Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 35adedb8830cf948b43b86231991124b > files > 13

gfs2-utils-0.1.62-39.el5.src.rpm

commit 8d3521017ebe5e9b8d8e190f1b33af601b461972
Author: Bob Peterson <bob@ganesha.peterson>
Date:   Wed Jan 20 12:31:38 2010 -0600

    libgfs2, fsck.gfs2: simplify block_query code
    
    This patch simplifies the block query code.  Now that the blockmap
    code doesn't have the duplicate block reference responsibilities,
    we don't need the query info to be in its own structure.  The
    block query can be reduced to a simple fetch from memory and mask
    off the bits we need.  The block query used to check for a valid
    block range.  Now, for performance reasons, that's the
    responsibility of the caller.  Most of the callers check for a
    valid range anyway, so checking it in the query was a waste of
    time.  This is for better performance and makes the code simpler
    and more readable.
    
    rhbz#455300

diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index 37fe632..2510ecb 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -56,7 +56,7 @@ struct dir_info
 struct dir_status {
 	uint8_t dotdir:1;
 	uint8_t dotdotdir:1;
-	struct gfs2_block_query q;
+	uint8_t q;
 	uint32_t entry_count;
 };
 
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 07850de..5fa5ce4 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -25,6 +25,7 @@
 #include "libgfs2.h"
 #include "lost_n_found.h"
 #include "link.h"
+#include "util.h"
 
 /* add_inode_to_lf - Add dir entry to lost+found for the inode
  * @ip: inode to add to lost + found
@@ -42,16 +43,13 @@ int add_inode_to_lf(struct gfs2_inode *ip){
 	__be32 inode_type;
 
 	if(!lf_dip) {
-		struct gfs2_block_query q = {0};
+		uint8_t q;
 
 		log_info( _("Locating/Creating lost and found directory\n"));
 
         lf_dip = createi(ip->i_sbd->md.rooti, "lost+found", S_IFDIR | 0700, 0);
-	if(gfs2_block_check(ip->i_sbd, bl, lf_dip->i_di.di_num.no_addr, &q)) {
-			stack;
-			return -1;
-		}
-		if(q.block_type != gfs2_inode_dir) {
+		q = block_type(lf_dip->i_di.di_num.no_addr);
+		if(q != gfs2_inode_dir) {
 			/* This is a new lost+found directory, so set its
 			 * block type and increment link counts for
 			 * the directories */
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index 8d1f8e8..3b5bfac 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -27,6 +27,7 @@
 #include "libgfs2.h"
 #include "fsck.h"
 #include "osi_list.h"
+#include "util.h"
 
 struct gfs2_options opts = {0};
 struct gfs2_inode *lf_dip; /* Lost and found directory inode */
@@ -174,22 +175,17 @@ static int check_system_inode(struct gfs2_inode *sysinode, const char *filename,
 		
 		/* FIXME: check this block's validity */
 
-		if(gfs2_block_check(sysinode->i_sbd, bl, iblock, &ds.q)) {
-			log_crit( _("Can't get %s inode block %" PRIu64 " (0x%"
-				 PRIx64 ") from block list\n"), filename,
-				 iblock, iblock);
-			return -1;
-		}
+		ds.q = block_type(iblock);
 		/* If the inode exists but the block is marked      */
 		/* free, we might be recovering from a corrupt      */
 		/* bitmap.  In that case, don't rebuild the inode.  */
 		/* Just reuse the inode and fix the bitmap.         */
-		if (ds.q.block_type == gfs2_block_free) {
+		if (ds.q == gfs2_block_free) {
 			log_info( _("The inode exists but the block is not marked 'in use'; fixing it.\n"));
 			gfs2_blockmap_set(sysinode->i_sbd, bl,
 				       sysinode->i_di.di_num.no_addr,
 				       mark);
-			ds.q.block_type = mark;
+			ds.q = mark;
 			if (mark == gfs2_inode_dir)
 				add_to_dir_list(sysinode->i_sbd,
 						sysinode->i_di.di_num.no_addr);
@@ -201,14 +197,14 @@ static int check_system_inode(struct gfs2_inode *sysinode, const char *filename,
 	 * create a new inode and get it all setup - of course,
 	 * everything will be in lost+found then, but we *need* our
 	 * system inodes before we can do any of that. */
-	if(!sysinode || ds.q.block_type != mark) {
+	if(!sysinode || ds.q != mark) {
 		log_err( _("Invalid or missing %s system inode.\n"), filename);
 		if (query(_("Create new %s system inode? (y/n) "), filename)) {
 			builder(sysinode->i_sbd);
 			gfs2_blockmap_set(sysinode->i_sbd, bl,
 				       sysinode->i_di.di_num.no_addr,
 				       mark);
-			ds.q.block_type = mark;
+			ds.q = mark;
 			if (mark == gfs2_inode_dir)
 				add_to_dir_list(sysinode->i_sbd,
 						sysinode->i_di.di_num.no_addr);
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 38e9cc5..1a701e1 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1098,7 +1098,7 @@ int remove_dentry_from_dir(struct gfs2_sbd *sbp, uint64_t dir,
 			   uint64_t dentryblock)
 {
 	struct metawalk_fxns remove_dentry_fxns = {0};
-	struct gfs2_block_query q;
+	uint8_t q;
 	int error;
 
 	log_debug( _("Removing dentry %" PRIu64 " (0x%" PRIx64 ") from directory %"
@@ -1110,11 +1110,8 @@ int remove_dentry_from_dir(struct gfs2_sbd *sbp, uint64_t dir,
 	remove_dentry_fxns.private = &dentryblock;
 	remove_dentry_fxns.check_dentry = remove_dentry;
 
-	if(gfs2_block_check(sbp, bl, dir, &q)) {
-		stack;
-		return -1;
-	}
-	if(q.block_type != gfs2_inode_dir) {
+	q = block_type(dir);
+	if(q != gfs2_inode_dir) {
 		log_info( _("Parent block is not a directory...ignoring\n"));
 		return 1;
 	}
@@ -1205,11 +1202,7 @@ int delete_blocks(struct gfs2_inode *ip, uint64_t block,
 		  struct gfs2_buffer_head **bh, const char *btype,
 		  void *private)
 {
-	struct gfs2_block_query q = {0};
-
 	if (gfs2_check_range(ip->i_sbd, block) == 0) {
-		if (gfs2_block_check(ip->i_sbd, bl, block, &q))
-			return 0;
 		if(!is_duplicate(block)) {
 			log_info( _("Deleting %s block %lld (0x%llx) as part "
 				    "of inode %lld (0x%llx)\n"), btype,
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 134476b..40d316e 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -97,7 +97,7 @@ static int leaf(struct gfs2_inode *ip, uint64_t block,
 static int check_metalist(struct gfs2_inode *ip, uint64_t block,
 			  struct gfs2_buffer_head **bh, void *private)
 {
-	struct gfs2_block_query q = {0};
+	uint8_t q;
 	int found_dup = 0;
 	struct gfs2_buffer_head *nbh;
 	struct block_count *bc = (struct block_count *)private;
@@ -111,13 +111,10 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
 
 		return 1;
 	}
-	if(gfs2_block_check(ip->i_sbd, bl, block, &q)) {
-		stack;
-		return -1;
-	}
-	if(q.block_type != gfs2_block_free) {
+	q = block_type(block);
+	if(q != gfs2_block_free) {
 		log_err( _("Found duplicate block referenced as metadata in "
-			   "indirect block - was marked %d\n"), q.block_type);
+			   "indirect block - was marked %d\n"), q);
 		gfs2_dup_set(block);
 		found_dup = 1;
 	}
@@ -147,7 +144,7 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
 
 static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
 {
-	struct gfs2_block_query q = {0};
+	uint8_t q;
 	struct block_count *bc = (struct block_count *) private;
 	int error = 0, btype;
 
@@ -164,20 +161,15 @@ static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
 			       gfs2_bad_block);
 		return 1;
 	}
-	if(gfs2_block_check(ip->i_sbd, bl, block, &q)) {
-		stack;
-		log_err( _("Found bad block referenced as data at %"
-			   PRIu64 " (0x%"PRIx64 ")\n"), block, block);
-		return -1;
-	}
-	if(q.block_type != gfs2_block_free) {
+	q = block_type(block);
+	if(q != gfs2_block_free) {
 		log_err( _("Found duplicate block referenced as data at %"
 			   PRIu64 " (0x%"PRIx64 ")\n"), block, block);
-		if (q.block_type != gfs2_meta_inval) {
+		if (q != gfs2_meta_inval) {
 			gfs2_dup_set(block);
 			/* If the prev ref was as data, this is likely a data
 			   block, so keep the block count for both refs. */
-			if (q.block_type == gfs2_block_used)
+			if (q == gfs2_block_used)
 				bc->data_count++;
 			return 1;
 		}
@@ -258,11 +250,6 @@ static int ask_remove_inode_eattr(struct gfs2_inode *ip,
 		 (unsigned long long)ip->i_di.di_num.no_addr);
 	if (query( _("Clear all Extended Attributes from the "
 		     "inode? (y/n) "))) {
-		struct gfs2_block_query q;
-		if(gfs2_block_check(ip->i_sbd, bl, ip->i_di.di_eattr, &q)) {
-			stack;
-			return -1;
-		}
 		if (!remove_inode_eattr(ip, bc,
 					is_duplicate(ip->i_di.di_eattr)))
 			log_err( _("Extended attributes were removed.\n"));
@@ -319,7 +306,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
 {
 	struct gfs2_sbd *sdp = ip->i_sbd;
 	int ret = 0;
-	struct gfs2_block_query q = {0};
+	uint8_t q;
 	struct block_count *bc = (struct block_count *) private;
 
 	/* This inode contains an eattr - it may be invalid, but the
@@ -332,10 +319,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
 		 * in pass1c */
 		return 1;
 	}
-	if(gfs2_block_check(sdp, bl, indirect, &q)) {
-		stack;
-		return -1;
-	}
+	q = block_type(indirect);
 
 	/* Special duplicate processing:  If we have an EA block,
 	   check if it really is an EA.  If it is, let duplicate
@@ -343,7 +327,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
 	   count it as a duplicate. */
 	*bh = bread(sdp, indirect);
 	if(gfs2_check_meta(*bh, GFS2_METATYPE_IN)) {
-		if(q.block_type != gfs2_block_free) { /* Duplicate? */
+		if(q != gfs2_block_free) { /* Duplicate? */
 			if (!clear_eas(ip, bc, indirect, 1,
 				       _("Bad indirect Extended Attribute "
 					 "duplicate found"))) {
@@ -357,7 +341,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
 			    "type"));
 		return 1;
 	}
-	if(q.block_type != gfs2_block_free) { /* Duplicate? */
+	if(q != gfs2_block_free) { /* Duplicate? */
 		log_err( _("Inode #%llu (0x%llx): Duplicate Extended "
 			   "Attribute indirect block found at #%llu "
 			   "(0x%llx).\n"),
@@ -414,19 +398,16 @@ static int check_leaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
 {
 	struct gfs2_buffer_head *leaf_bh = NULL;
 	struct gfs2_sbd *sdp = ip->i_sbd;
-	struct gfs2_block_query q = {0};
+	uint8_t q;
 	struct block_count *bc = (struct block_count *) private;
 
-	if(gfs2_block_check(sdp, bl, block, &q)) {
-		stack;
-		return -1;
-	}
+	q = block_type(block);
 	/* Special duplicate processing:  If we have an EA block, check if it
 	   really is an EA.  If it is, let duplicate handling sort it out.
 	   If it isn't, clear it but don't count it as a duplicate. */
 	leaf_bh = bread(sdp, block);
 	if(gfs2_check_meta(leaf_bh, btype)) {
-		if(q.block_type != gfs2_block_free) { /* Duplicate? */
+		if(q != gfs2_block_free) { /* Duplicate? */
 			clear_eas(ip, bc, block, 1,
 				  _("Bad Extended Attribute duplicate found"));
 		} else {
@@ -437,7 +418,7 @@ static int check_leaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
 		brelse(leaf_bh);
 		return 1;
 	}
-	if(q.block_type != gfs2_block_free) { /* Duplicate? */
+	if(q != gfs2_block_free) { /* Duplicate? */
 		log_debug( _("Duplicate block found at #%lld (0x%llx).\n"),
 			   (unsigned long long)block,
 			   (unsigned long long)block);
@@ -581,14 +562,8 @@ static int check_eattr_entries(struct gfs2_inode *ip,
 static int clear_metalist(struct gfs2_inode *ip, uint64_t block,
 		   struct gfs2_buffer_head **bh, void *private)
 {
-	struct gfs2_block_query q = {0};
-
 	*bh = NULL;
 
-	if(gfs2_block_check(ip->i_sbd, bl, block, &q)) {
-		stack;
-		return -1;
-	}
 	if(!is_duplicate(block)) {
 		gfs2_blockmap_set(ip->i_sbd, bl, block, gfs2_block_free);
 		return 0;
@@ -598,12 +573,6 @@ static int clear_metalist(struct gfs2_inode *ip, uint64_t block,
 
 static int clear_data(struct gfs2_inode *ip, uint64_t block, void *private)
 {
-	struct gfs2_block_query q = {0};
-
-	if(gfs2_block_check(ip->i_sbd, bl, block, &q)) {
-		stack;
-		return -1;
-	}
 	if(!is_duplicate(block)) {
 		gfs2_blockmap_set(ip->i_sbd, bl, block, gfs2_block_free);
 		return 0;
@@ -615,15 +584,9 @@ static int clear_data(struct gfs2_inode *ip, uint64_t block, void *private)
 static int clear_leaf(struct gfs2_inode *ip, uint64_t block,
 	       struct gfs2_buffer_head *bh, void *private)
 {
-	struct gfs2_block_query q = {0};
-
 	log_crit( _("Clearing leaf #%" PRIu64 " (0x%" PRIx64 ")\n"),
 		  block, block);
 
-	if(gfs2_block_check(ip->i_sbd, bl, block, &q)) {
-		stack;
-		return -1;
-	}
 	if(!is_duplicate(block)) {
 		log_crit( _("Setting leaf #%" PRIu64 " (0x%" PRIx64 ") invalid\n"),
 				 block, block);
@@ -669,7 +632,7 @@ int add_to_dir_list(struct gfs2_sbd *sbp, uint64_t block)
 static int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
 			  uint64_t block)
 {
-	struct gfs2_block_query q = {0};
+	uint8_t q;
 	struct gfs2_inode *ip;
 	int error;
 	struct block_count bc = {0};
@@ -697,12 +660,8 @@ static int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
 				 " (0x%" PRIx64 ") not fixed\n"), block, block);
 	}
 
-	if(gfs2_block_check(sdp, bl, block, &q)) {
-		stack;
-		fsck_inode_put(&ip);
-		return -1;
-	}
-	if(q.block_type != gfs2_block_free) {
+	q = block_type(block);
+	if(q != gfs2_block_free) {
 		log_err( _("Found duplicate block referenced as an inode at "
 			   "#%" PRIu64 " (0x%" PRIx64 ")\n"), block, block);
 		gfs2_dup_set(block);
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index 5c6abb7..43158ef 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -509,7 +509,7 @@ int pass1b(struct gfs2_sbd *sbp)
 {
 	struct dup_blks *b;
 	uint64_t i;
-	struct gfs2_block_query q;
+	uint8_t q;
 	osi_list_t *tmp = NULL, *x;
 	struct metawalk_fxns find_dirents = {0};
 	int rc = FSCK_OK;
@@ -534,18 +534,14 @@ int pass1b(struct gfs2_sbd *sbp)
 			goto out;
 		log_debug( _("Scanning block %" PRIu64 " (0x%" PRIx64 ") for inodes\n"),
 				  i, i);
-		if(gfs2_block_check(sbp, bl, i, &q)) {
-			stack;
-			rc = FSCK_ERROR;
-			goto out;
-		}
-		if((q.block_type == gfs2_inode_dir) ||
-		   (q.block_type == gfs2_inode_file) ||
-		   (q.block_type == gfs2_inode_lnk) ||
-		   (q.block_type == gfs2_inode_blk) ||
-		   (q.block_type == gfs2_inode_chr) ||
-		   (q.block_type == gfs2_inode_fifo) ||
-		   (q.block_type == gfs2_inode_sock)) {
+		q = block_type(i);
+		if((q == gfs2_inode_dir) ||
+		   (q == gfs2_inode_file) ||
+		   (q == gfs2_inode_lnk) ||
+		   (q == gfs2_inode_blk) ||
+		   (q == gfs2_inode_chr) ||
+		   (q == gfs2_inode_fifo) ||
+		   (q == gfs2_inode_sock)) {
 			osi_list_foreach_safe(tmp, &dup_blocks.list, x) {
 				b = osi_list_entry(tmp, struct dup_blks,
 						   list);
@@ -556,7 +552,7 @@ int pass1b(struct gfs2_sbd *sbp)
 				}
 			}
 		}
-		if(q.block_type == gfs2_inode_dir) {
+		if(q == gfs2_inode_dir) {
 			check_dir(sbp, i, &find_dirents);
 		}
 	}
diff --git a/gfs2/fsck/pass1c.c b/gfs2/fsck/pass1c.c
index 514afac..06020f0 100644
--- a/gfs2/fsck/pass1c.c
+++ b/gfs2/fsck/pass1c.c
@@ -85,7 +85,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
 		      void *private)
 {
 	struct gfs2_sbd *sbp = ip->i_sbd;
-	struct gfs2_block_query q;
+	uint8_t q;
 	struct gfs2_buffer_head *indir_bh = NULL;
 
 	if(gfs2_check_range(sbp, block)) {
@@ -98,11 +98,8 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
 			(unsigned long long)ip->i_di.di_num.no_addr);
 		return ask_remove_eattr(ip);
 	}
-	else if (gfs2_block_check(sbp, bl, block, &q)) {
-		stack;
-		return -1;
-	}
-	else if(q.block_type != gfs2_indir_blk) {
+	q = block_type(block);
+	if(q != gfs2_indir_blk) {
 		log_err( _("Extended attributes indirect block #%llu"
 			" (0x%llx) for inode #%llu"
 			" (0x%llx) invalid.\n"),
@@ -124,7 +121,7 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
 		     void *private)
 {
 	struct gfs2_sbd *sbp = ip->i_sbd;
-	struct gfs2_block_query q;
+	uint8_t q;
 
 	if(gfs2_check_range(sbp, block)) {
 		log_err( _("Extended attributes block for inode #%llu"
@@ -133,11 +130,8 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
 			(unsigned long long)ip->i_di.di_num.no_addr);
 		return ask_remove_eattr(ip);
 	}
-	else if (gfs2_block_check(sbp, bl, block, &q)) {
-		stack;
-		return -1;
-	}
-	else if(q.block_type != gfs2_meta_eattr) {
+	q = block_type(block);
+	if(q != gfs2_meta_eattr) {
 		log_err( _("Extended attributes block for inode #%llu"
 			   " (0x%llx) invalid.\n"),
 			 (unsigned long long)ip->i_di.di_num.no_addr,
@@ -222,14 +216,12 @@ static int check_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_ptr,
 			 struct gfs2_ea_header *ea_hdr,
 			 struct gfs2_ea_header *ea_hdr_prev, void *private)
 {
-	struct gfs2_block_query q;
+	uint8_t q;
 	struct gfs2_sbd *sbp = ip->i_sbd;
 
-	if(gfs2_block_check(sbp, bl, be64_to_cpu(*ea_ptr), &q)) {
-		stack;
-		return -1;
-	}
-	if(q.block_type != gfs2_meta_eattr) {
+
+	q = block_type(be64_to_cpu(*ea_ptr));
+	if(q != gfs2_meta_eattr) {
 		if(remove_eattr_entry(sbp, leaf_bh, ea_hdr, ea_hdr_prev)){
 			stack;
 			return -1;
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 2cfe12d..2d748e1 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -114,9 +114,9 @@ static const char *de_type_string(uint8_t de_type)
 	return de_types[3]; /* invalid */
 }
 
-static int check_file_type(uint8_t de_type, uint8_t block_type)
+static int check_file_type(uint8_t de_type, uint8_t blk_type)
 {
-	switch(block_type) {
+	switch(blk_type) {
 	case gfs2_inode_dir:
 		if(de_type != DT_DIR)
 			return 1;
@@ -169,7 +169,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 		 uint16_t *count, void *priv)
 {
 	struct gfs2_sbd *sbp = ip->i_sbd;
-	struct gfs2_block_query q = {0};
+	uint8_t q;
 	char tmp_name[MAX_FILENAME];
 	uint64_t entryblock;
 	struct dir_status *ds = (struct dir_status *) priv;
@@ -247,12 +247,9 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 			return 0;
 		}
 	}
-	if(gfs2_block_check(sbp, bl, de->de_inum.no_addr, &q)) {
-		stack;
-		return -1;
-	}
+	q = block_type(de->de_inum.no_addr);
 	/* Get the status of the directory inode */
-	if(q.block_type == gfs2_bad_block) {
+	if(q == gfs2_bad_block) {
 		/* This entry's inode has bad blocks in it */
 
 		/* Handle bad blocks */
@@ -279,10 +276,10 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 		}
 
 	}
-	if(q.block_type != gfs2_inode_dir && q.block_type != gfs2_inode_file &&
-	   q.block_type != gfs2_inode_lnk && q.block_type != gfs2_inode_blk &&
-	   q.block_type != gfs2_inode_chr && q.block_type != gfs2_inode_fifo &&
-	   q.block_type != gfs2_inode_sock) {
+	if(q != gfs2_inode_dir && q != gfs2_inode_file &&
+	   q != gfs2_inode_lnk && q != gfs2_inode_blk &&
+	   q != gfs2_inode_chr && q != gfs2_inode_fifo &&
+	   q != gfs2_inode_sock) {
 		log_err( _("Directory entry '%s' at block %llu (0x%llx"
 			   ") in dir inode %llu (0x%llx"
 			   ") block type %d: %s.\n"), tmp_name,
@@ -290,7 +287,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 			 (unsigned long long)de->de_inum.no_addr,
 			 (unsigned long long)ip->i_di.di_num.no_addr,
 			 (unsigned long long)ip->i_di.di_num.no_addr,
-			 q.block_type, q.block_type == gfs2_meta_inval ?
+			 q, q == gfs2_meta_inval ?
 			 _("previously marked invalid") :
 			 _("is not an inode"));
 
@@ -304,7 +301,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 			/* If it was previously marked invalid (i.e. known
 			   to be bad, not just a free block, etc.) then
 			   delete any metadata it holds.  If not, return. */
-			if (q.block_type != gfs2_meta_inval)
+			if (q != gfs2_meta_inval)
 				return 1;
 
 			/* Now try to clear the dinode, if it is an dinode */
@@ -332,7 +329,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 		}
 	}
 
-	error = check_file_type(de->de_type, q.block_type);
+	error = check_file_type(de->de_type, q);
 	if(error < 0) {
 		stack;
 		return -1;
@@ -343,7 +340,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 			 de_type_string(de->de_type), tmp_name,
 			 (unsigned long long)de->de_inum.no_addr,
 			 (unsigned long long)de->de_inum.no_addr,
-			 block_type_string(&q));
+			 block_type_string(q));
 		if(query( _("Clear stale directory entry? (y/n) "))) {
 			entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
 			check_inode_eattr(entry_ip, &clear_eattrs);
@@ -459,7 +456,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 			}
 		}
 
-		if(q.block_type != gfs2_inode_dir) {
+		if(q != gfs2_inode_dir) {
 			log_err( _("Found '..' entry in directory %llu (0x%llx) "
 				"pointing to something that's not a directory"),
 				(unsigned long long)ip->i_di.di_num.no_addr,
@@ -500,7 +497,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 
 	/* After this point we're only concerned with
 	 * directories */
-	if(q.block_type != gfs2_inode_dir) {
+	if(q != gfs2_inode_dir) {
 		log_debug( _("Found non-dir inode dentry\n"));
 		increment_link(sbp, de->de_inum.no_addr);
 		(*count)++;
@@ -566,12 +563,10 @@ int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
 
 	if (sysinode) {
 		iblock = sysinode->i_di.di_num.no_addr;
-		if(gfs2_block_check(sysinode->i_sbd, bl, iblock, &ds.q)) {
-			iblock = sysinode->i_di.di_num.no_addr;
-		}
+		ds.q = block_type(iblock);
 	}
 	pass2_fxns.private = (void *) &ds;
-	if(ds.q.block_type == gfs2_bad_block) {
+	if(ds.q == gfs2_bad_block) {
 		/* First check that the directory's metatree is valid */
 		if(check_metatree(sysinode, &pass2_fxns)) {
 			stack;
@@ -669,7 +664,7 @@ static inline int is_system_dir(struct gfs2_sbd *sbp, uint64_t block)
 int pass2(struct gfs2_sbd *sbp)
 {
 	uint64_t i;
-	struct gfs2_block_query q;
+	uint8_t q;
 	struct dir_status ds = {0};
 	struct gfs2_inode *ip;
 	char *filename;
@@ -706,13 +701,9 @@ int pass2(struct gfs2_sbd *sbp)
 		if (is_system_dir(sbp, i))
 			continue;
 
-		if(gfs2_block_check(sbp, bl, i, &q)) {
-			log_err( _("Can't get block %"PRIu64 " (0x%" PRIx64
-					") from block list\n"), i, i);
-			return FSCK_ERROR;
-		}
+		q = block_type(i);
 
-		if(q.block_type != gfs2_inode_dir)
+		if(q != gfs2_inode_dir)
 			continue;
 
 		log_debug( _("Checking directory inode at block %"PRIu64" (0x%"
@@ -720,7 +711,7 @@ int pass2(struct gfs2_sbd *sbp)
 
 		memset(&ds, 0, sizeof(ds));
 		pass2_fxns.private = (void *) &ds;
-		if(ds.q.block_type == gfs2_bad_block) {
+		if(ds.q == gfs2_bad_block) {
 			/* First check that the directory's metatree
 			 * is valid */
 			ip = fsck_load_inode(sbp, i);
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index 3182db1..7d4fe41 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -25,6 +25,7 @@
 #include "lost_n_found.h"
 #include "link.h"
 #include "metawalk.h"
+#include "util.h"
 
 static int attach_dotdot_to(struct gfs2_sbd *sbp, uint64_t newdotdot,
 			    uint64_t olddotdot, uint64_t block)
@@ -74,7 +75,7 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
 										struct dir_info *di)
 {
 	struct dir_info *pdi;
-	struct gfs2_block_query q_dotdot, q_treewalk;
+	uint8_t q_dotdot, q_treewalk;
 
 	di->checked = 1;
 
@@ -88,19 +89,8 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
 				   PRIu64" (0x%" PRIx64 ")\n"), di->dotdot_parent,
 				   di->dotdot_parent, di->treewalk_parent,
 				   di->treewalk_parent);
-		if(gfs2_block_check(sbp, bl, di->dotdot_parent, &q_dotdot)) {
-			log_err( _("Unable to find block %"PRIu64
-					" (0x%" PRIx64 ") in block map.\n"),
-					di->dotdot_parent, di->dotdot_parent);
-			return NULL;
-		}
-		if(gfs2_block_check(sbp, bl, di->treewalk_parent,
-				    &q_treewalk)) {
-			log_err( _("Unable to find block %"PRIu64
-					" (0x%" PRIx64 ") in block map\n"),
-					di->treewalk_parent, di->treewalk_parent);
-			return NULL;
-		}
+		q_dotdot = block_type(di->dotdot_parent);
+		q_treewalk = block_type(di->treewalk_parent);
 		/* if the dotdot entry isn't a directory, but the
 		 * treewalk is, treewalk is correct - if the treewalk
 		 * entry isn't a directory, but the dotdot is, dotdot
@@ -108,8 +98,8 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
 		 * choose? if neither are directories, we have a
 		 * problem - need to move this directory into lost+found
 		 */
-		if(q_dotdot.block_type != gfs2_inode_dir) {
-			if(q_treewalk.block_type != gfs2_inode_dir) {
+		if(q_dotdot != gfs2_inode_dir) {
+			if(q_treewalk != gfs2_inode_dir) {
 				log_err( _("Orphaned directory, move to lost+found\n"));
 				return NULL;
 			}
@@ -123,7 +113,7 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
 			}
 		}
 		else {
-			if(q_treewalk.block_type != gfs2_inode_dir) {
+			if(q_treewalk != gfs2_inode_dir) {
 				int error = 0;
 				log_warn( _(".. parent is valid, but treewalk"
 						 "is bad - reattaching to lost+found"));
@@ -165,13 +155,8 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
 		}
 	}
 	else {
-		if(gfs2_block_check(sbp, bl, di->dotdot_parent, &q_dotdot)) {
-			log_err( _("Unable to find parent block %"PRIu64
-					" (0x%" PRIx64 ")  in block map\n"),
-					di->dotdot_parent, di->dotdot_parent);
-			return NULL;
-		}
-		if(q_dotdot.block_type != gfs2_inode_dir) {
+		q_dotdot = block_type(di->dotdot_parent);
+		if(q_dotdot != gfs2_inode_dir) {
 			log_err( _("Orphaned directory at block %" PRIu64 " (0x%" PRIx64
 					") moved to lost+found\n"), di->dinode, di->dinode);
 			return NULL;
@@ -193,7 +178,7 @@ int pass3(struct gfs2_sbd *sbp)
 	osi_list_t *tmp;
 	struct dir_info *di, *tdi;
 	struct gfs2_inode *ip;
-	struct gfs2_block_query q;
+	uint8_t q;
 	int i;
 
 	find_di(sbp, sbp->md.rooti->i_di.di_num.no_addr, &di);
@@ -225,11 +210,8 @@ int pass3(struct gfs2_sbd *sbp)
 
 			/* FIXME: Factor this ? */
 			if(!tdi) {
-				if(gfs2_block_check(sbp, bl, di->dinode, &q)) {
-					stack;
-					return FSCK_ERROR;
-				}
-				if(q.block_type == gfs2_bad_block) {
+				q = block_type(di->dinode);
+				if(q == gfs2_bad_block) {
 					log_err( _("Found unlinked directory containing bad block\n"));
 					if(query(
 					   _("Clear unlinked directory with bad blocks? (y/n) "))) {
@@ -240,13 +222,13 @@ int pass3(struct gfs2_sbd *sbp)
 					} else
 						log_err( _("Unlinked directory with bad block remains\n"));
 				}
-				if(q.block_type != gfs2_inode_dir &&
-				   q.block_type != gfs2_inode_file &&
-				   q.block_type != gfs2_inode_lnk &&
-				   q.block_type != gfs2_inode_blk &&
-				   q.block_type != gfs2_inode_chr &&
-				   q.block_type != gfs2_inode_fifo &&
-				   q.block_type != gfs2_inode_sock) {
+				if(q != gfs2_inode_dir &&
+				   q != gfs2_inode_file &&
+				   q != gfs2_inode_lnk &&
+				   q != gfs2_inode_blk &&
+				   q != gfs2_inode_chr &&
+				   q != gfs2_inode_fifo &&
+				   q != gfs2_inode_sock) {
 					log_err( _("Unlinked block marked as inode not an inode\n"));
 					gfs2_blockmap_set(sbp, bl, di->dinode,
 						       gfs2_block_free);
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index 0c8f969..8a1f2e3 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -22,6 +22,7 @@
 #include "lost_n_found.h"
 #include "inode_hash.h"
 #include "metawalk.h"
+#include "util.h"
 
 struct metawalk_fxns pass4_fxns_delete = {
 	.private = NULL,
@@ -56,7 +57,7 @@ static int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
 	struct inode_info *ii;
 	struct gfs2_inode *ip;
 	int lf_addition = 0;
-	struct gfs2_block_query q;
+	uint8_t q;
 
 	/* FIXME: should probably factor this out into a generic
 	 * scanning fxn */
@@ -72,11 +73,8 @@ static int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
 		if(ii->counted_links == 0) {
 			log_err( _("Found unlinked inode at %" PRIu64 " (0x%" PRIx64 ")\n"),
 					ii->inode, ii->inode);
-			if(gfs2_block_check(sbp, bl, ii->inode, &q)) {
-				stack;
-				return -1;
-			}
-			if(q.block_type == gfs2_bad_block) {
+			q = block_type(ii->inode);
+			if(q == gfs2_bad_block) {
 				log_err( _("Unlinked inode %llu (0x%llx) contains"
 					"bad blocks\n"),
 					(unsigned long long)ii->inode,
@@ -95,16 +93,15 @@ static int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
 				} else
 					log_err( _("Unlinked inode with bad blocks not cleared\n"));
 			}
-			if(q.block_type != gfs2_inode_dir &&
-			   q.block_type != gfs2_inode_file &&
-			   q.block_type != gfs2_inode_lnk &&
-			   q.block_type != gfs2_inode_blk &&
-			   q.block_type != gfs2_inode_chr &&
-			   q.block_type != gfs2_inode_fifo &&
-			   q.block_type != gfs2_inode_sock) {
+			if(q != gfs2_inode_dir &&
+			   q != gfs2_inode_file &&
+			   q != gfs2_inode_lnk &&
+			   q != gfs2_inode_blk &&
+			   q != gfs2_inode_chr &&
+			   q != gfs2_inode_fifo &&
+			   q != gfs2_inode_sock) {
 				log_err( _("Unlinked block marked as inode is "
-					   "not an inode (%d)\n"),
-					 q.block_type);
+					   "not an inode (%d)\n"), q);
 				ip = fsck_load_inode(sbp, ii->inode);
 				if(query(_("Delete unlinked inode? (y/n) "))) {
 					check_inode_eattr(ip,
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index efad774..c6b005a 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -23,9 +23,9 @@
 #include "fs_bits.h"
 #include "util.h"
 
-static int convert_mark(struct gfs2_block_query *q, uint32_t *count)
+static int convert_mark(uint8_t q, uint32_t *count)
 {
-	switch(q->block_type) {
+	switch(q) {
 
 	case gfs2_meta_inval:
 		/* Convert invalid metadata to free blocks */
@@ -56,7 +56,7 @@ static int convert_mark(struct gfs2_block_query *q, uint32_t *count)
 		return GFS2_BLKST_USED;
 
 	default:
-		log_err( _("Invalid state %d found\n"), q->block_type);
+		log_err( _("Invalid state %d found\n"), q);
 		return -1;
 	}
 	return -1;
@@ -68,7 +68,7 @@ static int check_block_status(struct gfs2_sbd *sbp, char *buffer, unsigned int b
 	unsigned char *byte, *end;
 	unsigned int bit;
 	unsigned char rg_status, block_status;
-	struct gfs2_block_query q;
+	uint8_t q;
 	uint64_t block;
 	static int free_unlinked = -1;
 
@@ -83,9 +83,9 @@ static int check_block_status(struct gfs2_sbd *sbp, char *buffer, unsigned int b
 		warm_fuzzy_stuff(block);
 		if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
 			return 0;
-		gfs2_block_check(sbp, bl, block, &q);
+		q = block_type(block);
 
-		block_status = convert_mark(&q, count);
+		block_status = convert_mark(q, count);
 
 		/* If one node opens a file and another node deletes it, we
 		   may be left with a block that appears to be "unlinked" in
@@ -132,8 +132,8 @@ static int check_block_status(struct gfs2_sbd *sbp, char *buffer, unsigned int b
 			log_err( _("Ondisk status is %u (%s) but FSCK thinks it should be "),
 					rg_status, blockstatus[rg_status]);
 			log_err("%u (%s)\n", block_status, blockstatus[block_status]);
-			log_err( _("Metadata type is %u (%s)\n"), q.block_type,
-					block_type_string(&q));
+			log_err( _("Metadata type is %u (%s)\n"), q,
+					block_type_string(q));
 
 			if(query( _("Fix bitmap for block %" PRIu64
 				    " (0x%" PRIx64 ") ? (y/n) "),
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 48de4bd..d0dd4af 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -125,15 +125,15 @@ void warm_fuzzy_stuff(uint64_t block)
 	}
 }
 
-const char *block_type_string(struct gfs2_block_query *q)
+const char *block_type_string(uint8_t q)
 {
 	const char *blktyp[] = {"free", "used", "indirect data", "inode",
 							"file", "symlink", "block dev", "char dev",
 							"fifo", "socket", "dir leaf", "journ data",
 							"other meta", "eattribute", "unused",
 							"invalid"};
-	if (q->block_type < 16)
-		return (blktyp[q->block_type]);
+	if (q < 16)
+		return (blktyp[q]);
 	return blktyp[15];
 }
 
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index 3f9e921..3a0d959 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -14,6 +14,7 @@
 #ifndef __UTIL_H__
 #define __UTIL_H__
 
+#include "fsck.h"
 #include "libgfs2.h"
 
 #define fsck_lseek(fd, off) \
@@ -23,7 +24,19 @@ int compute_height(struct gfs2_sbd *sdp, uint64_t sz);
 struct di_info *search_list(osi_list_t *list, uint64_t addr);
 void big_file_comfort(struct gfs2_inode *ip, uint64_t blks_checked);
 void warm_fuzzy_stuff(uint64_t block);
-const char *block_type_string(struct gfs2_block_query *q);
+const char *block_type_string(uint8_t q);
 void gfs2_dup_set(uint64_t block);
 
+static inline uint8_t block_type(uint64_t bblock)
+{
+	static unsigned char *byte;
+	static uint64_t b;
+	static uint8_t btype;
+
+	byte = bl->map + BLOCKMAP_SIZE4(bblock);
+	b = BLOCKMAP_BYTE_OFFSET4(bblock);
+	btype = (*byte & (BLOCKMAP_MASK4 << b )) >> b;
+	return btype;
+}
+
 #endif /* __UTIL_H__ */
diff --git a/gfs2/libgfs2/block_list.c b/gfs2/libgfs2/block_list.c
index e9287d1..b57f58d 100644
--- a/gfs2/libgfs2/block_list.c
+++ b/gfs2/libgfs2/block_list.c
@@ -149,21 +149,6 @@ int gfs2_blockmap_set(struct gfs2_sbd *sdp, struct gfs2_bmap *bmap,
 	return 0;
 }
 
-int gfs2_block_check(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
-		     uint64_t block, struct gfs2_block_query *val)
-{
-	static unsigned char *byte;
-	static uint64_t b;
-
-	if(block >= il->size)
-		return -1;
-
-	byte = il->map + BLOCKMAP_SIZE4(block);
-	b = BLOCKMAP_BYTE_OFFSET4(block);
-	val->block_type = (*byte & (BLOCKMAP_MASK4 << b )) >> b;
-	return 0;
-}
-
 void *gfs2_bmap_destroy(struct gfs2_sbd *sdp, struct gfs2_bmap *il)
 {
 	if(il) {
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 5ac92d1..e243d3f 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -300,10 +300,6 @@ enum gfs2_mark_block {
 	gfs2_meta_inval = INVALID_META,
 };
 
-struct gfs2_block_query {
-        uint8_t block_type;
-};
-
 extern struct gfs2_bmap *gfs2_bmap_create(struct gfs2_sbd *sdp, uint64_t size,
 					  uint64_t *addl_mem_needed);
 extern struct special_blocks *blockfind(struct special_blocks *blist, uint64_t num);
@@ -319,8 +315,6 @@ extern int gfs2_block_unmark(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
 /* gfs2_block_clear clears all the marks for the given block */
 extern int gfs2_blockmap_clear(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
 			    uint64_t block);
-extern int gfs2_block_check(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
-			    uint64_t block, struct gfs2_block_query *val);
 extern void *gfs2_bmap_destroy(struct gfs2_sbd *sdp, struct gfs2_bmap *il);
 
 /* buf.c */