gfs2-utils: master - fsck.gfs2: pass1 should use gfs2_special_add not _set

Bob Peterson rpeterso at fedoraproject.org
Tue Jan 26 21:09:27 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitdiff;h=582c151afc8754011e494ed8e6ee4b37f79a353d
Commit:        582c151afc8754011e494ed8e6ee4b37f79a353d
Parent:        3eb488449add676e9c003de715419fa266e06320
Author:        Bob Peterson <bob at ganesha.peterson>
AuthorDate:    Thu Jan 21 14:26:17 2010 -0600
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Tue Jan 26 15:09:45 2010 -0600

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 f33ee27..1ea071e 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -366,7 +366,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 "
@@ -496,7 +496,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 2b752e4..a474580 100644
--- a/gfs2/libgfs2/block_list.c
+++ b/gfs2/libgfs2/block_list.c
@@ -81,12 +81,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));
@@ -95,6 +93,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 86db414..0452e47 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