fsck.gfs2: Fetch directory inodes early in pass2()
PATCH 1/1 fsck.gfs2: Fetch directory inodes early in pass2()
pass2() reads directory inodes twice: once indirectly through check_dir() and again shortly afterwards to perform other checks on the inode. To remove the duplicate reads, this patch moves the inode loading outside of check_dir() and keeps it around for the further checks. In order to avoid adding a fsck_inode_put() at each return point, and to remove some levels of nesting, the directory checking has been moved into a new pass2_check_dir() function which accepts the inode as an argument. pass2() now fetches the inode, calls pass2_check_dir() and then puts the inode. The patch also adds failure checking for the fsck_load_inode() calls.
Resolves: rhbz#1154726
--- gfs2/fsck/metawalk.c | 17 ++-- gfs2/fsck/metawalk.h | 2 +- gfs2/fsck/pass2.c | 243 ++++++++++++++++++++++++++------------------------- 3 files changed, 136 insertions(+), 126 deletions(-)
gfs2/fsck/metawalk.c +10 -7
@@ -1697,14 +1697,11 @@ int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,return error; } -int check_dir (struct gfs2_sbd *sdp,uint64_t block,struct metawalk_fxns *pass) +int check_dir (struct gfs2_sbd *sdp,struct gfs2_inode *ip,struct metawalk_fxns *pass) { -struct gfs2_inode *ip;int error =0 ;struct alloc_state as; - ip =fsck_load_inode (sdp, block); -astate_save (ip, &as);if (ip->i_di.di_flags &GFS2_DIF_EXHASH )
@@ -1718,7 +1715,6 @@ int check_dir(struct gfs2_sbd *sdp, uint64_t block, struct metawalk_fxns *pass)if (astate_changed (ip, &as))reprocess_inode (ip,_ ("Current" )); -fsck_inode_put (&ip);/* does a brelse */ return error; }
@@ -1750,6 +1746,7 @@ int remove_dentry_from_dir(struct gfs2_sbd *sdp, uint64_t dir, uint64_t dentryblock) {struct metawalk_fxns remove_dentry_fxns = {0 }; +struct gfs2_inode *ip;uint8_t q;int error;
@@ -1769,10 +1766,16 @@ int remove_dentry_from_dir(struct gfs2_sbd *sdp, uint64_t dir,log_info (_ ("Parent block is not an inode...ignoring\n" ));return 1 ; } + + ip =fsck_load_inode (sdp, dir); +if (ip ==NULL ) { + stack; +return -1 ; + }/* Need to run check_dir with a private var of dentryblock, * and fxns that remove that dentry if found */ - error =check_dir (sdp, dir, &remove_dentry_fxns); - + error =check_dir (sdp, ip, &remove_dentry_fxns); +fsck_inode_put (&ip);return error; }
gfs2/fsck/metawalk.h +1 -1
@@ -12,7 +12,7 @@ extern int check_inode_eattr(struct gfs2_inode *ip, struct metawalk_fxns *pass);extern int check_metatree (struct gfs2_inode *ip,struct metawalk_fxns *pass);extern int check_leaf_blks (struct gfs2_inode *ip,struct metawalk_fxns *pass); -extern int check_dir (struct gfs2_sbd *sdp,uint64_t block, +extern int check_dir (struct gfs2_sbd *sdp,struct gfs2_inode *ip,struct metawalk_fxns *pass);extern int check_linear_dir (struct gfs2_inode *ip,struct gfs2_buffer_head *bh,struct metawalk_fxns *pass);
gfs2/fsck/pass2.c +125 -118
288 lines not on this page · raw message
Signature · 1 line
1.8.3.1