[Cluster-devel] [fsck.gfs2 PATCH 26/30] fsck.gfs2: blocks cannot be UNLINKED in pass1b or after that

Bob Peterson rpeterso at redhat.com
Fri Apr 15 13:38:20 UTC 2016


This patch basically changes some checks for blocks in an UNLINKED
state to checking the FREE state instead. If any blocks were in the
UNLINKED state, they would have already been resolved by the time
we get to pass1b, and therefore the checks can only be in error.

Signed-off-by: Bob Peterson <rpeterso at redhat.com>
---
 gfs2/fsck/pass1b.c | 18 +++++++++---------
 gfs2/fsck/pass2.c  | 10 +---------
 gfs2/fsck/pass3.c  |  2 +-
 gfs2/fsck/pass4.c  |  2 +-
 4 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index d6ab285..f5f286a 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -358,7 +358,7 @@ static void resolve_dup_references(struct gfs2_sbd *sdp, struct duptree *dt,
 					  0);
 				fsck_bitmap_set(ip, ip->i_di.di_num.no_addr,
 						_("duplicate referencing bad"),
-						GFS2_BLKST_UNLINKED);
+						GFS2_BLKST_FREE);
 				/* We delete the dup_handler inode count and
 				   duplicate id BEFORE clearing the metadata,
 				   because if this is the last reference to
@@ -574,13 +574,11 @@ static void resolve_last_reference(struct gfs2_sbd *sdp, struct duptree *dt,
 		clone_dup_ref_in_inode(ip, dt);
 
 	q = bitmap_type(sdp, id->block_no);
-	if (q == GFS2_BLKST_UNLINKED) {
-		log_debug( _("The remaining reference inode %lld (0x%llx) is "
-			     "marked invalid: Marking the block as free.\n"),
+	if (q == GFS2_BLKST_FREE) {
+		log_debug( _("The remaining reference inode %lld (0x%llx) was "
+			     "already marked free.\n"),
 			   (unsigned long long)id->block_no,
 			   (unsigned long long)id->block_no);
-		fsck_bitmap_set(ip, dt->block, _("reference-repaired leaf"),
-				  GFS2_BLKST_FREE);
 	} else if (id->reftypecount[ref_is_inode]) {
 		set_ip_bitmap(ip);
 	} else if (id->reftypecount[ref_as_data]) {
@@ -941,11 +939,13 @@ int pass1b(struct gfs2_sbd *sdp)
 		if (q == GFS2_BLKST_FREE || q == GFS2_BLKST_USED || q < 0)
 			continue;
 
-		if (q == GFS2_BLKST_UNLINKED)
-			log_debug( _("Checking invalidated duplicate block "
-				     "%lld (0x%llx)\n"),
+		if (q == GFS2_BLKST_UNLINKED) {
+			log_debug( _("Error: block %lld (0x%llx) is still "
+				     "marked UNLINKED.\n"),
 				   (unsigned long long)i,
 				   (unsigned long long)i);
+			return FSCK_ERROR;
+		}
 
 		warm_fuzzy_stuff(i);
 		if (find_block_ref(sdp, i) < 0) {
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index d4f50d2..ffd58dc 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -1889,7 +1889,7 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
 	ds.q = bitmap_type(sysinode->i_sbd, iblock);
 
 	pass2_fxns.private = (void *) &ds;
-	if (ds.q == GFS2_BLKST_UNLINKED) {
+	if (ds.q == GFS2_BLKST_FREE) {
 		/* First check that the directory's metatree is valid */
 		error = check_metatree(sysinode, &pass2_fxns);
 		if (error < 0) {
@@ -1996,14 +1996,6 @@ static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
 	int error;
 
 	pass2_fxns.private = &ds;
-	if (ds.q == GFS2_BLKST_UNLINKED) {
-		/* First check that the directory's metatree is valid */
-		error = check_metatree(ip, &pass2_fxns);
-		if (error < 0) {
-			stack;
-			return error;
-		}
-	}
 	error = check_dir(sdp, ip, &pass2_fxns);
 	if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
 		return FSCK_OK;
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index 2fa0bdb..fbf8318 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -239,7 +239,7 @@ int pass3(struct gfs2_sbd *sdp)
 			}
 			q = bitmap_type(sdp, di->dinode.no_addr);
 			ip = fsck_load_inode(sdp, di->dinode.no_addr);
-			if (q == GFS2_BLKST_UNLINKED) {
+			if (q == GFS2_BLKST_FREE) {
 				log_err( _("Found unlinked directory "
 					   "containing bad block at block %llu"
 					   " (0x%llx)\n"),
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index 16339cc..313ff0f 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -61,7 +61,7 @@ static int handle_unlinked(struct gfs2_sbd *sdp, uint64_t no_addr,
 	log_err( _("Found unlinked inode at %llu (0x%llx)\n"),
 		 (unsigned long long)no_addr, (unsigned long long)no_addr);
 	q = bitmap_type(sdp, no_addr);
-	if (q == GFS2_BLKST_UNLINKED) {
+	if (q == GFS2_BLKST_FREE) {
 		log_err( _("Unlinked inode %llu (0x%llx) contains bad "
 			   "blocks\n"), (unsigned long long)no_addr,
 			 (unsigned long long)no_addr);
-- 
2.5.5




More information about the Cluster-devel mailing list