Skip to contentSkip to conversation

cluster/gfs/gfs_fsck fsck.h initialize.c log.c ...

Cluster-devel [email protected] 1 participant 1 message Nov 17, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rpeterso at sourceware.org 2006-11-17 16:43:49

Modified files:
gfs/gfs_fsck : fsck.h initialize.c log.c main.c pass1.c
pass1b.c pass1c.c pass2.c pass3.c pass4.c pass5.c util.c

Log message:
Resolves: bz208836 - fatal: invalid metadata block
1. Fix a memory leak in pass1b.
2. Improve performance of pass1b by combining loops through fs.
3. Give an error message and abort if file system > 16TB and node architecture is 32-bits.
4. Give users an "Abort" "Continue" and "Skip" if they interrupt with ctrl-c. Also, report progress for that pass on interrupt.
5. Added more "percent complete" messages for other passes.

See bz comment #33 for more details.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_fsck/fsck.h.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_fsck/initialize.c.diff?cvsroot=cluster&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_fsck/log.c.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_fsck/main.c.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_fsck/pass1.c.diff?cvsroot=cluster&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_fsck/pass1b.c.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_fsck/pass1c.c.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_fsck/pass2.c.diff?cvsroot=cluster&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_fsck/pass3.c.diff?cvsroot=cluster&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_fsck/pass4.c.diff?cvsroot=cluster&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_fsck/pass5.c.diff?cvsroot=cluster&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/gfs_fsck/util.c.diff?cvsroot=cluster&r1=1.7&r2=1.8

gfs/gfs_fsck/fsck.h +2 -1
@@ -26,7 +26,8 @@
 	int no:1;
 };
 
-extern uint64_t last_fs_block;
+extern uint64_t last_fs_block, last_reported_block;
+extern int skip_this_pass, fsck_abort, fsck_query;
 
 int initialize(struct fsck_sb *sbp);
 void destroy(struct fsck_sb *sbp);
gfs/gfs_fsck/initialize.c +6 -0
@@ -210,6 +210,12 @@
 	}
 
 	sdp->last_fs_block = (jmax > rmax) ? jmax : rmax;
+	if (sdp->last_fs_block > 0xffffffff && sizeof(unsigned long) <= 4) {
+		log_crit("This file system is too big for this computer to handle.\n");
+		log_crit("Last fs block = 0x%llx, but sizeof(unsigned long) is %d bytes.\n",
+				 sdp->last_fs_block, sizeof(unsigned long));
+		goto fail;
+	}
 
 	sdp->last_data_block = rmax;
 	sdp->first_data_block = rmin;
gfs/gfs_fsck/log.c +3 -1
@@ -102,7 +102,8 @@
 	if(sbp->opts->no)
 		return 0;
 
-	/* Watch stdin (fd 0) to see when it has input. */
+	fsck_query = TRUE;
+    /* Watch stdin (fd 0) to see when it has input. */
 	FD_ZERO(&rfds);
 	FD_SET(STDIN_FILENO, &rfds);
 
@@ -149,5 +150,6 @@
 		read(STDIN_FILENO, &response, sizeof(char));
 	}
 
+	fsck_query = FALSE;
 	return ret;
 }
gfs/gfs_fsck/main.c +148 -35

211 lines not on this page · raw message

gfs/gfs_fsck/pass1.c +7 -0
@@ -905,6 +905,13 @@
 				break;
 
 			warm_fuzzy_stuff(block);
+			if (fsck_abort) /* if asked to abort */
+				return 0;
+			if (skip_this_pass) {
+				printf("Skipping pass 1 is not a good idea.\n");
+				skip_this_pass = FALSE;
+				fflush(stdout);
+			}
 			if(get_and_read_buf(sbp, block, &bh, 0)){
 				stack;
 				log_crit("Unable to retrieve block %"PRIu64
gfs/gfs_fsck/pass1b.c +17 -18
@@ -470,6 +470,7 @@
 	osi_list_t *tmp;
 	struct metawalk_fxns find_dirents = {0};
 	find_dirents.check_dentry = &find_dentry;
+	int rc = 0;
 
 	osi_list_init(&sbp->dup_list);
 	/* Shove all blocks marked as duplicated into a list */
@@ -487,10 +488,14 @@
 	log_info("Scanning filesystem for inodes containing duplicate blocks...\n");
 	log_debug("Filesystem has %"PRIu64" blocks total\n", sbp->last_fs_block);
 	for(i = 0; i < sbp->last_fs_block; i += 1) {
+		warm_fuzzy_stuff(i);
+		if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
+			goto out;
 		log_debug("Scanning block %"PRIu64" for inodes\n", i);
 		if(block_check(sbp->bl, i, &q)) {
 			stack;
-			return -1;
+			rc = -1;
+			goto out;
 		}
 		if((q.block_type == inode_dir) ||
 		   (q.block_type == inode_file) ||
@@ -503,33 +508,27 @@
 				b = osi_list_entry(tmp, struct blocks, list);
 				if(find_block_ref(sbp, i, b)) {
 					stack;
-					return -1;
+					rc = -1;
+					goto out;
 				}
 			}
 		}
-	}
-
-	/* Rescan the fs looking for directory entries to the inodes
-	 * with duplicate blocks - might need this to deal with the
-	 * inode correctly */
-	log_info("Looking through directory entries for inodes with duplicate blocks...\n");
-	for(i = 0; i < sbp->last_fs_block; i++) {
-		if(block_check(sbp->bl, i, &q)) {
-			stack;
-			return 0;
-		}
 		if(q.block_type == inode_dir) {
 			check_dir(sbp, i, &find_dirents);
 		}
 	}
 
-
 	/* Fix dups here - it's going to slow things down a lot to fix
 	 * it later */
 	log_info("Handling duplicate blocks\n");
-	osi_list_foreach(tmp, &sbp->dup_list) {
-		b = osi_list_entry(tmp, struct blocks, list);
-		handle_dup_blk(sbp, b);
+out:
+	/*osi_list_foreach(tmp, &sbp->dup_list) {*/
+	while (!osi_list_empty(&sbp->dup_list)) {
+		b = osi_list_entry(sbp->dup_list.next, struct blocks, list);
+		if (!skip_this_pass && !rc) /* no error & not asked to skip the rest */
+			handle_dup_blk(sbp, b);
+		osi_list_del(&b->list);
+		free(b);
 	}
-	return 0;
+	return rc;
 }
gfs/gfs_fsck/pass1c.c +2 -0
@@ -252,6 +252,8 @@
 	log_info("Looking for inodes containing ea blocks...\n");
 	while (!find_next_block_type(sbp->bl, eattr_block, &block_no)) {
 
+		if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
+			return 0;
 		log_info("EA in inode %"PRIu64"\n", block_no);
 		if(get_and_read_buf(sbp, block_no, &bh, 0)) {
 			stack;
gfs/gfs_fsck/pass2.c +4 -0
@@ -812,6 +812,10 @@
 	/* Grab each directory inode, and run checks on it */
 	for(i = 0; i < sbp->last_fs_block; i++) {
 
+		warm_fuzzy_stuff(i);
+		if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
+			return 0;
+
 		/* Skip the root inode - it's checked above */
 		if(i == sbp->sb.sb_root_di.no_addr)
 			continue;
gfs/gfs_fsck/pass3.c +2 -0
@@ -213,6 +213,8 @@
 			/* FIXME: Change this so it returns success or
 			 * failure and put the parent inode in a
 			 * param */
+			if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
+				return 0;
 			tdi = mark_and_return_parent(sbp, di);
 
 			/* FIXME: Factor this ? */
gfs/gfs_fsck/pass4.c +4 -0
@@ -49,6 +49,8 @@
 	/* FIXME: should probably factor this out into a generic
 	 * scanning fxn */
 	osi_list_foreach(tmp, list) {
+		if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
+			return 0;
 		if(!(ii = osi_list_entry(tmp, struct inode_info, list))) {
 			log_crit("osi_list_foreach broken in scan_info_list!!\n");
 			exit(1);
@@ -176,6 +178,8 @@
 			  sbp->lf_dip->i_di.di_entries);
 	log_info("Checking inode reference counts.\n");
 	for (i = 0; i < FSCK_HASH_SIZE; i++) {
+		if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
+			return 0;
 		list = &sbp->inode_hash[i];
 		if(scan_inode_list(sbp, list)) {
 			stack;
gfs/gfs_fsck/pass5.c +6 -0
@@ -194,6 +194,8 @@
 		block = rg_data + *rg_block;
 		log_debug("Checking block %" PRIu64 "\n", block);
 		warm_fuzzy_stuff(block);
+		if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
+			return 0;
 		block_check(sbp->bl, block, &q);
 
 		block_status = convert_mark(q.block_type, count);
@@ -266,6 +268,8 @@
 				   BH_DATA(rgp->rd_bh[i]) + bits->bi_offset,
 				   bits->bi_len, &rg_block,
 				   rgp->rd_ri.ri_data1, count);
+		if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
+			return 0;
 	}
 
 	/* Compare the rgrps counters with what we found */
@@ -351,6 +355,8 @@
 
 	/* Reconcile RG bitmaps with fsck bitmap */
 	for(tmp = sbp->rglist.next; tmp != &sbp->rglist; tmp = tmp->next){
+		if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
+			return 0;
 		log_info("Updating Resource Group %"PRIu64"\n", rg_count);
 		memset(count, 0, sizeof(*count) * 5);
 		rgp = osi_list_entry(tmp, struct fsck_rgrp, rd_list);
gfs/gfs_fsck/util.c +1 -0
@@ -321,6 +321,7 @@
 	static struct timeval tv;
 	static uint32_t seconds = 0;
 	
+	last_reported_block = block;
 	gettimeofday(&tv, NULL);
 	if (!seconds)
 		seconds = tv.tv_sec;