Two fsck_bitmap_set patches
cover Two fsck_bitmap_set patches
Hi,
I posted these two fsck.gfs2 performance patches previously on 22 June as part of a multi-patch set. I split these two patches from the rest, but they only achieve savings together.
The theory behind these two patches is this:
A large file system (in my case 15TB, at 80% full) is going to loop trillions of times, touching the bitmap in memory each time, so the more efficient we can make that, the faster it will go. In my case, it was looping more than 13 trillion times, and as you can tell, making fsck_bitmap_set more efficient did help significantly.
In this case, the savings is probably only significant when verbose mode (-vv option) is not used. The problem is that the fsck_bitmap_set function was checking for verbose mode and passing lots of information into the function, even when it wasn't going to use it. By converting the function into a macro that only checked the value once instead of passing all that information, it avoided doing that 13 trillion times, which resulted in considerable savings.
The first performance patch I sent today allowed pass1 to go from 16h49m44.636s to 15h52m8.912s.
This set of two patches made pass1 go from 15h52m to 14h23m, a savings of 89 minutes: another 9.3 percent speedup from the previous set.
Regards,
Bob Peterson
Red Hat File Systems
---
Bob Peterson (2):
fsck.gfs2: Make _fsck_bitmap_set not send a return code fsck.gfs2: convert fsck_bitmap_set to a macro
gfs2/fsck/metawalk.c | 58 ---------------------------------------------- gfs2/fsck/metawalk.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++------ gfs2/fsck/pass1.c | 22 ++++++++++++++---- 3 files changed, 75 insertions(+), 70 deletions(-)
Signature · 1 line
2.5.5
PATCH 1/2 fsck.gfs2: Make _fsck_bitmap_set not send a return code
Most places in fsck.gfs2 set the bitmap and don't bother to check the return code from function fsck_bitmap_set. Only the call from pass1 needs the return code. So sending back the return code is a waste of time. We marginally increase the function efficiency by eliminating the return value, but more importantly, this paves the way for future patches to make fsck.gfs2 faster.
--- gfs2/fsck/metawalk.c | 50 ++++------------------------------------------- gfs2/fsck/metawalk.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++----- gfs2/fsck/pass1.c | 9 +++++++-- 3 files changed, 61 insertions(+), 53 deletions(-)
gfs2/fsck/metawalk.c +4 -46
@@ -166,59 +166,17 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,/* * _fsck_bitmap_set - Mark a block in the bitmap, and adjust free space. */ -int _fsck_bitmap_set (struct gfs2_inode *ip,uint64_t bblock, -const char *btype,int mark, -int error_on_dinode,const char *caller,int fline) +void _fsck_bitmap_set (struct gfs2_inode *ip,uint64_t bblock, +const char *btype,int mark, +int error_on_dinode,const char *caller,int fline) {int error; -static int prev_ino_addr =0 ; -static int prev_mark =0 ; -static int prevcount =0 ; -static const char *prev_caller =NULL ; - -if (print_level >=MSG_DEBUG ) { -if ((ip->i_di.di_num.no_addr == prev_ino_addr) && - (mark == prev_mark) && caller == prev_caller) { -log_info ("(0x%llx) " , (unsigned long long )bblock); - prevcount++; -if (prevcount >10 ) { -log_info ("\n" ); - prevcount =0 ; - } -/* I'm circumventing the log levels here on purpose to make the -output easier to debug. */ - }else if (ip->i_di.di_num.no_addr == bblock) { -if (prevcount) { -log_info ("\n" ); - prevcount =0 ; - } -printf (_ ("(%s:%d) %s inode found at block " -"(0x%llx): marking as '%s'\n" ), caller, fline, - btype, - (unsigned long long )ip->i_di.di_num.no_addr, -block_type_string (mark)); - }else { -if (prevcount) { -log_info ("\n" ); - prevcount =0 ; - } -printf (_ ("(%s:%d) inode (0x%llx) references %s block" -" (0x%llx): marking as '%s'\n" ), - caller, fline, - (unsigned long long )ip->i_di.di_num.no_addr, - btype, (unsigned long long )bblock, -block_type_string (mark)); - } - prev_ino_addr = ip->i_di.di_num.no_addr; - prev_mark = mark; - prev_caller = caller; - } +_fsck_bitmap_set_dbg (ip, bblock, btype, mark, caller, fline); error =check_n_fix_bitmap (ip->i_sbd, ip->i_rgd, bblock, error_on_dinode, mark);if (error <0 )log_err (_ ("This block is not represented in the bitmap.\n" )); -return error; }struct duptree *dupfind (uint64_t block)
gfs2/fsck/metawalk.h +50 -5
71 lines not on this page · raw message
gfs2/fsck/pass1.c +7 -2
@@ -115,8 +115,13 @@ static int _fsck_blockmap_set(struct gfs2_inode *ip, uint64_t bblock, const char *btype, int mark, int error_on_dinode, const char *caller, int fline) { - int error = _fsck_bitmap_set(ip, bblock, btype, mark, error_on_dinode, - caller, fline); + int error; + +_fsck_bitmap_set_dbg (ip, bblock, btype, mark, caller, fline); + error =check_n_fix_bitmap (ip->i_sbd, ip->i_rgd, bblock, + error_on_dinode, mark); +if (error <0 ) +log_err (_ ("This block is not represented in the bitmap.\n" ));if (error)return error;
Signature · 1 line
2.5.5
PATCH 2/2 fsck.gfs2: convert fsck_bitmap_set to a macro
In reply to Bob PetersonBefore this patch fsck_bitmap_set was a function that was passed in values for function and line number, but it only used them if it was in verbose mode. This patch reorganizes it into a macro that only passes things it needs to.
--- gfs2/fsck/metawalk.c | 16 ---------------- gfs2/fsck/metawalk.h | 22 ++++++++++++++-------- gfs2/fsck/pass1.c | 15 +++++++++++---- 3 files changed, 25 insertions(+), 28 deletions(-)
gfs2/fsck/metawalk.c +0 -16
@@ -163,22 +163,6 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,return 0 ; } -/* -* _fsck_bitmap_set - Mark a block in the bitmap, and adjust free space. -*/ -void _fsck_bitmap_set (struct gfs2_inode *ip,uint64_t bblock, -const char *btype,int mark, -int error_on_dinode,const char *caller,int fline) -{ -int error; - -_fsck_bitmap_set_dbg (ip, bblock, btype, mark, caller, fline); - error =check_n_fix_bitmap (ip->i_sbd, ip->i_rgd, bblock, - error_on_dinode, mark); -if (error <0 ) -log_err (_ ("This block is not represented in the bitmap.\n" )); -} -struct duptree *dupfind (uint64_t block) {struct osi_node *node = dup_blocks.osi_node;
gfs2/fsck/metawalk.h +14 -8
@@ -19,9 +19,6 @@ extern int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,extern int check_leaf (struct gfs2_inode *ip,int lindex,struct metawalk_fxns *pass,uint64_t *leaf_no,struct gfs2_leaf *leaf,int *ref_count); -extern void _fsck_bitmap_set (struct gfs2_inode *ip,uint64_t bblock, -const char *btype,int mark,int error_on_dinode, -const char *caller,int line);extern int check_n_fix_bitmap (struct gfs2_sbd *sdp,struct rgrp_tree *rgd,uint64_t blk,int error_on_dinode,int new_state);
@@ -38,9 +35,6 @@ static inline void _fsck_bitmap_set_dbg(struct gfs2_inode *ip, uint64_t bblock,static int prevcount =0 ;static const char *prev_caller =NULL ; -if (print_level <MSG_DEBUG ) -return ; -if ((ip->i_di.di_num.no_addr == prev_ino_addr) && (mark == prev_mark) && caller == prev_caller) {log_info ("(0x%llx) " , (unsigned long long )bblock);
@@ -78,8 +72,20 @@ static inline void _fsck_bitmap_set_dbg(struct gfs2_inode *ip, uint64_t bblock,#define is_duplicate (dblock) ((dupfind(dblock)) ? 1 : 0) -#define fsck_bitmap_set (ip, b, bt, m) \ - _fsck_bitmap_set(ip, b, bt, m, 0, __FUNCTION__, __LINE__) +#define fsck_bitmap_set (ip, bblock, btype, mark) \ + do { \ + int ret; \ + \ + if (print_level >= MSG_DEBUG) \ + _fsck_bitmap_set_dbg(ip, bblock, btype, mark, \ + __FUNCTION__, __LINE__); \ + ret = check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, bblock, \ + 0, mark); \ + if (ret < 0) \ + log_err(_("This block is not represented in " \ + "the bitmap.\n")); \ + } while (0) +enum meta_check_rc { meta_error =-1 , meta_is_good =0 ,
gfs2/fsck/pass1.c +11 -4
@@ -117,7 +117,8 @@ static int _fsck_blockmap_set(struct gfs2_inode *ip, uint64_t bblock, {int error; -_fsck_bitmap_set_dbg (ip, bblock, btype, mark, caller, fline); +if (print_level >=MSG_DEBUG ) +_fsck_bitmap_set_dbg (ip, bblock, btype, mark, caller, fline); error =check_n_fix_bitmap (ip->i_sbd, ip->i_rgd, bblock, error_on_dinode, mark);if (error <0 )
@@ -130,8 +131,6 @@ static int _fsck_blockmap_set(struct gfs2_inode *ip, uint64_t bblock,#define fsck_blockmap_set (ip, b, bt, m) \ _fsck_blockmap_set(ip, b, bt, m, 0, __FUNCTION__, __LINE__) -#define fsck_blkmap_set_noino (ip, b, bt, m) \ - _fsck_blockmap_set(ip, b, bt, m, 1, __FUNCTION__, __LINE__)/** * delete_block - delete a block associated with an inode
@@ -516,7 +515,15 @@ static int blockmap_set_as_data(struct gfs2_inode *ip, uint64_t block)struct gfs2_buffer_head *bh;struct gfs2_dinode *di; - error =fsck_blkmap_set_noino (ip, block,_ ("data" ),GFS2_BLKST_USED ); +if (print_level >=MSG_DEBUG ) +_fsck_bitmap_set_dbg (ip, block,_ ("data" ),GFS2_BLKST_USED , + __FUNCTION__, __LINE__); + error =check_n_fix_bitmap (ip->i_sbd, ip->i_rgd, block,1 , +GFS2_BLKST_USED ); +if (error <0 ) +log_err (_ ("This block is not represented in the bitmap.\n" )); +if (!error) + error =gfs2_blockmap_set (bl, block,GFS2_BLKST_USED );if (!error)return 0 ;
Signature · 1 line
2.5.5