cluster: RHEL56 - fsck.gfs2: pass1 should use gfs2_special_add not _set

Bob Peterson rpeterso at fedoraproject.org
Sat Apr 10 04:52:52 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=4d41d1c30a8a80aef09abf8fb18facb3f68ea5bb
Commit:        4d41d1c30a8a80aef09abf8fb18facb3f68ea5bb
Parent:        cb66bfe79239309ace78c06f3548fb402be4e201
Author:        Bob Peterson <bob at ganesha.peterson>
AuthorDate:    Thu Jan 21 14:26:17 2010 -0600
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Fri Apr 9 23:33:16 2010 -0500

fsck.gfs2: pass1 should use gfs2_special_add not _set

Since pass1 traverses the file system sequentially by block,
it can safely assume blocks it adds to the special_blocks list
are not already on it.  Therefore, it can safely add those
blocks to the list and avoid checking for it already being
there.  This saves a tiny bit of time, which may seem
trivial but when there are a million inodes on the list, the
time saved is worth it.

rhbz#455300
---
 gfs2/fsck/pass1.c         |    4 ++--
 gfs2/libgfs2/block_list.c |   11 ++++++++---
 gfs2/libgfs2/libgfs2.h    |    3 ++-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index a3029d7..9b7bd9c 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -378,7 +378,7 @@ static int finish_eattr_indir(struct gfs2_inode *ip, int leaf_pointers,
 		   (unsigned long long)ip->i_di.di_num.no_addr);
 	/* Mark the inode as having an eattr in the block map
 	   so pass1c can check it. */
-	gfs2_special_set(&ip->i_sbd->eattr_blocks, ip->i_di.di_num.no_addr);
+	gfs2_special_add(&ip->i_sbd->eattr_blocks, ip->i_di.di_num.no_addr);
 	if (!leaf_pointer_errors)
 		return 0;
 	log_err( _("Inode %lld (0x%llx) has recoverable indirect "
@@ -508,7 +508,7 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
 		     "block(s) attached.\n"),
 		   (unsigned long long)ip->i_di.di_num.no_addr,
 		   (unsigned long long)ip->i_di.di_num.no_addr);
-	gfs2_special_set(&sdp->eattr_blocks, ip->i_di.di_num.no_addr);
+	gfs2_special_add(&sdp->eattr_blocks, ip->i_di.di_num.no_addr);
 	if(gfs2_check_range(sdp, block)) {
 		log_warn( _("Inode #%llu (0x%llx): Extended Attribute leaf "
 			    "block #%llu (0x%llx) is out of range.\n"),
diff --git a/gfs2/libgfs2/block_list.c b/gfs2/libgfs2/block_list.c
index 153ed9a..fdf7251 100644
--- a/gfs2/libgfs2/block_list.c
+++ b/gfs2/libgfs2/block_list.c
@@ -91,12 +91,10 @@ struct special_blocks *blockfind(struct special_blocks *blist, uint64_t num)
 	return NULL;
 }
 
-void gfs2_special_set(struct special_blocks *blocklist, uint64_t block)
+void gfs2_special_add(struct special_blocks *blocklist, uint64_t block)
 {
 	struct special_blocks *b;
 
-	if (blockfind(blocklist, block))
-		return;
 	b = malloc(sizeof(struct special_blocks));
 	if (b) {
 		memset(b, 0, sizeof(*b));
@@ -105,6 +103,13 @@ void gfs2_special_set(struct special_blocks *blocklist, uint64_t block)
 	}
 }
 
+void gfs2_special_set(struct special_blocks *blocklist, uint64_t block)
+{
+	if (blockfind(blocklist, block))
+		return;
+	gfs2_special_add(blocklist, block);
+}
+
 void gfs2_special_clear(struct special_blocks *blocklist, uint64_t block)
 {
 	struct special_blocks *b;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 726dd86..4bd7878 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -303,10 +303,11 @@ enum gfs2_mark_block {
 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);
+extern void gfs2_special_add(struct special_blocks *blocklist, uint64_t block);
 extern void gfs2_special_set(struct special_blocks *blocklist, uint64_t block);
 extern void gfs2_special_free(struct special_blocks *blist);
 extern int gfs2_blockmap_set(struct gfs2_sbd *sdp, struct gfs2_bmap *il,
-			  uint64_t block, enum gfs2_mark_block mark);
+			     uint64_t block, enum gfs2_mark_block mark);
 extern void gfs2_special_clear(struct special_blocks *blocklist,
 			       uint64_t block);
 /* gfs2_block_unmark clears ONE mark for the given block */


More information about the cluster-commits mailing list