Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=013... Commit: 013d20413ffb8d960089836be487b9c16a9f12d6 Parent: 3da2b5547b562a9f332f4875738f131d8f6f0a2e Author: Bob Peterson bob@ganesha.peterson AuthorDate: Fri Jan 22 13:55:51 2010 -0600 Committer: Bob Peterson rpeterso@redhat.com CommitterDate: Tue Jan 26 14:39:30 2010 -0600
fsck.gfs2: metawalk needs to check for no valid leaf blocks
The code that validates directory leaf blocks was failing in rare cases where the directory had no valid leaf blocks at all. It would give a good return code and pretend everything was okay when, in fact, it left corruption out there.
rhbz#455300 --- gfs2/fsck/metawalk.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index 0a25160..a0ca65b 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -532,7 +532,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass) int error; struct gfs2_leaf leaf, oldleaf; uint64_t leaf_no, old_leaf, bad_leaf = -1; - uint64_t first_leaf_ptr = -1, first_ok_leaf = -1; + uint64_t first_ok_leaf; struct gfs2_buffer_head *lbh; int lindex; struct gfs2_sbd *sbp = ip->i_sbd; @@ -542,21 +542,27 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass) /* Find the first valid leaf pointer in range and use it as our "old" leaf. That way, bad blocks at the beginning will be overwritten with the first valid leaf. */ - first_ok_leaf = -1; + first_ok_leaf = leaf_no = -1; for(lindex = 0; lindex < (1 << ip->i_di.di_depth); lindex++) { - gfs2_get_leaf_nr(ip, lindex, &first_ok_leaf); - if (first_leaf_ptr == -1) - first_leaf_ptr = first_ok_leaf; - if(gfs2_check_range(ip->i_sbd, first_ok_leaf) == 0) { - lbh = bread(sbp, first_ok_leaf); + gfs2_get_leaf_nr(ip, lindex, &leaf_no); + if (gfs2_check_range(ip->i_sbd, leaf_no) == 0) { + lbh = bread(sbp, leaf_no); /* Make sure it's really a valid leaf block. */ if (gfs2_check_meta(lbh, GFS2_METATYPE_LF) == 0) { brelse(lbh); + first_ok_leaf = leaf_no; break; } brelse(lbh); } } + if (first_ok_leaf == -1) { /* no valid leaf found */ + log_err( _("Directory #%llu (0x%llx) has no valid leaf " + "blocks\n"), + (unsigned long long)ip->i_di.di_num.no_addr, + (unsigned long long)ip->i_di.di_num.no_addr); + return 1; + } old_leaf = -1; memset(&oldleaf, 0, sizeof(oldleaf)); for(lindex = 0; lindex < (1 << ip->i_di.di_depth); lindex++) {
cluster-commits@lists.stg.fedorahosted.org