Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitdiff... Commit: 68f7f4867f02a29433c3ccdf39664a29d624ff43 Parent: d39dde5bacd8e8c11d4d202b04236b520bf6a660 Author: Bob Peterson rpeterso@redhat.com AuthorDate: Thu Aug 25 10:49:36 2011 -0500 Committer: Bob Peterson rpeterso@redhat.com CommitterDate: Mon Aug 29 12:56:29 2011 -0500
fsck.gfs2: Speed up rangecheck functions
This patch speeds up the block rangecheck functions by passing the block type in as an integer rather than a translated string constant. The translation functions were a bit costly.
rhbz#675723 --- gfs2/fsck/pass1.c | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c index 8db8579..9929301 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -1052,9 +1052,14 @@ static int invalidate_eattr_leaf(struct gfs2_inode *ip, uint64_t block, * be trusted. Thus it needs to be in a separate loop. * Returns: 0 if good range, otherwise != 0 */ +enum b_types { btype_meta, btype_leaf, btype_data, btype_ieattr, btype_eattr}; +const char *btypes[5] = { + "metadata", "leaf", "data", "indirect extended attribute", + "extended attribute" }; + static int rangecheck_block(struct gfs2_inode *ip, uint64_t block, - struct gfs2_buffer_head **bh, - const char *btype, void *private) + struct gfs2_buffer_head **bh, enum b_types btype, + void *private) { long *bad_pointers = (long *)private; uint8_t q; @@ -1063,7 +1068,7 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block, (*bad_pointers)++; log_info( _("Bad %s block pointer (invalid or out of range " "#%ld) found in inode %lld (0x%llx).\n"), - btype, *bad_pointers, + btypes[btype], *bad_pointers, (unsigned long long)ip->i_di.di_num.no_addr, (unsigned long long)ip->i_di.di_num.no_addr); if ((*bad_pointers) <= BAD_POINTER_TOLERANCE) @@ -1077,7 +1082,7 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block, (*bad_pointers)++; log_info( _("Duplicated %s block pointer (violation %ld, block" " %lld (0x%llx)) found in inode %lld (0x%llx).\n"), - btype, *bad_pointers, + btypes[btype], *bad_pointers, (unsigned long long)block, (unsigned long long)block, (unsigned long long)ip->i_di.di_num.no_addr, (unsigned long long)ip->i_di.di_num.no_addr); @@ -1093,36 +1098,33 @@ static int rangecheck_metadata(struct gfs2_inode *ip, uint64_t block, struct gfs2_buffer_head **bh, int h, void *private) { - return rangecheck_block(ip, block, bh, _("metadata"), private); + return rangecheck_block(ip, block, bh, btype_meta, private); }
static int rangecheck_leaf(struct gfs2_inode *ip, uint64_t block, void *private) { - return rangecheck_block(ip, block, NULL, _("leaf"), private); + return rangecheck_block(ip, block, NULL, btype_leaf, private); }
static int rangecheck_data(struct gfs2_inode *ip, uint64_t block, void *private) { - return rangecheck_block(ip, block, NULL, _("data"), private); + return rangecheck_block(ip, block, NULL, btype_data, private); }
static int rangecheck_eattr_indir(struct gfs2_inode *ip, uint64_t block, uint64_t parent, struct gfs2_buffer_head **bh, void *private) { - return rangecheck_block(ip, block, NULL, - _("indirect extended attribute"), - private); + return rangecheck_block(ip, block, NULL, btype_ieattr, private); }
static int rangecheck_eattr_leaf(struct gfs2_inode *ip, uint64_t block, uint64_t parent, struct gfs2_buffer_head **bh, void *private) { - return rangecheck_block(ip, block, NULL, _("extended attribute"), - private); + return rangecheck_block(ip, block, NULL, btype_eattr, private); }
struct metawalk_fxns rangecheck_fxns = {
cluster-commits@lists.fedorahosted.org