From: Bob Peterson <rpete...@redhat.com> This is a small performance improvement. Rather than having function dir_split_leaf read in the leaf to be split, this patch lets the buffer_head to be passed in from the calling function, which has it read in anyway.
rhbz#902920 --- gfs2/libgfs2/fs_ops.c | 9 ++++----- gfs2/libgfs2/libgfs2.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c index c1bd6db..bca622a 100644 --- a/gfs2/libgfs2/fs_ops.c +++ b/gfs2/libgfs2/fs_ops.c @@ -916,9 +916,10 @@ void gfs2_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out) } } -void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, uint64_t leaf_no) +void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, uint64_t leaf_no, + struct gfs2_buffer_head *obh) { - struct gfs2_buffer_head *nbh, *obh; + struct gfs2_buffer_head *nbh; struct gfs2_leaf *nleaf, *oleaf; struct gfs2_dirent *dent, *prev = NULL, *next = NULL, *new; uint32_t start, len, half_len, divider; @@ -942,7 +943,6 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, uint64_t leaf_no) nleaf = (struct gfs2_leaf *)nbh->b_data; nleaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE); - obh = bread(dip->i_sbd, leaf_no); oleaf = (struct gfs2_leaf *)obh->b_data; len = 1 << (dip->i_di.di_depth - be16_to_cpu(oleaf->lf_depth)); @@ -1027,7 +1027,6 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, uint64_t leaf_no) bmodified(dip->i_bh); bmodified(obh); /* Need to do this in case nothing was moved */ - brelse(obh); bmodified(nbh); brelse(nbh); } @@ -1174,8 +1173,8 @@ restart: if (dirent_alloc(dip, bh, len, &dent)) { if (be16_to_cpu(leaf->lf_depth) < dip->i_di.di_depth) { + dir_split_leaf(dip, lindex, leaf_no, bh); brelse(bh); - dir_split_leaf(dip, lindex, leaf_no); goto restart; } else if (dip->i_di.di_depth < GFS2_DIR_MAX_DEPTH) { diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index 4b012ab..90a131a 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -470,7 +470,7 @@ extern void gfs2_get_leaf_nr(struct gfs2_inode *dip, uint32_t index, uint64_t *leaf_out); extern void gfs2_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out); extern void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex, - uint64_t leaf_no); + uint64_t leaf_no, struct gfs2_buffer_head *obh); extern void gfs2_free_block(struct gfs2_sbd *sdp, uint64_t block); extern int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t block); extern int gfs2_get_leaf(struct gfs2_inode *dip, uint64_t leaf_no, -- 1.7.11.7