From: Bob Peterson Date: Fri, 13 Jan 2017 15:33:00 -0500 (EST) Subject: [Cluster-devel] [fsck.gfs PATCH] fsck.gfs2: Repair rindex entries that were destroyed In-Reply-To: <750571242.10393034.1484339479059.JavaMail.zimbra@redhat.com> Message-ID: <1485324214.10393623.1484339580049.JavaMail.zimbra@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, If an rindex entry was destroyed, the rindex was skipped, which means its rgrp never gets inserted into the rgrp tree. The trouble is, that causes a off-by-one-entry problem with all subsequent rindex entries. So if rindex entry R is destroyed, then rebuilt, originally good entry R+1 is checked against new entry for R. Function rg_repair already had the capability to insert new rindex entries, but only at the end. This would be typical for a gfs2_grow that failed and left a bunch of rgrps on the device, but the rindex was never synced properly. This patch allows the function to insert catch-up entries in the middle, which re-syncs the actual versus expected rgrp trees. Signed-off-by: Bob Peterson --- diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c index 49bbad6..f397db1 100644 --- a/gfs2/fsck/rgrepair.c +++ b/gfs2/fsck/rgrepair.c @@ -1137,10 +1137,14 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count, int *sane) next = osi_next(n); enext = osi_next(e); expected = (struct rgrp_tree *)e; + actual = (struct rgrp_tree *)n; - /* If we ran out of actual rindex entries due to rindex + /* If the next "actual" rgrp in memory is too far away, + fill in a new one with the expected value. -or- + If we ran out of actual rindex entries due to rindex damage, fill in a new one with the expected values. */ - if (!n) { /* end of actual rindex */ + if (!n || /* end of actual rindex */ + expected->ri.ri_addr < actual->ri.ri_addr) { log_err( _("Entry missing from rindex: 0x%llx\n"), (unsigned long long)expected->ri.ri_addr); actual = rgrp_insert(&sdp->rgtree, @@ -1150,8 +1154,9 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count, int *sane) break; } rindex_modified = 1; + next = n; /* Ensure that the old actual gets checked + against a new expected, since we added */ } else { - actual = (struct rgrp_tree *)n; ri_compare(rg, actual->ri, expected->ri, ri_addr, "llx", unsigned long long); ri_compare(rg, actual->ri, expected->ri, ri_length,