cluster: STABLE3 - gfs2: libgfs2 and fsck.gfs2 cleanups

Bob Peterson rpeterso at fedoraproject.org
Tue Jan 26 21:19:37 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=324588669d02c9a1e1d2fe3ba3b8edf11863721b
Commit:        324588669d02c9a1e1d2fe3ba3b8edf11863721b
Parent:        48cd85089a1a12d4c36fca20b9b3fed362b8f4b7
Author:        Bob Peterson <bob at ganesha.peterson>
AuthorDate:    Wed Jan 20 15:46:50 2010 -0600
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Tue Jan 26 14:39:28 2010 -0600

gfs2: libgfs2 and fsck.gfs2 cleanups

This patch is big, but mostly cosmetic.  There are a few places
where I found and fixed a bug with the previous patches.  However,
by and large, this patch is comprised of (1) comment changes,
(2) code reformatting for readability, (3) variable renames to
aid in readability, (4) code restructuring for efficiency, as in
the case where I got rid of useless function scan_meta and just
inlined it, (5) improved error messages given to aid in debugging.

rhbz#455300
---
 gfs2/convert/gfs2_convert.c |    5 +-
 gfs2/edit/gfs2hex.c         |    3 +-
 gfs2/edit/hexedit.c         |    2 +-
 gfs2/edit/savemeta.c        |   11 ++--
 gfs2/fsck/eattr.c           |    8 +--
 gfs2/fsck/fsck.h            |   28 ++++----
 gfs2/fsck/lost_n_found.c    |   53 ++++-----------
 gfs2/fsck/metawalk.c        |   48 +++++++-------
 gfs2/fsck/metawalk.h        |   50 ++++++++------
 gfs2/fsck/pass1.c           |   97 ++++++++++++---------------
 gfs2/fsck/pass1b.c          |   33 +++++----
 gfs2/fsck/pass1c.c          |    1 -
 gfs2/fsck/pass2.c           |  157 +++++++++++++++++++++++--------------------
 gfs2/fsck/pass3.c           |   13 ++--
 gfs2/fsck/pass4.c           |   21 +++---
 gfs2/fsck/pass5.c           |    8 +-
 gfs2/fsck/rgrepair.c        |   10 ++--
 gfs2/fsck/util.c            |    4 +-
 gfs2/libgfs2/block_list.c   |    1 -
 gfs2/libgfs2/buf.c          |    4 +-
 gfs2/libgfs2/fs_ops.c       |   71 +++++++++-----------
 gfs2/libgfs2/gfs2_log.c     |    6 +--
 gfs2/libgfs2/libgfs2.h      |    5 +-
 gfs2/libgfs2/super.c        |    2 +-
 24 files changed, 307 insertions(+), 334 deletions(-)

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 2e10496..5d8d9cd 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -331,8 +331,7 @@ static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
 		if (amount > sbp->bsize - hdrsize - ptramt)
 			amount = sbp->bsize - hdrsize - ptramt;
 
-		memcpy(bh->b_data + hdrsize + ptramt,
-		       (char *)srcptr, amount);
+		memcpy(bh->b_data + hdrsize + ptramt, (char *)srcptr, amount);
 		srcptr += amount;
 		bmodified(bh);
 		if (bh != ip->i_bh)
@@ -784,7 +783,7 @@ static int fetch_inum(struct gfs2_sbd *sbp, uint64_t iblock,
 /* Returns: 0 on success, -1 on failure                                      */
 /* ------------------------------------------------------------------------- */
 static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
-						struct gfs2_buffer_head *bh, int dir_entries)
+			       struct gfs2_buffer_head *bh, int dir_entries)
 {
 	int error;
 	struct gfs2_dirent *dent;
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index cbf8dc0..00c4481 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -470,7 +470,8 @@ static void do_eattr_extended(struct gfs2_buffer_head *ebh)
 	print_gfs2("Eattr Entries:");
 	eol(0);
 
-	for (x = sizeof(struct gfs2_meta_header); x < sbd.bsize; x += ea.ea_rec_len)
+	for (x = sizeof(struct gfs2_meta_header); x < sbd.bsize;
+	     x += ea.ea_rec_len)
 	{
 		eol(0);
 		gfs2_ea_header_in(&ea, ebh->b_data + x);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 0017a60..45dfcc4 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -3042,7 +3042,7 @@ static void dump_journal(const char *journal)
 			abs_block = jblock + jb;
 			dummy_bh.b_data = j_bh->b_data;
 		} else {
-			error = fsck_readi(j_inode, (void *)&jbuf, jb,
+			error = fsck_readi(j_inode, (void *)jbuf, jb,
 					   sbd.bsize, &abs_block);
 			if (!error) /* end of file */
 				break;
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 4b49050..a69816f 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -852,17 +852,16 @@ static int restore_data(int fd, int in_fd, int printblocksonly)
 				fprintf(stderr, "bad seek: %s from %s:"
 					"%d: block %lld (0x%llx)\n",
 					strerror(errno), __FUNCTION__,
-					__LINE__, (unsigned long long)
-					savedata->blk,
-					(unsigned long long)
-					savedata->blk);
+					__LINE__,
+					(unsigned long long)savedata->blk,
+					(unsigned long long)savedata->blk);
 				exit(-1);
 			}
 			if (write(fd, savedata->buf, sbd.bsize) != sbd.bsize) {
 				fprintf(stderr, "write error: %s from "
 					"%s:%d: block %lld (0x%llx)\n",
-					strerror(errno),
-					__FUNCTION__, __LINE__,
+					strerror(errno), __FUNCTION__,
+					__LINE__,
 					(unsigned long long)savedata->blk,
 					(unsigned long long)savedata->blk);
 				exit(-1);
diff --git a/gfs2/fsck/eattr.c b/gfs2/fsck/eattr.c
index a319500..6be4fa3 100644
--- a/gfs2/fsck/eattr.c
+++ b/gfs2/fsck/eattr.c
@@ -42,17 +42,12 @@ int clear_eattr_entry (struct gfs2_inode *ip,
 		       void *private)
 {
 	struct gfs2_sbd *sdp = ip->i_sbd;
-	char ea_name[256];
 
 	if(!ea_hdr->ea_name_len){
 		/* Skip this entry for now */
 		return 1;
 	}
 
-	memset(ea_name, 0, sizeof(ea_name));
-	strncpy(ea_name, (char *)ea_hdr + sizeof(struct gfs2_ea_header),
-		ea_hdr->ea_name_len);
-
 	if(!GFS2_EATYPE_VALID(ea_hdr->ea_type) &&
 	   ((ea_hdr_prev) || (!ea_hdr_prev && ea_hdr->ea_type))){
 		/* Skip invalid entry */
@@ -71,8 +66,7 @@ int clear_eattr_entry (struct gfs2_inode *ip,
 		} else {
 			log_debug( _("  Pointers Required: %d\n"
 				  "  Pointers Reported: %d\n"),
-				  max_ptrs,
-				  ea_hdr->ea_num_ptrs);
+				  max_ptrs, ea_hdr->ea_num_ptrs);
 		}
 
 
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index a15bc33..7107678 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -61,7 +61,7 @@ enum rgindex_trust_level { /* how far can we trust our RG index? */
 
 struct dup_blks {
 	osi_list_t list;
-	uint64_t block_no;
+	uint64_t block;
 	osi_list_t ref_inode_list;
 };
 
@@ -70,19 +70,21 @@ extern struct gfs2_inode *fsck_inode_get(struct gfs2_sbd *sdp,
 				  struct gfs2_buffer_head *bh);
 extern void fsck_inode_put(struct gfs2_inode **ip);
 
-int initialize(struct gfs2_sbd *sbp, int force_check, int preen,
-	       int *all_clean);
-void destroy(struct gfs2_sbd *sbp);
-int pass1(struct gfs2_sbd *sbp);
-int pass1b(struct gfs2_sbd *sbp);
-int pass1c(struct gfs2_sbd *sbp);
-int pass2(struct gfs2_sbd *sbp);
-int pass3(struct gfs2_sbd *sbp);
-int pass4(struct gfs2_sbd *sbp);
-int pass5(struct gfs2_sbd *sbp);
-int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count);
-int fsck_query(const char *format, ...)
+extern int initialize(struct gfs2_sbd *sbp, int force_check, int preen,
+		      int *all_clean);
+extern void destroy(struct gfs2_sbd *sbp);
+extern int pass1(struct gfs2_sbd *sbp);
+extern int pass1b(struct gfs2_sbd *sbp);
+extern int pass1c(struct gfs2_sbd *sbp);
+extern int pass2(struct gfs2_sbd *sbp);
+extern int pass3(struct gfs2_sbd *sbp);
+extern int pass4(struct gfs2_sbd *sbp);
+extern int pass5(struct gfs2_sbd *sbp);
+extern int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count);
+extern int fsck_query(const char *format, ...)
 	__attribute__((format(printf,1,2)));
+extern struct dir_info *dirtree_find(uint64_t block);
+extern void dirtree_delete(struct dir_info *b);
 
 /* FIXME: Hack to get this going for pass2 - this should be pulled out
  * of pass1 and put somewhere else... */
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index bc07d7b..25dec6c 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -25,8 +25,6 @@
  */
 int add_inode_to_lf(struct gfs2_inode *ip){
 	char tmp_name[256];
-	char *filename;
-	int filename_len;
 	__be32 inode_type;
 
 	if(!lf_dip) {
@@ -34,7 +32,8 @@ int add_inode_to_lf(struct gfs2_inode *ip){
 
 		log_info( _("Locating/Creating lost and found directory\n"));
 
-        lf_dip = createi(ip->i_sbd->md.rooti, "lost+found", S_IFDIR | 0700, 0);
+		lf_dip = createi(ip->i_sbd->md.rooti, "lost+found",
+				 S_IFDIR | 0700, 0);
 		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
@@ -59,28 +58,16 @@ int add_inode_to_lf(struct gfs2_inode *ip){
 	}
 	switch(ip->i_di.di_mode & S_IFMT){
 	case S_IFDIR:
-		log_info( _("Adding .. entry pointing to lost+found for %llu\n"),
-				 (unsigned long long)ip->i_di.di_num.no_addr);
-		sprintf(tmp_name, "..");
-		filename_len = strlen(tmp_name);  /* no trailing NULL */
-		if(!(filename = malloc((sizeof(char) * filename_len) + 1))) {
-			log_err( _("Unable to allocate name\n"));
-			stack;
-			return -1;
-		}
-		if(!memset(filename, 0, (sizeof(char) * filename_len) + 1)) {
-			log_err( _("Unable to zero name\n"));
-			stack;
-			return -1;
-		}
-		memcpy(filename, tmp_name, filename_len);
+		log_info( _("Adding .. entry pointing to lost+found for "
+			    "directory %llu (0x%llx)\n"),
+			  (unsigned long long)ip->i_di.di_num.no_addr,
+			  (unsigned long long)ip->i_di.di_num.no_addr);
 
-		if(gfs2_dirent_del(ip, filename, filename_len))
-			log_warn( _("add_inode_to_lf:  "
-					 "Unable to remove \"..\" directory entry.\n"));
+		if(gfs2_dirent_del(ip, "..", 2))
+			log_warn( _("add_inode_to_lf: Unable to remove "
+				    "\"..\" directory entry.\n"));
 
-		dir_add(ip, filename, filename_len, &(lf_dip->i_di.di_num), DT_DIR);
-		free(filename);
+		dir_add(ip, "..", 2, &(lf_dip->i_di.di_num), DT_DIR);
 		sprintf(tmp_name, "lost_dir_%llu",
 			(unsigned long long)ip->i_di.di_num.no_addr);
 		inode_type = DT_DIR;
@@ -121,26 +108,14 @@ int add_inode_to_lf(struct gfs2_inode *ip){
 		inode_type = DT_REG;
 		break;
 	}
-	filename_len = strlen(tmp_name);  /* no trailing NULL */
-	if(!(filename = malloc(sizeof(char) * filename_len))) {
-		log_err( _("Unable to allocate name\n"));
-			stack;
-			return -1;
-		}
-	if(!memset(filename, 0, sizeof(char) * filename_len)) {
-		log_err( _("Unable to zero name\n"));
-		stack;
-		return -1;
-	}
-	memcpy(filename, tmp_name, filename_len);
 
-	dir_add(lf_dip, filename, filename_len, &(ip->i_di.di_num), inode_type);
-  	increment_link(ip->i_sbd, ip->i_di.di_num.no_addr);
+	dir_add(lf_dip, tmp_name, strlen(tmp_name), &(ip->i_di.di_num),
+		inode_type);
+	increment_link(ip->i_sbd, ip->i_di.di_num.no_addr);
 	if(S_ISDIR(ip->i_di.di_mode))
 		increment_link(ip->i_sbd, lf_dip->i_di.di_num.no_addr);
 
-	free(filename);
 	log_notice( _("Added inode #%llu to lost+found dir\n"),
-		   (unsigned long long)ip->i_di.di_num.no_addr);
+		    (unsigned long long)ip->i_di.di_num.no_addr);
 	return 0;
 }
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index d348123..6dd46cd 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -24,7 +24,7 @@ struct dup_blks *dupfind(uint64_t num)
 
 	for (tmp = head->next; tmp != head; tmp = tmp->next) {
 		b = osi_list_entry(tmp, struct dup_blks, list);
-		if (b->block_no == num)
+		if (b->block == num)
 			return b;
 	}
 	return NULL;
@@ -281,8 +281,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
 				bmodified(bh);
 				/* Mark dirent buffer as modified */
 				first = 0;
-			}
-			else {
+			} else {
 				error = pass->check_dentry(ip, dent, prev, bh,
 							   filename, count,
 							   pass->private);
@@ -294,7 +293,12 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
 		}
 
 		if ((char *)dent + de.de_rec_len >= bh_end){
-			log_debug( _("Last entry processed.\n"));
+			log_debug( _("Last entry processed for %lld->%lld "
+				     "(0x%llx->0x%llx).\n"),
+				   (unsigned long long)ip->i_di.di_num.no_addr,
+				   (unsigned long long)bh->b_blocknr,
+				   (unsigned long long)ip->i_di.di_num.no_addr,
+				   (unsigned long long)bh->b_blocknr);
 			break;
 		}
 
@@ -387,8 +391,7 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
 								  leaf info */
 			ref_count++;
 			continue;
-		}
-		else if(old_leaf == leaf_no) {
+		} else if(old_leaf == leaf_no) {
 			ref_count++;
 			continue;
 		}
@@ -490,11 +493,11 @@ static int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
 				break;
 			}
 			exp_count = (1 << (ip->i_di.di_depth - leaf.lf_depth));
-			log_debug( _("expected count %u - di_depth %u, leaf depth %u\n"),
-					  exp_count, ip->i_di.di_depth, leaf.lf_depth);
+			/*log_debug( _("expected count %u - di_depth %u,
+			  leaf depth %u\n"),
+			  exp_count, ip->i_di.di_depth, leaf.lf_depth);*/
 
-			if(pass->check_dentry &&
-			   S_ISDIR(ip->i_di.di_mode)) {
+			if(pass->check_dentry && S_ISDIR(ip->i_di.di_mode)) {
 				error = check_entries(ip, lbh, DIR_EXHASH,
 						      &count, pass);
 
@@ -560,9 +563,8 @@ static int check_eattr_entries(struct gfs2_inode *ip,
 	int error = 0;
 	uint32_t offset = (uint32_t)sizeof(struct gfs2_meta_header);
 
-	if(!pass->check_eattr_entry) {
+	if(!pass->check_eattr_entry)
 		return 0;
-	}
 
 	ea_hdr = (struct gfs2_ea_header *)(bh->b_data +
 					  sizeof(struct gfs2_meta_header));
@@ -761,7 +763,7 @@ static int check_indirect_eattr(struct gfs2_inode *ip, uint64_t indirect,
 							 pass->private);
 			}
 			if (leaf_pointer_errors == leaf_pointers) {
-				if (indirect_buf->b_changed)
+				if (indirect_buf->b_modified)
 					gfs2_set_bitmap(sdp, indirect,
 							GFS2_BLKST_FREE);
 				gfs2_blockmap_set(sdp, bl, indirect,
@@ -794,8 +796,7 @@ int check_inode_eattr(struct gfs2_inode *ip, struct metawalk_fxns *pass)
 		  (unsigned long long)ip->i_di.di_num.no_addr);
 
 	if(ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT){
-		if((error = check_indirect_eattr(ip, ip->i_di.di_eattr,
-						 pass)))
+		if((error = check_indirect_eattr(ip, ip->i_di.di_eattr, pass)))
 			stack;
 	} else {
 		error = check_leaf_eattr(ip, ip->i_di.di_eattr,
@@ -809,12 +810,13 @@ int check_inode_eattr(struct gfs2_inode *ip, struct metawalk_fxns *pass)
 
 /**
  * build_and_check_metalist - check a bunch of indirect blocks
- * Note: Every buffer put on the metalist should be "held".
+ *                            This includes hash table blocks for directories
+ *                            which are technically "data" in the bitmap.
+ *
  * @ip:
  * @mlp:
  */
-static int build_and_check_metalist(struct gfs2_inode *ip,
-				    osi_list_t *mlp,
+static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
 				    struct metawalk_fxns *pass)
 {
 	uint32_t height = ip->i_di.di_height;
@@ -829,7 +831,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip,
 	/* if(<there are no indirect blocks to check>) */
 	if (height < 2)
 		return 0;
-	for (i = 1; i < height; i++){
+	for (i = 1; i < height; i++) {
 		prev_list = &mlp[i - 1];
 		cur_list = &mlp[i];
 
@@ -848,7 +850,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip,
 					continue;
 				head_size = sizeof(struct gfs2_dinode);
 			}
-
+			/* Now check the metadata itself */
 			for (ptr = (uint64_t *)(bh->b_data + head_size);
 			     (char *)ptr < (bh->b_data + ip->i_sbd->bsize);
 			     ptr++) {
@@ -982,7 +984,6 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
 				big_file_comfort(ip, blks_checked);
 		}
 	}
-
 	if (ip->i_di.di_blocks > COMFORTABLE_BLKS) {
 		log_notice( _("\rLarge file at %lld (0x%llx) - 100 percent "
 			      "complete.                                   "
@@ -1024,8 +1025,8 @@ end:
 }
 
 /* Checks stuffed inode directories */
-static int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
-			    struct metawalk_fxns *pass)
+int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
+		     struct metawalk_fxns *pass)
 {
 	int error = 0;
 	uint16_t count = 0;
@@ -1039,7 +1040,6 @@ static int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
 	return error;
 }
 
-
 int check_dir(struct gfs2_sbd *sbp, uint64_t block, struct metawalk_fxns *pass)
 {
 	struct gfs2_inode *ip;
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index 0ad0aa2..c24c705 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -6,26 +6,33 @@
 
 struct metawalk_fxns;
 
-int check_inode_eattr(struct gfs2_inode *ip, struct metawalk_fxns *pass);
-int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass);
-int check_dir(struct gfs2_sbd *sbp, uint64_t block,
-			  struct metawalk_fxns *pass);
-int remove_dentry_from_dir(struct gfs2_sbd *sbp, uint64_t dir,
-						   uint64_t dentryblock);
-int find_di(struct gfs2_sbd *sbp, uint64_t childblock, struct dir_info **dip);
-int dinode_hash_insert(osi_list_t *buckets, uint64_t key, struct dir_info *di);
-int dinode_hash_remove(osi_list_t *buckets, uint64_t key);
-int delete_blocks(struct gfs2_inode *ip, uint64_t block,
-		  struct gfs2_buffer_head **bh, const char *btype,
-		  void *private);
-int delete_metadata(struct gfs2_inode *ip, uint64_t block,
-		    struct gfs2_buffer_head **bh, void *private);
-int delete_data(struct gfs2_inode *ip, uint64_t block, void *private);
-int delete_eattr_indir(struct gfs2_inode *ip, uint64_t block, uint64_t parent,
-		       struct gfs2_buffer_head **bh, void *private);
-int delete_eattr_leaf(struct gfs2_inode *ip, uint64_t block, uint64_t parent,
-		      struct gfs2_buffer_head **bh, void *private);
-struct dup_blks *dupfind(uint64_t num);
+extern int check_inode_eattr(struct gfs2_inode *ip,
+			     struct metawalk_fxns *pass);
+extern int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass);
+extern int check_dir(struct gfs2_sbd *sbp, uint64_t block,
+		     struct metawalk_fxns *pass);
+extern int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
+			    struct metawalk_fxns *pass);
+extern int remove_dentry_from_dir(struct gfs2_sbd *sbp, uint64_t dir,
+				  uint64_t dentryblock);
+extern int find_di(struct gfs2_sbd *sbp, uint64_t childblock,
+		   struct dir_info **dip);
+extern int dinode_hash_insert(osi_list_t *buckets, uint64_t key,
+			      struct dir_info *di);
+extern int dinode_hash_remove(osi_list_t *buckets, uint64_t key);
+extern int delete_blocks(struct gfs2_inode *ip, uint64_t block,
+			 struct gfs2_buffer_head **bh, const char *btype,
+			 void *private);
+extern int delete_metadata(struct gfs2_inode *ip, uint64_t block,
+			   struct gfs2_buffer_head **bh, void *private);
+extern int delete_data(struct gfs2_inode *ip, uint64_t block, void *private);
+extern int delete_eattr_indir(struct gfs2_inode *ip, uint64_t block,
+			      uint64_t parent, struct gfs2_buffer_head **bh,
+			      void *private);
+extern int delete_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
+			     uint64_t parent, struct gfs2_buffer_head **bh,
+			     void *private);
+extern struct dup_blks *dupfind(uint64_t num);
 
 #define is_duplicate(dblock) ((dupfind(dblock)) ? 1 : 0)
 
@@ -74,8 +81,7 @@ struct metawalk_fxns {
 				     struct gfs2_ea_header *ea_hdr_prev,
 				     void *private);
 	int (*finish_eattr_indir) (struct gfs2_inode *ip, int leaf_pointers,
-				   int leaf_pointer_errors,
-				   void *private);
+				   int leaf_pointer_errors, void *private);
 };
 
 #endif /* _METAWALK_H */
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 2d1aed5..6862f29 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -73,8 +73,11 @@ static int leaf(struct gfs2_inode *ip, uint64_t block,
 {
 	struct block_count *bc = (struct block_count *) private;
 
-	log_debug( _("\tLeaf block at %15" PRIu64 " (0x%" PRIx64 ")\n"),
-			  block, block);
+	log_debug( _("\tDinode %lld (0x%llx) references leaf block #%lld "
+		     "(0x%llx)\n"),
+		   (unsigned long long)ip->i_di.di_num.no_addr,
+		   (unsigned long long)ip->i_di.di_num.no_addr,
+		   (unsigned long long)block, (unsigned long long)block);
 	gfs2_blockmap_set(ip->i_sbd, bl, block, gfs2_leaf_blk);
 	bc->indir_count++;
 	return 0;
@@ -148,7 +151,7 @@ static int check_data(struct gfs2_inode *ip, uint64_t block, void *private)
 		return 1;
 	}
 	q = block_type(block);
-	if(q != gfs2_block_free) {
+	if (q != gfs2_block_free) {
 		log_err( _("Found duplicate block referenced as data at %"
 			   PRIu64 " (0x%"PRIx64 ")\n"), block, block);
 		if (q != gfs2_meta_inval) {
@@ -234,8 +237,7 @@ static int ask_remove_inode_eattr(struct gfs2_inode *ip,
 	log_err( _("Inode %lld (0x%llx) has unrecoverable Extended Attribute "
 		   "errors.\n"), (unsigned long long)ip->i_di.di_num.no_addr,
 		 (unsigned long long)ip->i_di.di_num.no_addr);
-	if (query( _("Clear all Extended Attributes from the "
-		     "inode? (y/n) "))) {
+	if (query( _("Clear all Extended Attributes from the inode? (y/n) "))){
 		if (!remove_inode_eattr(ip, bc,
 					is_duplicate(ip->i_di.di_eattr)))
 			log_err( _("Extended attributes were removed.\n"));
@@ -766,14 +768,14 @@ static int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
 	}
 
 	pass1_fxns.private = &bc;
-
 	error = check_metatree(ip, &pass1_fxns);
 	if (fsck_abort || error < 0) {
 		fsck_inode_put(&ip);
 		return 0;
 	}
-	if(error > 0) {
-		log_warn( _("Marking inode #%llu (0x%llx) invalid\n"),
+	if (error > 0) {
+		log_err( _("Error: inode %llu (0x%llx) has unrecoverable "
+			   "errors; invalidating.\n"),
 			 (unsigned long long)ip->i_di.di_num.no_addr,
 			 (unsigned long long)ip->i_di.di_num.no_addr);
 		/* FIXME: Must set all leaves invalid as well */
@@ -810,7 +812,9 @@ static int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
 			ip->i_di.di_blocks = 1 + bc.indir_count + bc.data_count +
 				bc.ea_count;
 			bmodified(ip->i_bh);
-			gfs2_dinode_out(&ip->i_di, ip->i_bh);
+			log_err( _("Block count for #%llu (0x%llx) fixed\n"),
+				(unsigned long long)ip->i_di.di_num.no_addr,
+				(unsigned long long)ip->i_di.di_num.no_addr);
 		} else
 			log_err( _("Bad block count for #%llu (0x%llx"
 				") not fixed\n"),
@@ -822,46 +826,6 @@ static int handle_di(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
 	return 0;
 }
 
-static int scan_meta(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh,
-			  uint64_t block)
-{
-	if (gfs2_check_meta(bh, 0)) {
-		log_info( _("Found invalid metadata at #%llu (0x%llx)\n"),
-			  (unsigned long long)block,
-			  (unsigned long long)block);
-		if(gfs2_blockmap_set(sdp, bl, block, gfs2_meta_inval)) {
-			stack;
-			return -1;
-		}
-		if(query( _("Okay to free the invalid block? (y/n)"))) {
-			gfs2_set_bitmap(sdp, block, GFS2_BLKST_FREE);
-			log_err( _("The invalid block was freed.\n"));
-		} else {
-			log_err( _("The invalid block was ignored.\n"));
-		}
-		return 0;
-	}
-
-	log_debug( _("Checking metadata block #%" PRIu64 " (0x%" PRIx64 ")\n"), block,
-			  block);
-
-	if (!gfs2_check_meta(bh, GFS2_METATYPE_DI)) {
-		/* handle_di calls inode_get, then inode_put, which does brelse.   */
-		/* In order to prevent brelse from getting the count off, hold it. */
-		if(handle_di(sdp, bh, block)) {
-			stack;
-			return -1;
-		}
-	}
-	/* Ignore everything else - they should be hit by the handle_di step.
-	 * Don't check NONE either, because check_meta passes everything if
-	 * GFS2_METATYPE_NONE is specified.
-	 * Hopefully, other metadata types such as indirect blocks will be
-	 * handled when the inode itself is processed, and if it's not, it
-	 * should be caught in pass5. */
-	return 0;
-}
-
 /**
  * pass1 - walk through inodes and check inode state
  *
@@ -902,10 +866,9 @@ int pass1(struct gfs2_sbd *sbp)
 	 * uses the rg bitmaps, so maybe that's the best way to start
 	 * things - we can change the method later if necessary.
 	 */
-
 	for (tmp = sbp->rglist.next; tmp != &sbp->rglist;
-	     tmp = tmp->next, rg_count++){
-		log_info( _("Checking metadata in Resource Group #%" PRIu64 "\n"),
+	     tmp = tmp->next, rg_count++) {
+		log_debug( _("Checking metadata in Resource Group #%" PRIu64 "\n"),
 				 rg_count);
 		rgd = osi_list_entry(tmp, struct rgrp_list, list);
 		for (i = 0; i < rgd->ri.ri_length; i++) {
@@ -922,9 +885,12 @@ int pass1(struct gfs2_sbd *sbp)
 
 		while (1) {
 			/* "block" is relative to the entire file system */
+			/* Get the next dinode in the file system, according
+			   to the bitmap.  This should ONLY be dinodes. */
 			if (gfs2_next_rg_meta(rgd, &block, first))
 				break;
 			warm_fuzzy_stuff(block);
+
 			if (fsck_abort) /* if asked to abort */
 				return FSCK_OK;
 			if (skip_this_pass) {
@@ -934,11 +900,36 @@ int pass1(struct gfs2_sbd *sbp)
 			}
 			bh = bread(sbp, block);
 
-			if (scan_meta(sbp, bh, block)) {
+			/*log_debug( _("Checking metadata block #%" PRIu64
+			  " (0x%" PRIx64 ")\n"), block, block);*/
+
+			if (gfs2_check_meta(bh, GFS2_METATYPE_DI)) {
+				log_err( _("Found invalid inode at block #"
+					   "%llu (0x%llx)\n"),
+					 (unsigned long long)block,
+					 (unsigned long long)block);
+				if(query( _("Okay to free the invalid block? "
+					    "(y/n)"))) {
+					gfs2_set_bitmap(sbp, block,
+							GFS2_BLKST_FREE);
+					log_err( _("The invalid block was "
+						   "freed.\n"));
+				} else {
+					log_err( _("The invalid block was "
+						   "ignored.\n"));
+				}
+			} else if (handle_di(sbp, bh, block) < 0) {
 				stack;
 				brelse(bh);
 				return FSCK_ERROR;
 			}
+			/* Ignore everything else - they should be hit by the
+			   handle_di step.  Don't check NONE either, because
+			   check_meta passes everything if GFS2_METATYPE_NONE
+			   is specified.  Hopefully, other metadata types such
+			   as indirect blocks will be handled when the inode
+			   itself is processed, and if it's not, it should be
+			   caught in pass5. */
 			brelse(bh);
 			first = 0;
 		}
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index 4827534..ead608a 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -161,7 +161,7 @@ static int clear_dup_metalist(struct gfs2_inode *ip, uint64_t block,
 
 	if(dh->ref_count == 1)
 		return 1;
-	if(block == dh->b->block_no) {
+	if(block == dh->b->block) {
 		log_err( _("Found duplicate reference in inode \"%s\" at "
 			   "block #%llu (0x%llx) to block #%llu (0x%llx)\n"),
 			 dh->id->name ? dh->id->name : _("unknown name"),
@@ -195,7 +195,7 @@ static int clear_dup_eattr_indir(struct gfs2_inode *ip, uint64_t block,
 	*bh = NULL;
 	if(dh->ref_count == 1)
 		return 1;
-	if(block == dh->b->block_no) {
+	if(block == dh->b->block) {
 		log_err( _("Found dup in inode \"%s\" with address #%llu"
 			" (0x%llx) with block #%llu (0x%llx)\n"),
 			dh->id->name ? dh->id->name : _("unknown name"),
@@ -221,7 +221,7 @@ static int clear_dup_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
 
 	if(dh->ref_count == 1)
 		return 1;
-	if(block == dh->b->block_no) {
+	if(block == dh->b->block) {
 		log_err( _("Found dup in inode \"%s\" with address #%llu"
 			" (0x%llx) with block #%llu (0x%llx)\n"),
 			dh->id->name ? dh->id->name : _("unknown name"),
@@ -293,7 +293,7 @@ static int clear_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_data_ptr,
 
 	if(dh->ref_count == 1)
 		return 1;
-	if(block == dh->b->block_no) {
+	if(block == dh->b->block) {
 		log_err( _("Found dup in inode \"%s\" with address #%llu"
 			" (0x%llx) with block #%llu (0x%llx)\n"),
 			dh->id->name ? dh->id->name : _("unknown name"),
@@ -316,7 +316,7 @@ static int clear_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_data_ptr,
 static int find_block_ref(struct gfs2_sbd *sbp, uint64_t inode, struct dup_blks *b)
 {
 	struct gfs2_inode *ip;
-	struct fxn_info myfi = {b->block_no, 0, 1};
+	struct fxn_info myfi = {b->block, 0, 1};
 	struct inode_with_dups *id = NULL;
 	struct metawalk_fxns find_refs = {
 		.private = (void*) &myfi,
@@ -333,7 +333,7 @@ static int find_block_ref(struct gfs2_sbd *sbp, uint64_t inode, struct dup_blks
 	ip = fsck_load_inode(sbp, inode); /* bread, inode_get */
 	log_debug( _("Checking inode %" PRIu64 " (0x%" PRIx64 ")'s "
 		     "metatree for references to block %" PRIu64 " (0x%" PRIx64
-		     ")\n"), inode, inode, b->block_no, b->block_no);
+		     ")\n"), inode, inode, b->block, b->block);
 	if(check_metatree(ip, &find_refs)) {
 		stack;
 		fsck_inode_put(&ip); /* out, brelse, free */
@@ -357,7 +357,7 @@ static int find_block_ref(struct gfs2_sbd *sbp, uint64_t inode, struct dup_blks
 		}
 		log_debug( _("Found %d entries with block %" PRIu64
 				  " (0x%" PRIx64 ") in inode #%" PRIu64 " (0x%" PRIx64 ")\n"),
-				  myfi.found, b->block_no, b->block_no, inode, inode);
+				  myfi.found, b->block, b->block, inode, inode);
 		id->dup_count = myfi.found;
 		id->block_no = inode;
 		id->ea_only = myfi.ea_only;
@@ -402,7 +402,7 @@ static int handle_dup_blk(struct gfs2_sbd *sbp, struct dup_blks *b)
 		struct gfs2_buffer_head *bh;
 		uint32_t cmagic;
 
-		bh = bread(sbp, b->block_no);
+		bh = bread(sbp, b->block);
 		cmagic = ((struct gfs2_meta_header *)(bh->b_data))->mh_magic;
 		brelse(bh);
 		if (be32_to_cpu(cmagic) == GFS2_MAGIC) {
@@ -413,8 +413,8 @@ static int handle_dup_blk(struct gfs2_sbd *sbp, struct dup_blks *b)
 				    "but the block is really metadata.\n"),
 				  id->name, (unsigned long long)id->block_no,
 				  (unsigned long long)id->block_no,
-				  (unsigned long long)b->block_no,
-				  (unsigned long long)b->block_no);
+				  (unsigned long long)b->block,
+				  (unsigned long long)b->block);
 			if (query( _("Clear the inode? (y/n) "))) {
 				log_warn( _("Clearing inode %lld (0x%llx)...\n"),
 					 (unsigned long long)id->block_no,
@@ -438,8 +438,7 @@ static int handle_dup_blk(struct gfs2_sbd *sbp, struct dup_blks *b)
 
 	log_notice( _("Block %llu (0x%llx) has %d inodes referencing it"
 		   " for a total of %d duplicate references\n"),
-		   (unsigned long long)b->block_no,
-		   (unsigned long long)b->block_no,
+		   (unsigned long long)b->block, (unsigned long long)b->block,
 		   dh.ref_inode_count, dh.ref_count);
 
 	osi_list_foreach(tmp, &b->ref_inode_list) {
@@ -448,8 +447,8 @@ static int handle_dup_blk(struct gfs2_sbd *sbp, struct dup_blks *b)
 			    "block %llu (0x%llx)\n"), id->name,
 			  (unsigned long long)id->block_no,
 			  (unsigned long long)id->block_no,
-			  id->dup_count, (unsigned long long)b->block_no,
-			  (unsigned long long)b->block_no);
+			  id->dup_count, (unsigned long long)b->block,
+			  (unsigned long long)b->block);
 	}
 	osi_list_foreach(tmp, &b->ref_inode_list) {
 		id = osi_list_entry(tmp, struct inode_with_dups, list);
@@ -550,6 +549,12 @@ out:
                 b = osi_list_entry(tmp, struct dup_blks, list);
 		if (!skip_this_pass && !rc) /* no error & not asked to skip the rest */
 			handle_dup_blk(sbp, b);
+		/* Do not attempt to free the dup_blocks list or its parts
+		   here because any func that calls check_metatree needs
+		   to check duplicate status based on this linked list.
+		   This is especially true for pass2 where it may delete "bad"
+		   inodes, and we can't delete an inode's indirect block if
+		   it was a duplicate (therefore in use by another dinode). */
 	}
 	return rc;
 }
diff --git a/gfs2/fsck/pass1c.c b/gfs2/fsck/pass1c.c
index 4174363..10b92ed 100644
--- a/gfs2/fsck/pass1c.c
+++ b/gfs2/fsck/pass1c.c
@@ -206,7 +206,6 @@ static int check_eattr_extentry(struct gfs2_inode *ip, uint64_t *ea_ptr,
 	uint8_t q;
 	struct gfs2_sbd *sbp = ip->i_sbd;
 
-
 	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)){
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 5e60b50..27a7cc7 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -19,7 +19,7 @@
 /* Set children's parent inode in dir_info structure - ext2 does not set
  * dotdot inode here, but instead in pass3 - should we? */
 static int set_parent_dir(struct gfs2_sbd *sbp, uint64_t childblock,
-				   uint64_t parentblock)
+			  uint64_t parentblock)
 {
 	struct dir_info *di;
 
@@ -37,7 +37,7 @@ static int set_parent_dir(struct gfs2_sbd *sbp, uint64_t childblock,
 		}
 	} else {
 		log_err( _("Unable to find block %"PRIu64" (0x%" PRIx64
-				") in dir_info list\n"),	childblock,	childblock);
+			   ") in dir_info list\n"), childblock, childblock);
 		return -1;
 	}
 
@@ -93,9 +93,9 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
 static const char *de_type_string(uint8_t de_type)
 {
 	const char *de_types[15] = {"unknown", "fifo", "chrdev", "invalid",
-								"directory", "invalid", "blkdev", "invalid",
-								"file", "invalid", "symlink", "invalid",
-								"socket", "invalid", "wht"};
+				    "directory", "invalid", "blkdev", "invalid",
+				    "file", "invalid", "symlink", "invalid",
+				    "socket", "invalid", "wht"};
 	if (de_type < 15)
 		return de_types[de_type];
 	return de_types[3]; /* invalid */
@@ -220,8 +220,10 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 		strncpy(tmp_name, filename, MAX_FILENAME - 1);
 
 	if(gfs2_check_range(ip->i_sbd, entryblock)) {
-		log_err( _("Block # referenced by directory entry %s is out of range\n"),
-				tmp_name);
+		log_err( _("Block # referenced by directory entry %s in inode "
+			   "%lld (0x%llx) is out of range\n"),
+			 tmp_name, (unsigned long long)ip->i_di.di_num.no_addr,
+			 (unsigned long long)ip->i_di.di_num.no_addr);
 		if(query( _("Clear directory entry tp out of range block? (y/n) "))) {
 			log_err( _("Clearing %s\n"), tmp_name);
 			dirent2_del(ip, bh, prev_de, dent);
@@ -231,10 +233,12 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 			log_err( _("Directory entry to out of range block remains\n"));
 			(*count)++;
 			ds->entry_count++;
+			/* can't do this because the block is out of range:
+			   increment_link(entryblock); */
 			return 0;
 		}
 	}
-	q = block_type(de->de_inum.no_addr);
+	q = block_type(entryblock);
 	/* Get the status of the directory inode */
 	if(q == gfs2_bad_block) {
 		/* This entry's inode has bad blocks in it */
@@ -243,14 +247,13 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 		log_err( _("Found a bad directory entry: %s\n"), filename);
 
 		if(query( _("Delete inode containing bad blocks? (y/n)"))) {
-			entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
+			entry_ip = fsck_load_inode(sbp, entryblock);
 			check_inode_eattr(entry_ip, &pass2_fxns_delete);
 			check_metatree(entry_ip, &pass2_fxns_delete);
 			bmodified(entry_ip->i_bh);
 			fsck_inode_put(&entry_ip);
 			dirent2_del(ip, bh, prev_de, dent);
-			gfs2_blockmap_set(sbp, bl, de->de_inum.no_addr,
-				       gfs2_block_free);
+			gfs2_blockmap_set(sbp, bl, entryblock, gfs2_block_free);
 			bmodified(bh);
 			log_warn( _("The inode containing bad blocks was "
 				    "deleted.\n"));
@@ -263,15 +266,12 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 		}
 
 	}
-	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,
-			 (unsigned long long)de->de_inum.no_addr,
-			 (unsigned long long)de->de_inum.no_addr,
+	if(q < gfs2_inode_dir || q > gfs2_inode_sock) {
+		log_err( _("Directory entry '%s' referencing inode %llu "
+			   "(0x%llx) in dir inode %llu (0x%llx) block type "
+			   "%d: %s.\n"), tmp_name,
+			 (unsigned long long)entryblock,
+			 (unsigned long long)entryblock,
 			 (unsigned long long)ip->i_di.di_num.no_addr,
 			 (unsigned long long)ip->i_di.di_num.no_addr,
 			 q, q == gfs2_meta_inval ?
@@ -292,20 +292,19 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 				return 1;
 
 			/* Now try to clear the dinode, if it is an dinode */
-			bhi = bread(sbp, de->de_inum.no_addr);
+			bhi = bread(sbp, entryblock);
 			error = gfs2_check_meta(bhi, GFS2_METATYPE_DI);
 			bmodified(bhi);
 			brelse(bhi);
 			if (error)
 				return 1; /* not a dinode: nothing to delete */
 
-			entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
+			entry_ip = fsck_load_inode(sbp, entryblock);
 			check_inode_eattr(entry_ip, &pass2_fxns_delete);
 			check_metatree(entry_ip, &pass2_fxns_delete);
 			bmodified(entry_ip->i_bh);
 			fsck_inode_put(&entry_ip);
-			gfs2_blockmap_set(sbp, bl, de->de_inum.no_addr,
-				       gfs2_block_free);
+			gfs2_blockmap_set(sbp, bl, entryblock, gfs2_block_free);
 
 			return 1;
 		} else {
@@ -318,19 +317,29 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 
 	error = check_file_type(de->de_type, q);
 	if(error < 0) {
+		log_err( _("Error: directory entry type is "
+			   "incompatible with block type at block %lld "
+			   "(0x%llx) in directory inode %llu (0x%llx).\n"),
+			 (unsigned long long)entryblock,
+			 (unsigned long long)entryblock,
+			 (unsigned long long)ip->i_di.di_num.no_addr,
+			 (unsigned long long)ip->i_di.di_num.no_addr);
+		log_err( _("Directory entry type is %d, block type is %d.\n"),
+			 de->de_type, q);
 		stack;
 		return -1;
 	}
 	if(error > 0) {
-		log_warn( _("Type '%s' in dir entry (%s, %llu/0x%llx) conflicts"
+		log_err( _("Type '%s' in dir entry (%s, %llu/0x%llx) conflicts"
 			 " with type '%s' in dinode. (Dir entry is stale.)\n"),
 			 de_type_string(de->de_type), tmp_name,
-			 (unsigned long long)de->de_inum.no_addr,
-			 (unsigned long long)de->de_inum.no_addr,
+			 (unsigned long long)entryblock,
+			 (unsigned long long)entryblock,
 			 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);
+			entry_ip = fsck_load_inode(sbp, entryblock);
+		check_inode_eattr(entry_ip, &clear_eattrs);
+		if (entry_ip != ip)
 			fsck_inode_put(&entry_ip);
 
 			dirent2_del(ip, bh, prev_de, dent);
@@ -354,7 +363,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 				(unsigned long long)ip->i_di.di_num.no_addr,
 				(unsigned long long)ip->i_di.di_num.no_addr);
 			if(query( _("Clear duplicate '.' entry? (y/n) "))) {
-				entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
+				entry_ip = fsck_load_inode(sbp, entryblock);
 				check_inode_eattr(entry_ip, &clear_eattrs);
 				fsck_inode_put(&entry_ip);
 
@@ -366,7 +375,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 				/* FIXME: Should we continue on here
 				 * and check the rest of the '.'
 				 * entry? */
-				increment_link(sbp, de->de_inum.no_addr);
+				increment_link(sbp, entryblock);
 				(*count)++;
 				ds->entry_count++;
 				return 0;
@@ -377,19 +386,19 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 		 * location */
 
 		/* check that '.' refers to this inode */
-		if(de->de_inum.no_addr != ip->i_di.di_num.no_addr) {
+		if(entryblock != ip->i_di.di_num.no_addr) {
 			log_err( _("'.' entry's value incorrect in directory %llu"
 				" (0x%llx).  Points to %llu"
 				" (0x%llx) when it should point to %llu"
 				" (0x%llx).\n"),
-				(unsigned long long)de->de_inum.no_addr,
-				(unsigned long long)de->de_inum.no_addr,
-				(unsigned long long)de->de_inum.no_addr,
-				(unsigned long long)de->de_inum.no_addr,
+				(unsigned long long)entryblock,
+				(unsigned long long)entryblock,
+				(unsigned long long)entryblock,
+				(unsigned long long)entryblock,
 				(unsigned long long)ip->i_di.di_num.no_addr,
 				(unsigned long long)ip->i_di.di_num.no_addr);
 			if(query( _("Remove '.' reference? (y/n) "))) {
-				entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
+				entry_ip = fsck_load_inode(sbp, entryblock);
 				check_inode_eattr(entry_ip, &clear_eattrs);
 				fsck_inode_put(&entry_ip);
 
@@ -401,7 +410,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 				log_err( _("Invalid '.' reference remains\n"));
 				/* Not setting ds->dotdir here since
 				 * this '.' entry is invalid */
-				increment_link(sbp, de->de_inum.no_addr);
+				increment_link(sbp, entryblock);
 				(*count)++;
 				ds->entry_count++;
 				return 0;
@@ -409,7 +418,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 		}
 
 		ds->dotdir = 1;
-		increment_link(sbp, de->de_inum.no_addr);
+		increment_link(sbp, entryblock);
 		(*count)++;
 		ds->entry_count++;
 
@@ -424,7 +433,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 				(unsigned long long)ip->i_di.di_num.no_addr);
 			if(query( _("Clear duplicate '..' entry? (y/n) "))) {
 
-				entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
+				entry_ip = fsck_load_inode(sbp, entryblock);
 				check_inode_eattr(entry_ip, &clear_eattrs);
 				fsck_inode_put(&entry_ip);
 
@@ -436,7 +445,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 				/* FIXME: Should we continue on here
 				 * and check the rest of the '..'
 				 * entry? */
-				increment_link(sbp, de->de_inum.no_addr);
+				increment_link(sbp, entryblock);
 				(*count)++;
 				ds->entry_count++;
 				return 0;
@@ -449,8 +458,9 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 				(unsigned long long)ip->i_di.di_num.no_addr,
 				(unsigned long long)ip->i_di.di_num.no_addr);
 			if(query( _("Clear bad '..' directory entry? (y/n) "))) {
-				entry_ip = fsck_load_inode(sbp, de->de_inum.no_addr);
-				check_inode_eattr(entry_ip, &clear_eattrs);
+				entry_ip = fsck_load_inode(sbp, entryblock);
+			check_inode_eattr(entry_ip, &clear_eattrs);
+			if (entry_ip != ip)
 				fsck_inode_put(&entry_ip);
 
 				dirent2_del(ip, bh, prev_de, dent);
@@ -458,14 +468,13 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 				return 1;
 			} else {
 				log_err( _("Bad '..' directory entry remains\n"));
-				increment_link(sbp, de->de_inum.no_addr);
+				increment_link(sbp, entryblock);
 				(*count)++;
 				ds->entry_count++;
 				return 0;
 			}
 		}
-		/* GFS2 does not rely on '..' being in a
-		 * certain location */
+		/* GFS2 does not rely on '..' being in a certain location */
 
 		/* Add the address this entry is pointing to
 		 * to this inode's dotdot_parent in
@@ -476,27 +485,26 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 		}
 
 		ds->dotdotdir = 1;
-		increment_link(sbp, de->de_inum.no_addr);
+		increment_link(sbp, entryblock);
 		(*count)++;
 		ds->entry_count++;
 		return 0;
 	}
 
-	/* After this point we're only concerned with
-	 * directories */
+	/* After this point we're only concerned with directories */
 	if(q != gfs2_inode_dir) {
 		log_debug( _("Found non-dir inode dentry\n"));
-		increment_link(sbp, de->de_inum.no_addr);
+		increment_link(sbp, entryblock);
 		(*count)++;
 		ds->entry_count++;
 		return 0;
 	}
 
-	log_debug( _("Found plain directory dentry\n"));
+	/*log_debug( _("Found plain directory dentry\n"));*/
 	error = set_parent_dir(sbp, entryblock, ip->i_di.di_num.no_addr);
 	if(error > 0) {
 		log_err( _("%s: Hard link to block %" PRIu64" (0x%" PRIx64
-				") detected.\n"), filename, entryblock, entryblock);
+			   ") detected.\n"), tmp_name, entryblock, entryblock);
 
 		if(query( _("Clear hard link to directory? (y/n) "))) {
 			bmodified(bh);
@@ -510,12 +518,11 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 			ds->entry_count++;
 			return 0;
 		}
-	}
-	else if (error < 0) {
+	} else if (error < 0) {
 		stack;
 		return -1;
 	}
-	increment_link(sbp, de->de_inum.no_addr);
+	increment_link(sbp, entryblock);
 	(*count)++;
 	ds->entry_count++;
 	/* End of checks */
@@ -650,7 +657,7 @@ static inline int is_system_dir(struct gfs2_sbd *sbp, uint64_t block)
  */
 int pass2(struct gfs2_sbd *sbp)
 {
-	uint64_t i;
+	uint64_t dirblk;
 	uint8_t q;
 	struct dir_status ds = {0};
 	struct gfs2_inode *ip;
@@ -679,43 +686,44 @@ int pass2(struct gfs2_sbd *sbp)
 	}
 	log_info( _("Checking directory inodes.\n"));
 	/* Grab each directory inode, and run checks on it */
-	for(i = 0; i < last_fs_block; i++) {
-		warm_fuzzy_stuff(i);
+	for(dirblk = 0; dirblk < last_fs_block; dirblk++) {
+		warm_fuzzy_stuff(dirblk);
 		if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
 			return FSCK_OK;
 
 		/* Skip the system inodes - they're checked above */
-		if (is_system_dir(sbp, i))
+		if (is_system_dir(sbp, dirblk))
 			continue;
 
-		q = block_type(i);
+		q = block_type(dirblk);
 
 		if(q != gfs2_inode_dir)
 			continue;
 
 		log_debug( _("Checking directory inode at block %"PRIu64" (0x%"
-				  PRIx64 ")\n"), i, i);
+				  PRIx64 ")\n"), dirblk, dirblk);
 
 		memset(&ds, 0, sizeof(ds));
 		pass2_fxns.private = (void *) &ds;
 		if(ds.q == gfs2_bad_block) {
 			/* First check that the directory's metatree
 			 * is valid */
-			ip = fsck_load_inode(sbp, i);
+			ip = fsck_load_inode(sbp, dirblk);
 			if(check_metatree(ip, &pass2_fxns)) {
 				fsck_inode_put(&ip);
 				stack;
 				return FSCK_ERROR;
 			}
 		}
-		error = check_dir(sbp, i, &pass2_fxns);
+		error = check_dir(sbp, dirblk, &pass2_fxns);
 		if(error < 0) {
 			stack;
 			return FSCK_ERROR;
 		}
 		if (error > 0) {
 			struct dir_info *di = NULL;
-			error = find_di(sbp, i, &di);
+
+			error = find_di(sbp, dirblk, &di);
 			if(error < 0) {
 				stack;
 				return FSCK_ERROR;
@@ -724,30 +732,33 @@ int pass2(struct gfs2_sbd *sbp)
 				/* FIXME: factor */
 				if(query( _("Remove directory entry for bad"
 					    " inode %"PRIu64" (0x%" PRIx64 ") in %"PRIu64
-					    " (0x%" PRIx64 ")? (y/n)"), i, i, di->treewalk_parent,
+					    " (0x%" PRIx64 ")? (y/n)"),
+					  dirblk, dirblk, di->treewalk_parent,
 					  di->treewalk_parent)) {
-					error = remove_dentry_from_dir(sbp, di->treewalk_parent,
-												   i);
+					error = remove_dentry_from_dir(sbp,
+							di->treewalk_parent,
+								       dirblk);
 					if(error < 0) {
 						stack;
 						return FSCK_ERROR;
 					}
 					if(error > 0) {
 						log_warn( _("Unable to find dentry for %"
-								 PRIu64 " (0x%" PRIx64 ") in %" PRIu64
-								 " (0x%" PRIx64 ")\n"), i, i,
-								 di->treewalk_parent, di->treewalk_parent);
+							    PRIu64 " (0x%" PRIx64 ") in %" PRIu64
+							    " (0x%" PRIx64 ")\n"), dirblk, dirblk,
+							  di->treewalk_parent, di->treewalk_parent);
 					}
 					log_warn( _("Directory entry removed\n"));
 				} else
 					log_err( _("Directory entry to invalid inode remains.\n"));
 			}
-			gfs2_blockmap_set(sbp, bl, i, gfs2_meta_inval);
+			gfs2_blockmap_set(sbp, bl, dirblk, gfs2_meta_inval);
 		}
-		ip = fsck_load_inode(sbp, i);
+		ip = fsck_load_inode(sbp, dirblk);
 		if(!ds.dotdir) {
 			log_err(_("No '.' entry found for directory inode at "
-				  "block %"PRIu64" (0x%" PRIx64 ")\n"), i, i);
+				  "block %"PRIu64" (0x%" PRIx64 ")\n"),
+				dirblk, dirblk);
 
 			if (query( _("Is it okay to add '.' entry? (y/n) "))) {
 				sprintf(tmp_name, ".");
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index bcca68c..c1986f3 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -55,11 +55,12 @@ static int attach_dotdot_to(struct gfs2_sbd *sbp, uint64_t newdotdot,
 	bmodified(ip->i_bh);
 	fsck_inode_put(&ip);
 	fsck_inode_put(&pip);
+	free(filename);
 	return 0;
 }
 
 static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
-										struct dir_info *di)
+					       struct dir_info *di)
 {
 	struct dir_info *pdi;
 	uint8_t q_dotdot, q_treewalk;
@@ -98,8 +99,7 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
 								 di->dotdot_parent, di->dinode);
 				di->dotdot_parent = di->treewalk_parent;
 			}
-		}
-		else {
+		} else {
 			if(q_treewalk != gfs2_inode_dir) {
 				int error = 0;
 				log_warn( _(".. parent is valid, but treewalk"
@@ -133,10 +133,11 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sbp,
 			}
 			else {
 				log_err( _("Both .. and treewalk parents are "
-						"directories, going with treewalk for "
-						"now...\n"));
+					   "directories, going with treewalk "
+					   "for now...\n"));
 				attach_dotdot_to(sbp, di->treewalk_parent,
-								 di->dotdot_parent, di->dinode);
+						 di->dotdot_parent,
+						 di->dinode);
 				di->dotdot_parent = di->treewalk_parent;
 			}
 		}
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index b3f28d7..a28dec6 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -24,7 +24,8 @@ struct metawalk_fxns pass4_fxns_delete = {
 static int fix_inode_count(struct gfs2_sbd *sbp, struct inode_info *ii,
 					struct gfs2_inode *ip)
 {
-	log_info( _("Fixing inode count for %llu (0x%llx) \n"),
+	log_info( _("Fixing inode link count (%d->%d) for %llu (0x%llx) \n"),
+		  ip->i_di.di_nlink, ii->counted_links,
 		 (unsigned long long)ip->i_di.di_num.no_addr,
 		 (unsigned long long)ip->i_di.di_num.no_addr);
 	if(ip->i_di.di_nlink == ii->counted_links)
@@ -55,8 +56,6 @@ static int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
 			log_crit( _("osi_list_foreach broken in scan_info_list!!\n"));
 			exit(FSCK_ERROR);
 		}
-		log_debug( _("Checking reference count on inode at block %" PRIu64
-				  " (0x%" PRIx64 ")\n"), ii->inode, ii->inode);
 		if(ii->counted_links == 0) {
 			log_err( _("Found unlinked inode at %" PRIu64 " (0x%" PRIx64 ")\n"),
 					ii->inode, ii->inode);
@@ -87,8 +86,11 @@ static int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
 			   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);
+				log_err( _("Unlinked block %lld (0x%llx) "
+					   "marked as inode is "
+					   "not an inode (%d)\n"),
+					 (unsigned long long)ii->inode,
+					 (unsigned long long)ii->inode, q);
 				ip = fsck_load_inode(sbp, ii->inode);
 				if(query(_("Delete unlinked inode? (y/n) "))) {
 					check_inode_eattr(ip,
@@ -126,8 +128,7 @@ static int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
 					stack;
 					fsck_inode_put(&ip);
 					return -1;
-				}
-				else {
+				} else {
 					fix_inode_count(sbp, ii, ip);
 					lf_addition = 1;
 				}
@@ -148,8 +149,10 @@ static int scan_inode_list(struct gfs2_sbd *sbp, osi_list_t *list) {
 				fix_inode_count(sbp, ii, ip);
 				bmodified(ip->i_bh);
 				fsck_inode_put(&ip); /* out, brelse, free */
-				log_warn( _("Link count updated for inode %"
-						 PRIu64 " (0x%" PRIx64 ") \n"), ii->inode, ii->inode);
+				log_warn( _("Link count updated to %d for "
+					    "inode %" PRIu64 " (0x%"
+					    PRIx64 ") \n"), ii->link_count,
+					  ii->inode, ii->inode);
 			} else {
 				log_err( _("Link count for inode %" PRIu64 " (0x%" PRIx64
 						") still incorrect\n"), ii->inode, ii->inode);
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index 3448204..41da203 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -43,7 +43,7 @@ static int convert_mark(uint8_t q, uint32_t *count)
 		return GFS2_BLKST_USED;
 
 	default:
-		log_err( _("Invalid state %d found\n"), q);
+		log_err( _("Invalid block type %d found\n"), q);
 		return -1;
 	}
 	return -1;
@@ -122,9 +122,9 @@ static int check_block_status(struct gfs2_sbd *sbp, char *buffer, unsigned int b
 			log_err( _("Metadata type is %u (%s)\n"), q,
 					block_type_string(q));
 
-			if(query( _("Fix bitmap for block %" PRIu64
-				    " (0x%" PRIx64 ") ? (y/n) "),
-				  block, block)) {
+			if(query(_("Fix bitmap for block %" PRIu64
+				   " (0x%" PRIx64 ") ? (y/n) "),
+				 block, block)) {
 				if(gfs2_set_bitmap(sbp, block, block_status))
 					log_err( _("Failed.\n"));
 				else
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 0cb99d2..2dace5d 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -19,11 +19,11 @@ struct special_blocks false_rgrps;
 
 #define ri_compare(rg, ondisk, expected, field, fmt)	\
 	if (ondisk.field != expected.field) { \
-		log_warn("rindex #%d " #field " discrepancy: index 0x%" fmt \
-			 " != expected: 0x%" fmt "\n",			\
-			 rg + 1, ondisk.field, expected.field);		\
-		ondisk.field = expected.field; \
-		rindex_modified = TRUE; \
+		log_warn( _("rindex #%d " #field " discrepancy: index 0x%" \
+			    fmt	" != expected: 0x%" fmt "\n"),		\
+			  rg + 1, ondisk.field, expected.field);	\
+		ondisk.field = expected.field;				\
+		rindex_modified = TRUE;					\
 	}
 
 /*
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 2d601ef..a705975 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -58,7 +58,7 @@ void warm_fuzzy_stuff(uint64_t block)
 	static uint64_t one_percent = 0;
 	static struct timeval tv;
 	static uint32_t seconds = 0;
-	
+
 	if (!one_percent)
 		one_percent = last_fs_block / 100;
 	if (block - last_reported_block >= one_percent) {
@@ -160,7 +160,7 @@ void gfs2_dup_set(uint64_t block)
 	b = malloc(sizeof(struct dup_blks));
 	if (b) {
 		memset(b, 0, sizeof(*b));
-		b->block_no = block;
+		b->block = block;
 		osi_list_init(&b->ref_inode_list);
 		osi_list_add(&b->list, &dup_blocks.list);
 	}
diff --git a/gfs2/libgfs2/block_list.c b/gfs2/libgfs2/block_list.c
index aa774be..bc8babc 100644
--- a/gfs2/libgfs2/block_list.c
+++ b/gfs2/libgfs2/block_list.c
@@ -91,7 +91,6 @@ void gfs2_special_set(struct special_blocks *blocklist, uint64_t block)
 		b->block = block;
 		osi_list_add(&b->list, &blocklist->list);
 	}
-	return;
 }
 
 void gfs2_special_clear(struct special_blocks *blocklist, uint64_t block)
diff --git a/gfs2/libgfs2/buf.c b/gfs2/libgfs2/buf.c
index 5b8d29d..5a0f718 100644
--- a/gfs2/libgfs2/buf.c
+++ b/gfs2/libgfs2/buf.c
@@ -69,7 +69,7 @@ int bwrite(struct gfs2_buffer_head *bh)
 	if (write(sdp->device_fd, bh->b_data, sdp->bsize) != sdp->bsize)
 		return -1;
 	sdp->writes++;
-	bh->b_changed = 0;
+	bh->b_modified = 0;
 	return 0;
 }
 
@@ -79,7 +79,7 @@ int brelse(struct gfs2_buffer_head *bh)
 
 	if (bh->b_blocknr == -1)
 		printf("Double free!\n");
-	if (bh->b_changed)
+	if (bh->b_modified)
 		error = bwrite(bh);
 	bh->b_blocknr = -1;
 	if (bh->b_altlist.next && !osi_list_empty(&bh->b_altlist))
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index b3b527f..bc8319e 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -93,7 +93,7 @@ void inode_put(struct gfs2_inode **ip_in)
 	uint64_t block = ip->i_di.di_num.no_addr;
 	struct gfs2_sbd *sdp = ip->i_sbd;
 
-	if (ip->i_bh->b_changed) {
+	if (ip->i_bh->b_modified) {
 		gfs2_dinode_out(&ip->i_di, ip->i_bh);
 		if (!ip->bh_owned && is_system_inode(sdp, block))
 			fprintf(stderr, "Warning: Change made to inode "
@@ -154,8 +154,9 @@ static uint64_t blk_alloc_i(struct gfs2_sbd *sdp, unsigned int type)
 
 found:
 	if (bn >= ri->ri_bitbytes * GFS2_NBBY)
-		die("allocation is broken (2): %u %u %"PRIu64" %u\n",
-		    bn, ri->ri_bitbytes * GFS2_NBBY,
+		die("allocation is broken (2): bn: %u %u rgrp: %"PRIu64
+		    " (0x%" PRIx64 ") Free:%u\n",
+		    bn, ri->ri_bitbytes * GFS2_NBBY, (uint64_t)rl->ri.ri_addr,
 		    (uint64_t)rl->ri.ri_addr, rl->rg.rg_free);
 
 	switch (type) {
@@ -234,15 +235,14 @@ void unstuff_dinode(struct gfs2_inode *ip)
 
 	if (ip->i_di.di_size) {
 		if (isdir) {
+			struct gfs2_meta_header mh;
+
 			block = meta_alloc(ip);
 			bh = bget(sdp, block);
-			{
-				struct gfs2_meta_header mh;
-				mh.mh_magic = GFS2_MAGIC;
-				mh.mh_type = GFS2_METATYPE_JD;
-				mh.mh_format = GFS2_FORMAT_JD;
-				gfs2_meta_header_out(&mh, bh);
-			}
+			mh.mh_magic = GFS2_MAGIC;
+			mh.mh_type = GFS2_METATYPE_JD;
+			mh.mh_format = GFS2_FORMAT_JD;
+			gfs2_meta_header_out(&mh, bh);
 
 			buffer_copy_tail(sdp, bh,
 					 sizeof(struct gfs2_meta_header),
@@ -312,15 +312,14 @@ void build_height(struct gfs2_inode *ip, int height)
 			}
 
 		if (new_block) {
+			struct gfs2_meta_header mh;
+
 			block = meta_alloc(ip);
 			bh = bget(sdp, block);
-			{
-				struct gfs2_meta_header mh;
-				mh.mh_magic = GFS2_MAGIC;
-				mh.mh_type = GFS2_METATYPE_IN;
-				mh.mh_format = GFS2_FORMAT_IN;
-				gfs2_meta_header_out(&mh, bh);
-			}
+			mh.mh_magic = GFS2_MAGIC;
+			mh.mh_type = GFS2_METATYPE_IN;
+			mh.mh_format = GFS2_FORMAT_IN;
+			gfs2_meta_header_out(&mh, bh);
 			buffer_copy_tail(sdp, bh,
 					 sizeof(struct gfs2_meta_header),
 					 ip->i_bh, sizeof(struct gfs2_dinode));
@@ -567,7 +566,7 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
 }
 
 static void copy_from_mem(struct gfs2_buffer_head *bh, void **buf,
-						  unsigned int offset, unsigned int size)
+			  unsigned int offset, unsigned int size)
 {
 	char **p = (char **)buf;
 
@@ -763,7 +762,7 @@ static int dirent_alloc(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
 				memset(new, 0, sizeof(struct gfs2_dirent));
 
 				new->de_rec_len = cpu_to_be16(cur_rec_len -
-											  GFS2_DIRENT_SIZE(cur_name_len));
+					  GFS2_DIRENT_SIZE(cur_name_len));
 				new->de_name_len = cpu_to_be16(name_len);
 
 				new_rec_len = be16_to_cpu(new->de_rec_len);
@@ -812,14 +811,13 @@ void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
 }
 
 void gfs2_get_leaf_nr(struct gfs2_inode *dip, uint32_t lindex,
-					  uint64_t *leaf_out)
+		      uint64_t *leaf_out)
 {
 	uint64_t leaf_no;
 	int count;
 
-	count = gfs2_readi(dip, (char *)&leaf_no,
-		      lindex * sizeof(uint64_t),
-		      sizeof(uint64_t));
+	count = gfs2_readi(dip, (char *)&leaf_no, lindex * sizeof(uint64_t),
+			   sizeof(uint64_t));
 	if (count != sizeof(uint64_t))
 		die("gfs2_get_leaf_nr:  Bad internal read.\n");
 
@@ -838,7 +836,8 @@ void gfs2_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out)
 		die("gfs2_put_leaf_nr:  Bad internal write.\n");
 }
 
-static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, uint64_t leaf_no)
+static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
+			   uint64_t leaf_no)
 {
 	struct gfs2_buffer_head *nbh, *obh;
 	struct gfs2_leaf *nleaf, *oleaf;
@@ -875,16 +874,11 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, uint64_t lea
 		fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
 		exit(-1);
 	}
-	count = gfs2_readi(dip, (char *)lp, start * sizeof(uint64_t),
-		      half_len * sizeof(uint64_t));
-	if (count != half_len * sizeof(uint64_t))
-		die("dir_split_leaf (1)\n");
-
 	for (x = 0; x < half_len; x++)
 		lp[x] = cpu_to_be64(bn);
 
 	count = gfs2_writei(dip, (char *)lp, start * sizeof(uint64_t),
-		       half_len * sizeof(uint64_t));
+			    half_len * sizeof(uint64_t));
 	if (count != half_len * sizeof(uint64_t))
 		die("dir_split_leaf (2)\n");
 
@@ -976,7 +970,7 @@ static void dir_double_exhash(struct gfs2_inode *dip)
 		}
 
 		count = gfs2_writei(dip, (char *)buf + sdp->sd_hash_bsize,
-							block * sdp->bsize, sdp->bsize);
+				    block * sdp->bsize, sdp->bsize);
 		if (count != sdp->bsize)
 			die("dir_double_exhash (2)\n");
 
@@ -1062,8 +1056,8 @@ static void dir_e_add(struct gfs2_inode *dip, const char *filename, int len,
 	uint32_t hash;
 	uint64_t leaf_no, bn;
 
- restart:
 	hash = gfs2_disk_hash(filename, len);
+restart:
 	/* Have to kludge because (hash >> 32) gives hash for some reason. */
 	if (dip->i_di.di_depth)
 		lindex = hash >> (32 - dip->i_di.di_depth);
@@ -1094,15 +1088,14 @@ static void dir_e_add(struct gfs2_inode *dip, const char *filename, int len,
 				continue;
 
 			} else {
+				struct gfs2_meta_header mh;
+
 				bn = meta_alloc(dip);
 				nbh = bget(dip->i_sbd, bn);
-				{
-					struct gfs2_meta_header mh;
-					mh.mh_magic = GFS2_MAGIC;
-					mh.mh_type = GFS2_METATYPE_LF;
-					mh.mh_format = GFS2_FORMAT_LF;
-					gfs2_meta_header_out(&mh, nbh);
-				}
+				mh.mh_magic = GFS2_MAGIC;
+				mh.mh_type = GFS2_METATYPE_LF;
+				mh.mh_format = GFS2_FORMAT_LF;
+				gfs2_meta_header_out(&mh, nbh);
 
 				leaf->lf_next = cpu_to_be64(bn);
 
diff --git a/gfs2/libgfs2/gfs2_log.c b/gfs2/libgfs2/gfs2_log.c
index 907c5f7..622589b 100644
--- a/gfs2/libgfs2/gfs2_log.c
+++ b/gfs2/libgfs2/gfs2_log.c
@@ -50,19 +50,16 @@ void print_msg(int priority, const char *file, int line,
 		vfprintf(stderr, format, args);
 		break;
 	}
-	return;
 }
 
 
 void print_fsck_log(int iif, int priority, const char *file, int line,
 		    const char *format, ...)
 {
-
 	va_list args;
 	const char *transform;
 
-        va_start(args, format);
-
+	va_start(args, format);
 	transform = _(format);
 
 	if((_state.print_level == priority) ||
@@ -150,7 +147,6 @@ char generic_interrupt(const char *caller, const char *where,
 int gfs2_query(int *setonabort, struct gfs2_options *opts,
 	       const char *format, ...)
 {
-
 	va_list args;
 	const char *transform;
 	char response;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 3b843e5..b0745aa 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -111,7 +111,7 @@ struct rgrp_list {
 struct gfs2_buffer_head {
 	osi_list_t b_altlist; /* alternate list */
 	uint64_t b_blocknr;
-	int b_changed;
+	int b_modified;
 	char *b_data;
 	struct gfs2_sbd *sdp;
 };
@@ -329,7 +329,7 @@ extern struct gfs2_buffer_head *__bread(struct gfs2_sbd *sdp, uint64_t num,
 extern int bwrite(struct gfs2_buffer_head *bh);
 extern int brelse(struct gfs2_buffer_head *bh);
 
-#define bmodified(bh) do { bh->b_changed = 1; } while(0)
+#define bmodified(bh) do { bh->b_modified = 1; } while(0)
 
 #define bget_generic(bl, num, find, read) __bget_generic(bl, num, find, read, \
 							 __LINE__, \
@@ -700,7 +700,6 @@ extern void gfs2_leaf_print(struct gfs2_leaf *lf);
 extern void gfs2_ea_header_print(struct gfs2_ea_header *ea, char *name);
 extern void gfs2_log_header_print(struct gfs2_log_header *lh);
 extern void gfs2_log_descriptor_print(struct gfs2_log_descriptor *ld);
-extern void gfs2_inum_range_print(struct gfs2_inum_range *ir);
 extern void gfs2_statfs_change_print(struct gfs2_statfs_change *sc);
 extern void gfs2_quota_change_print(struct gfs2_quota_change *qc);
 
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index 0d65928..ca7bf09 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -131,7 +131,7 @@ int ji_update(struct gfs2_sbd *sdp)
 	int i;
 
 	if(!ip) {
-		log_crit("Journal inode not found.\n");
+		log_crit("Journal index inode not found.\n");
 		return -1;
 	}
 


More information about the cluster-commits mailing list