* [Cluster-devel] [PATCH 1/2] gfs2_edit savemeta: Split out the rgrp saving code
@ 2017-01-18 16:25 Andrew Price
2017-01-18 16:25 ` [Cluster-devel] [PATCH 2/2] gfs2_edit savemeta: Save corrupt rgrp headers Andrew Price
2017-01-18 16:46 ` [Cluster-devel] [PATCH 1/2] gfs2_edit savemeta: Split out the rgrp saving code Bob Peterson
0 siblings, 2 replies; 3+ messages in thread
From: Andrew Price @ 2017-01-18 16:25 UTC (permalink / raw)
To: cluster-devel.redhat.com
Factor out the rgrp saving code into its own function to make it easier
to work with.
Signed-off-by: Andrew Price <anprice@redhat.com>
---
gfs2/edit/savemeta.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index f6b7ff0..da24645 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -770,6 +770,26 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
free(ibuf);
}
+static void save_rgrp(struct metafd *mfd, struct rgrp_tree *rgd, int withcontents)
+{
+ uint64_t addr = rgd->ri.ri_addr;
+ uint32_t i;
+
+ if (gfs2_rgrp_read(&sbd, rgd))
+ return;
+ log_debug("RG at %"PRIu64" (0x%"PRIx64") is %u long\n",
+ addr, addr, rgd->ri.ri_length);
+ /* Save the rg and bitmaps */
+ for (i = 0; i < rgd->ri.ri_length; i++) {
+ warm_fuzzy_stuff(rgd->ri.ri_addr + i, FALSE);
+ save_bh(mfd, rgd->bits[i].bi_bh, 0, NULL);
+ }
+ /* Save the other metadata: inodes, etc. if mode is not 'savergs' */
+ if (withcontents)
+ save_allocated(rgd, mfd);
+ gfs2_rgrp_relse(rgd);
+}
+
static int save_header(struct metafd *mfd, uint64_t fsbytes)
{
struct savemeta_header smh = {
@@ -878,25 +898,9 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
/* Walk through the resource groups saving everything within */
for (n = osi_first(&sbd.rgtree); n; n = osi_next(n)) {
struct rgrp_tree *rgd;
- unsigned i;
rgd = (struct rgrp_tree *)n;
- if (gfs2_rgrp_read(&sbd, rgd))
- continue;
- log_debug("RG at %lld (0x%llx) is %u long\n",
- (unsigned long long)rgd->ri.ri_addr,
- (unsigned long long)rgd->ri.ri_addr,
- rgd->ri.ri_length);
- /* Save off the rg and bitmaps */
- for (i = 0; i < rgd->ri.ri_length; i++) {
- warm_fuzzy_stuff(rgd->ri.ri_addr + i, FALSE);
- save_bh(&mfd, rgd->bits[i].bi_bh, 0, NULL);
- }
- /* Save off the other metadata: inodes, etc. if mode is not 'savergs' */
- if (saveoption != 2) {
- save_allocated(rgd, &mfd);
- }
- gfs2_rgrp_relse(rgd);
+ save_rgrp(&mfd, rgd, (saveoption != 2));
}
/* Clean up */
/* There may be a gap between end of file system and end of device */
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH 2/2] gfs2_edit savemeta: Save corrupt rgrp headers
2017-01-18 16:25 [Cluster-devel] [PATCH 1/2] gfs2_edit savemeta: Split out the rgrp saving code Andrew Price
@ 2017-01-18 16:25 ` Andrew Price
2017-01-18 16:46 ` [Cluster-devel] [PATCH 1/2] gfs2_edit savemeta: Split out the rgrp saving code Bob Peterson
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Price @ 2017-01-18 16:25 UTC (permalink / raw)
To: cluster-devel.redhat.com
Previously, savemeta used gfs2_rgrp_read() to read resource groups. This
includes a metadata check which fails the read if the resource groups
are corrupt. Since we want to save corruption in order to analyze it, we
need to read the rgrp headers without checking them. Use a new,
simplified rgrp_read() function for that.
Also avoid the effect of a similar metadata check in
get_gfs_struct_info() when saving rgrps.
Signed-off-by: Andrew Price <anprice@redhat.com>
---
gfs2/edit/savemeta.c | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index da24645..dee405b 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -417,7 +417,8 @@ static int save_bh(struct metafd *mfd, struct gfs2_buffer_head *savebh, uint64_t
because we want to know if the source inode is a system inode
not the block within the inode "blk". They may or may not
be the same thing. */
- if (get_gfs_struct_info(savebh, owner, blktype, &blklen) && !block_is_systemfile(owner))
+ if (get_gfs_struct_info(savebh, owner, blktype, &blklen) &&
+ !block_is_systemfile(owner) && owner != 0)
return 0; /* Not metadata, and not system file, so skip it */
/* No need to save trailing zeroes */
@@ -770,12 +771,41 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
free(ibuf);
}
+/* We don't use gfs2_rgrp_read() here as it checks for metadata sanity and we
+ want to save rgrp headers even if they're corrupt. */
+static int rgrp_read(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
+{
+ unsigned x, length = rgd->ri.ri_length;
+ struct gfs2_buffer_head **bhs;
+
+ if (length == 0 || gfs2_check_range(sdp, rgd->ri.ri_addr))
+ return -1;
+
+ bhs = calloc(length, sizeof(struct gfs2_buffer_head *));
+ if (bhs == NULL)
+ return -1;
+
+ if (breadm(sdp, bhs, length, rgd->ri.ri_addr)) {
+ free(bhs);
+ return -1;
+ }
+ for (x = 0; x < length; x++)
+ rgd->bits[x].bi_bh = bhs[x];
+
+ if (sdp->gfs1)
+ gfs_rgrp_in((struct gfs_rgrp *)&rgd->rg, rgd->bits[0].bi_bh);
+ else
+ gfs2_rgrp_in(&rgd->rg, rgd->bits[0].bi_bh);
+ free(bhs);
+ return 0;
+}
+
static void save_rgrp(struct metafd *mfd, struct rgrp_tree *rgd, int withcontents)
{
uint64_t addr = rgd->ri.ri_addr;
uint32_t i;
- if (gfs2_rgrp_read(&sbd, rgd))
+ if (rgrp_read(&sbd, rgd))
return;
log_debug("RG at %"PRIu64" (0x%"PRIx64") is %u long\n",
addr, addr, rgd->ri.ri_length);
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH 1/2] gfs2_edit savemeta: Split out the rgrp saving code
2017-01-18 16:25 [Cluster-devel] [PATCH 1/2] gfs2_edit savemeta: Split out the rgrp saving code Andrew Price
2017-01-18 16:25 ` [Cluster-devel] [PATCH 2/2] gfs2_edit savemeta: Save corrupt rgrp headers Andrew Price
@ 2017-01-18 16:46 ` Bob Peterson
1 sibling, 0 replies; 3+ messages in thread
From: Bob Peterson @ 2017-01-18 16:46 UTC (permalink / raw)
To: cluster-devel.redhat.com
----- Original Message -----
| Factor out the rgrp saving code into its own function to make it easier
| to work with.
|
| Signed-off-by: Andrew Price <anprice@redhat.com>
| ---
ACK to both patches. Thanks for sorting this out.
Regards,
Bob Peterson
Red Hat File Systems
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-18 16:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-18 16:25 [Cluster-devel] [PATCH 1/2] gfs2_edit savemeta: Split out the rgrp saving code Andrew Price
2017-01-18 16:25 ` [Cluster-devel] [PATCH 2/2] gfs2_edit savemeta: Save corrupt rgrp headers Andrew Price
2017-01-18 16:46 ` [Cluster-devel] [PATCH 1/2] gfs2_edit savemeta: Split out the rgrp saving code Bob Peterson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).