commit 4d41d1c30a8a80aef09abf8fb18facb3f68ea5bb Author: Bob Peterson <bob@ganesha.peterson> Date: Thu Jan 21 14:26:17 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 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 */