cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [gfs2-utils PATCH 4/7] fsck.gfs2: Make _fsck_bitmap_set not send a return code
Date: Wed, 22 Jun 2016 14:26:49 -0500	[thread overview]
Message-ID: <715bb5ead3ff627e9fc85dc481a0f9cc4b1b9685.1466623303.git.rpeterso@redhat.com> (raw)
In-Reply-To: <cover.1466623302.git.rpeterso@redhat.com>

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@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



  parent reply	other threads:[~2016-06-22 19:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-22 19:26 [Cluster-devel] [gfs2-utils PATCH 0/7] fsck.gfs2 performance improvements Bob Peterson
2016-06-22 19:26 ` [Cluster-devel] [gfs2-utils PATCH 1/7] fsck.gfs2: Don't bother to pass bl blockmap pointer Bob Peterson
2016-06-23 12:45   ` Andrew Price
2016-06-22 19:26 ` [Cluster-devel] [gfs2-utils PATCH 2/7] fsck.gfs2: Remember the previous rgrp pointer for speed Bob Peterson
2016-06-22 19:26 ` [Cluster-devel] [gfs2-utils PATCH 3/7] fsck.gfs2: Don't set gfs1rg pointer unless we need to Bob Peterson
2016-06-22 19:26 ` Bob Peterson [this message]
2016-06-22 19:26 ` [Cluster-devel] [gfs2-utils PATCH 5/7] fsck.gfs2: convert fsck_bitmap_set to a macro Bob Peterson
2016-06-22 19:26 ` [Cluster-devel] [gfs2-utils PATCH 6/7] fsck.gfs2: Speed up function bitmap_type Bob Peterson
2016-06-22 19:26 ` [Cluster-devel] [gfs2-utils PATCH 7/7] fsck.gfs2: Make pass2 go by directory rbtree for performance Bob Peterson
2016-06-27 12:24 ` [Cluster-devel] [gfs2-utils PATCH 0/7] fsck.gfs2 performance improvements Steven Whitehouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=715bb5ead3ff627e9fc85dc481a0f9cc4b1b9685.1466623303.git.rpeterso@redhat.com \
    --to=rpeterso@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).