gfs2-utils: master - fsck.gfs2: Keep proper counts when duplicates are found

Bob Peterson rpeterso at fedoraproject.org
Mon May 20 16:18:25 UTC 2013


Gitweb:        http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=a9af1133710ab33e992264b8889645fb88b1aeaf
Commit:        a9af1133710ab33e992264b8889645fb88b1aeaf
Parent:        107a5e95546c8fd975f3137fd4d324b77f921229
Author:        Bob Peterson <rpeterso at redhat.com>
AuthorDate:    Tue Apr 2 11:14:55 2013 -0700
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Mon May 20 11:12:46 2013 -0500

fsck.gfs2: Keep proper counts when duplicates are found

When fsck.gfs2 discovered a duplicate reference to the same block,
it was not properly incrementing the block counters for data and
metadata. Therefore, when the duplicate situation is resolved, the
resulting dinode is likely to have the wrong block count. This patch
makes it increment the counters, regardless of whether the block is
a duplicate reference.
---
 gfs2/fsck/pass1.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index a88895f..27bb5d4 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -218,6 +218,7 @@ static int check_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
 	/* Note if we've gotten this far, the block has already passed the
 	   check in metawalk: gfs2_check_meta(lbh, GFS2_METATYPE_LF).
 	   So we know it's a leaf block. */
+	bc->indir_count++;
 	q = block_type(block);
 	if (q != gfs2_block_free) {
 		log_err( _("Found duplicate block #%llu (0x%llx) referenced "
@@ -235,7 +236,6 @@ static int check_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
 			return -EEXIST;
 	}
 	fsck_blockmap_set(ip, block, _("directory leaf"), gfs2_leaf_blk);
-	bc->indir_count++;
 	return 0;
 }
 
@@ -401,6 +401,7 @@ static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
 				  gfs2_bad_block);
 		return 1;
 	}
+	bc->data_count++; /* keep the count sane anyway */
 	q = block_type(block);
 	if (q != gfs2_block_free) {
 		log_err( _("Found duplicate %s block %llu (0x%llx) "
@@ -415,16 +416,11 @@ static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
 				    "sort it out in pass1b.\n"));
 			add_duplicate_ref(ip, block, ref_as_data, 0,
 					  INODE_VALID);
-			/* If the prev ref was as data, this is likely a data
-			   block, so keep the block count for both refs. */
-			if (q == gfs2_block_used)
-				bc->data_count++;
 			return 1;
 		}
 		log_info( _("The block was invalid as metadata but might be "
 			    "okay as data.  I'll sort it out in pass1b.\n"));
 		add_duplicate_ref(ip, block, ref_as_data, 0, INODE_VALID);
-		bc->data_count++;
 		return 1;
 	}
 	/* In gfs1, rgrp indirect blocks are marked in the bitmap as "meta".
@@ -443,7 +439,6 @@ static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
 		fsck_blockmap_set(ip, block, _("jdata"), gfs2_jdata);
 	} else
 		fsck_blockmap_set(ip, block, _("data"), gfs2_block_used);
-	bc->data_count++;
 	return 0;
 }
 


More information about the cluster-commits mailing list