Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=11d171e7...
Commit: 11d171e73e0f960c65e50e2a5fc3fac136d1076c
Parent: 648a5d7c208bc9e342db31b1c79f019f448b5295
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Fri Feb 12 14:58:29 2016 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Feb 25 11:47:40 2016 -0500
fsck.gfs2: Add ability to fix rindex file size
Before this patch, fsck.gfs2 checked the size of rindex, and if
it wasn't evenly divisible by the size of an rindex entry, it
threw up its hands and gave up. This patch allows fsck.gfs2 to
repair the rindex size, basically rounding down to the largest
number of rgrps that will fit.
Signed-off-by: Bob Peterson <rpeterso(a)redhat.com>
---
gfs2/fsck/rgrepair.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 6e56f91..1fefc34 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -934,10 +934,18 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count,
int *sane)
sdp->rgtree.osi_node = NULL; /* Just to be safe */
rindex_read(sdp, 0, &sdp->rgrps, sane);
if (sdp->md.riinode->i_di.di_size % sizeof(struct gfs2_rindex)) {
- log_warn( _("WARNING: rindex file is corrupt.\n"));
- gfs2_rgrp_free(&sdp->rgcalc);
- gfs2_rgrp_free(&sdp->rgtree);
- return -1;
+ log_warn( _("WARNING: rindex file has an invalid size.\n"));
+ if (!query( _("Truncate the rindex size? (y/n)"))) {
+ log_err(_("The rindex was not repaired.\n"));
+ gfs2_rgrp_free(&sdp->rgcalc);
+ gfs2_rgrp_free(&sdp->rgtree);
+ return -1;
+ }
+ sdp->md.riinode->i_di.di_size /= sizeof(struct gfs2_rindex);
+ sdp->md.riinode->i_di.di_size *= sizeof(struct gfs2_rindex);
+ bmodified(sdp->md.riinode->i_bh);
+ log_err(_("Changing rindex size to %lld.\n"),
+ (unsigned long long)sdp->md.riinode->i_di.di_size);
}
log_warn( _("L%d: number of rgs expected = %lld.\n"), trust_lvl + 1,
(unsigned long long)sdp->rgrps);