[Cluster-devel] [gfs2-utils PATCH 4/7] fsck.gfs2: Make _fsck_bitmap_set not send a return code

Bob Peterson rpeterso at redhat.com
Wed Jun 22 19:26:49 UTC 2016


Most places in fsck.gfs2 set the bitmap and don't bother to check
the return code from function fsck_bitmap_set. Only the call from
pass1 needs the return code. So sending back the return code is a
waste of time. We marginally increase the function efficiency by
eliminating the return value, but more importantly, this paves the
way for future patches to make fsck.gfs2 faster.

Signed-off-by: Bob Peterson <rpeterso at redhat.com>
---
 gfs2/fsck/metawalk.c | 50 ++++-------------------------------------------
 gfs2/fsck/metawalk.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++-----
 gfs2/fsck/pass1.c    |  9 +++++++--
 3 files changed, 61 insertions(+), 53 deletions(-)

diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 651bd79..6259a66 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -166,59 +166,17 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
 /*
  * _fsck_bitmap_set - Mark a block in the bitmap, and adjust free space.
  */
-int _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
-		     const char *btype, int mark,
-		     int error_on_dinode, const char *caller, int fline)
+void _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
+		      const char *btype, int mark,
+		      int error_on_dinode, const char *caller, int fline)
 {
 	int error;
-	static int prev_ino_addr = 0;
-	static int prev_mark = 0;
-	static int prevcount = 0;
-	static const char *prev_caller = NULL;
-
-	if (print_level >= MSG_DEBUG) {
-		if ((ip->i_di.di_num.no_addr == prev_ino_addr) &&
-		    (mark == prev_mark) && caller == prev_caller) {
-			log_info("(0x%llx) ", (unsigned long long)bblock);
-			prevcount++;
-			if (prevcount > 10) {
-				log_info("\n");
-				prevcount = 0;
-			}
-		/* I'm circumventing the log levels here on purpose to make the
-		   output easier to debug. */
-		} else if (ip->i_di.di_num.no_addr == bblock) {
-			if (prevcount) {
-				log_info("\n");
-				prevcount = 0;
-			}
-			printf( _("(%s:%d) %s inode found at block "
-				  "(0x%llx): marking as '%s'\n"), caller, fline,
-			       btype,
-			       (unsigned long long)ip->i_di.di_num.no_addr,
-			       block_type_string(mark));
 
-		} else {
-			if (prevcount) {
-				log_info("\n");
-				prevcount = 0;
-			}
-			printf( _("(%s:%d) inode (0x%llx) references %s block"
-				  " (0x%llx): marking as '%s'\n"),
-			       caller, fline,
-			       (unsigned long long)ip->i_di.di_num.no_addr,
-			       btype, (unsigned long long)bblock,
-			       block_type_string(mark));
-		}
-		prev_ino_addr = ip->i_di.di_num.no_addr;
-		prev_mark = mark;
-		prev_caller = caller;
-	}
+	_fsck_bitmap_set_dbg(ip, bblock, btype, mark, caller, fline);
 	error = check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, bblock,
 				   error_on_dinode, mark);
 	if (error < 0)
 		log_err(_("This block is not represented in the bitmap.\n"));
-	return error;
 }
 
 struct duptree *dupfind(uint64_t block)
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index 119efee..5410775 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -19,9 +19,9 @@ extern int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
 extern int check_leaf(struct gfs2_inode *ip, int lindex,
 		      struct metawalk_fxns *pass, uint64_t *leaf_no,
 		      struct gfs2_leaf *leaf, int *ref_count);
-extern int _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
-			    const char *btype, int mark, int error_on_dinode,
-			    const char *caller, int line);
+extern void _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
+			     const char *btype, int mark, int error_on_dinode,
+			     const char *caller, int line);
 extern int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
 			      uint64_t blk, int error_on_dinode,
 			      int new_state);
@@ -29,12 +29,57 @@ extern struct duptree *dupfind(uint64_t block);
 extern struct gfs2_inode *fsck_system_inode(struct gfs2_sbd *sdp,
 					    uint64_t block);
 
+static inline void _fsck_bitmap_set_dbg(struct gfs2_inode *ip, uint64_t bblock,
+					const char *btype, int mark,
+					const char *caller, int fline)
+{
+	static int prev_ino_addr = 0;
+	static int prev_mark = 0;
+	static int prevcount = 0;
+	static const char *prev_caller = NULL;
+
+	if (print_level < MSG_DEBUG)
+		return;
+
+	if ((ip->i_di.di_num.no_addr == prev_ino_addr) &&
+	    (mark == prev_mark) && caller == prev_caller) {
+		log_info("(0x%llx) ", (unsigned long long)bblock);
+		prevcount++;
+		if (prevcount > 10) {
+			log_info("\n");
+			prevcount = 0;
+		}
+		/* I'm circumventing the log levels here on purpose to make the
+		   output easier to debug. */
+	} else if (ip->i_di.di_num.no_addr == bblock) {
+		if (prevcount) {
+			log_info("\n");
+			prevcount = 0;
+		}
+		printf( _("(%s:%d) %s inode found at block (0x%llx): "
+			  "marking as '%s'\n"), caller, fline, btype,
+			(unsigned long long)ip->i_di.di_num.no_addr,
+			block_type_string(mark));
+	} else {
+		if (prevcount) {
+			log_info("\n");
+			prevcount = 0;
+		}
+		printf( _("(%s:%d) inode (0x%llx) references %s block"
+			  " (0x%llx): marking as '%s'\n"), caller, fline,
+			(unsigned long long)ip->i_di.di_num.no_addr,
+			btype, (unsigned long long)bblock,
+			block_type_string(mark));
+	}
+	prev_ino_addr = ip->i_di.di_num.no_addr;
+	prev_mark = mark;
+	prev_caller = caller;
+}
+
 #define is_duplicate(dblock) ((dupfind(dblock)) ? 1 : 0)
 
 #define fsck_bitmap_set(ip, b, bt, m) \
 	_fsck_bitmap_set(ip, b, bt, m, 0, __FUNCTION__, __LINE__)
-#define fsck_bitmap_set_noino(ip, b, bt, m) \
-	_fsck_bitmap_set(ip, b, bt, m, 1, __FUNCTION__, __LINE__)
 enum meta_check_rc {
 	meta_error = -1,
 	meta_is_good = 0,
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 112b68e..2a3fbde 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -115,8 +115,13 @@ static int _fsck_blockmap_set(struct gfs2_inode *ip, uint64_t bblock,
 			      const char *btype, int mark, int error_on_dinode,
 			      const char *caller, int fline)
 {
-	int error = _fsck_bitmap_set(ip, bblock, btype, mark, error_on_dinode,
-				     caller, fline);
+	int error;
+
+	_fsck_bitmap_set_dbg(ip, bblock, btype, mark, caller, fline);
+	error = check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, bblock,
+				   error_on_dinode, mark);
+	if (error < 0)
+		log_err(_("This block is not represented in the bitmap.\n"));
 	if (error)
 		return error;
 
-- 
2.5.5




More information about the Cluster-devel mailing list