[Cluster-devel] cluster/gfs2/fsck metawalk.c pass1.c pass1c.c ...

rpeterso at sourceware.org rpeterso at sourceware.org
Fri Nov 16 23:21:31 UTC 2007


CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rpeterso at sourceware.org	2007-11-16 23:21:30

Modified files:
	gfs2/fsck      : metawalk.c pass1.c pass1c.c pass2.c pass5.c 

Log message:
	Resolves: bz 382581: GFS2: gfs2_fsck: buffer still held for block

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/metawalk.c.diff?cvsroot=cluster&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass1.c.diff?cvsroot=cluster&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass1c.c.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass2.c.diff?cvsroot=cluster&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/fsck/pass5.c.diff?cvsroot=cluster&r1=1.5&r2=1.6

--- cluster/gfs2/fsck/metawalk.c	2007/09/18 18:14:04	1.13
+++ cluster/gfs2/fsck/metawalk.c	2007/11/16 23:21:30	1.14
@@ -463,9 +463,11 @@
 		if(error > 0) {
 			return 1;
 		}
+		check_eattr_entries(ip, bh, pass);
+		if (bh)
+			brelse(bh, not_updated);
 	}
 
-	check_eattr_entries(ip, bh, pass);
 	return 0;
 }
 
@@ -487,9 +489,9 @@
 	log_debug("Checking EA indirect block #%"PRIu64" (0x%" PRIx64 ").\n",
 			  indirect, indirect);
 
-	if (!pass->check_eattr_indir ||
+	if (pass->check_eattr_indir &&
 	    !pass->check_eattr_indir(ip, indirect, ip->i_di.di_num.no_addr,
-								 &indirect_buf, pass->private)) {
+				     &indirect_buf, pass->private)) {
 		ea_leaf_ptr = (uint64_t *)(indirect_buf->b_data
 								   + sizeof(struct gfs2_meta_header));
 		end = ea_leaf_ptr + ((sdp->sd_sb.sb_bsize
--- cluster/gfs2/fsck/pass1.c	2007/09/18 18:14:04	1.11
+++ cluster/gfs2/fsck/pass1.c	2007/11/16 23:21:30	1.12
@@ -143,7 +143,6 @@
 	int ret = 0;
 	struct gfs2_block_query q = {0};
 	struct block_count *bc = (struct block_count *) private;
-	uint64_t block;
 
 	/* This inode contains an eattr - it may be invalid, but the
 	 * eattr attributes points to a non-zero block */
@@ -167,23 +166,27 @@
 		ret = 1;
 	}
 	else {
-		log_debug("Setting %" PRIu64 " (0x%"
-			  PRIx64 ") to eattr block\n", indirect, indirect);
-		gfs2_block_set(bl, indirect, gfs2_eattr_block);
+		log_debug("Marking inode %" PRIu64 " (0x%"
+			  PRIx64 ") with eattr block\n",
+			  ip->i_di.di_num.no_addr, ip->i_di.di_num.no_addr);
+		/* Mark the inode as having an eattr in the block map
+		   so pass1c can check it. */
+		gfs2_block_mark(bl, ip->i_di.di_num.no_addr, gfs2_eattr_block);
 
 		*bh = bread(sdp, indirect);
-		block = be64_to_cpu(*(*bh)->b_data);
 		if(gfs2_check_meta(*bh, GFS2_METATYPE_IN)) {
 			log_warn("EA indirect block %" PRIu64 " (0x%" PRIx64
-					 ") has incorrect type.\n", block, block);
-			gfs2_block_set(bl, block, gfs2_meta_inval);
+				 ") has incorrect type.\n",
+				 indirect, indirect);
+			gfs2_block_set(bl, indirect, gfs2_meta_inval);
 			ret = 1;
+			brelse(*bh, not_updated);
 		}
 		else {
 			/* FIXME: do i need to differentiate this as an ea_indir? */
 			log_debug("Setting %" PRIu64 " (0x%" PRIx64
-					  ") to indirect block\n", block, block);
-			gfs2_block_set(bl, block, gfs2_indir_blk);
+				  ") to indirect block\n", indirect, indirect);
+			gfs2_block_set(bl, indirect, gfs2_indir_blk);
 			bc->ea_count++;
 		}
 	}
@@ -293,6 +296,7 @@
 				 ip->i_di.di_num.no_addr);
 			gfs2_block_set(bl, block, gfs2_meta_inval);
 			ret = -1;
+			brelse(leaf_bh, not_updated);
 		}
 		else {
 			log_debug("Setting block %" PRIu64 " (0x%" PRIx64
@@ -300,7 +304,6 @@
 			gfs2_block_set(bl, block, gfs2_meta_eattr);
 			bc->ea_count++;
 		}
-		brelse(leaf_bh, not_updated);
 	}
 	*bh = leaf_bh;
 
--- cluster/gfs2/fsck/pass1c.c	2007/09/18 18:14:04	1.7
+++ cluster/gfs2/fsck/pass1c.c	2007/11/16 23:21:30	1.8
@@ -77,7 +77,6 @@
 	int *update = (int *) private;
 	struct gfs2_sbd *sbp = ip->i_sbd;
 	struct gfs2_block_query q;
-	struct gfs2_buffer_head *leaf_bh;
 
 	if(gfs2_check_range(sbp, block)) {
 		log_err("Extended attributes block out of range...removing\n");
@@ -96,9 +95,8 @@
 		return 1;
 	}
 	else 
-		leaf_bh = bread(sbp, block);
+		*bh = bread(sbp, block);
 
-	*bh = leaf_bh;
 	return 0;
 }
 
@@ -237,24 +235,28 @@
 
 		if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
 			return 0;
-		log_info("EA in inode %"PRIu64" (0x%" PRIx64 ")\n", block_no,
-				 block_no);
 		bh = bread(sbp, block_no);
-		ip = inode_get(sbp, bh);
+		if (gfs2_check_meta(bh, GFS2_METATYPE_IN)) { /* if a dinode */
+			log_info("EA in inode %"PRIu64" (0x%" PRIx64 ")\n",
+				 block_no, block_no);
+			gfs2_block_clear(bl, block_no, gfs2_eattr_block);
+			ip = inode_get(sbp, bh);
 
-		log_debug("Found eattr at %"PRIu64" (0x%" PRIx64 ")\n",
+			log_debug("Found eattr at %"PRIu64" (0x%" PRIx64 ")\n",
 				  ip->i_di.di_eattr, ip->i_di.di_eattr);
-		/* FIXME: Handle walking the eattr here */
-		error = check_inode_eattr(ip, &pass1c_fxns);
-		if(error < 0) {
-			stack;
-			return -1;
-		}
+			/* FIXME: Handle walking the eattr here */
+			error = check_inode_eattr(ip, &pass1c_fxns);
+			if(error < 0) {
+				stack;
+				brelse(bh, not_updated);
+				return -1;
+			}
 
-		if(update)
-			gfs2_dinode_out(&ip->i_di, bh->b_data);
+			if(update)
+				gfs2_dinode_out(&ip->i_di, bh->b_data);
 
-		free(ip);
+			free(ip);
+		}
 		brelse(bh, update);
 
 		block_no++;
--- cluster/gfs2/fsck/pass2.c	2007/09/18 18:14:04	1.9
+++ cluster/gfs2/fsck/pass2.c	2007/11/16 23:21:30	1.10
@@ -89,18 +89,13 @@
 static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
 			    uint64_t parent, struct gfs2_buffer_head **bh, void *private)
 {
-
+	*bh = bread(ip->i_sbd, block);
 	return 0;
 }
 static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
 			    uint64_t parent, struct gfs2_buffer_head **bh, void *private)
 {
-#if 0
-	struct gfs2_buffer_head *leaf_bh;
-
-	leaf_bh = bread(ip->i_sbd, block);
-	brelse(leaf_bh);
-#endif
+	*bh = bread(ip->i_sbd, block);
 	return 0;
 }
 
--- cluster/gfs2/fsck/pass5.c	2007/06/28 23:41:37	1.5
+++ cluster/gfs2/fsck/pass5.c	2007/11/16 23:21:30	1.6
@@ -81,7 +81,6 @@
 	while(byte < end) {
 		rg_status = ((*byte >> bit) & GFS2_BIT_MASK);
 		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;




More information about the Cluster-devel mailing list