Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=f150dda8961cf6... Commit: f150dda8961cf6b535da786eb6e9aa5a75a7349f Parent: 0c93cdb7378757e954d635e114e37a62a888b17e Author: Bob Peterson rpeterso@redhat.com AuthorDate: Fri Jan 6 14:21:35 2012 -0600 Committer: Bob Peterson rpeterso@redhat.com CommitterDate: Fri Apr 5 06:25:00 2013 -0700
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#877150 --- 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 62cc96e..79fd216 100644 --- a/gfs2/fsck/pass1.c +++ b/gfs2/fsck/pass1.c @@ -1040,9 +1040,14 @@ static int invalidate_eattr_leaf(struct gfs2_inode *ip, uint64_t block, * duplicate (for example) until we know if the pointers in general can * be trusted. Thus it needs to be in a separate loop. */ +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; @@ -1051,7 +1056,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) @@ -1065,7 +1070,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); @@ -1081,36 +1086,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 = {