Skip to content

Commit b99b98d

Browse files
committed
GFS2: Move readahead of metadata during deallocation into its own function
Move the recently added readahead of the indirect pointer tree during deallocation into its own function in order that we can use it elsewhere in the future. Also this fixes the resetting of the "first" variable in the original patch. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 9ae3242 commit b99b98d

1 file changed

Lines changed: 26 additions & 19 deletions

File tree

‎fs/gfs2/bmap.c‎

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,30 @@ static inline __be64 *metapointer(unsigned int height, const struct metapath *mp
269269
return ((__be64 *)(bh->b_data + head_size)) + mp->mp_list[height];
270270
}
271271

272+
static void gfs2_metapath_ra(struct gfs2_glock *gl,
273+
const struct buffer_head *bh, const __be64 *pos)
274+
{
275+
struct buffer_head *rabh;
276+
const __be64 *endp = (const __be64 *)(bh->b_data + bh->b_size);
277+
const __be64 *t;
278+
279+
for (t = pos; t < endp; t++) {
280+
if (!*t)
281+
continue;
282+
283+
rabh = gfs2_getbuf(gl, be64_to_cpu(*t), CREATE);
284+
if (trylock_buffer(rabh)) {
285+
if (!buffer_uptodate(rabh)) {
286+
rabh->b_end_io = end_buffer_read_sync;
287+
submit_bh(READA | REQ_META, rabh);
288+
continue;
289+
}
290+
unlock_buffer(rabh);
291+
}
292+
brelse(rabh);
293+
}
294+
}
295+
272296
/**
273297
* lookup_metapath - Walk the metadata tree to a specific point
274298
* @ip: The inode
@@ -843,7 +867,7 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh,
843867
{
844868
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
845869
struct buffer_head *bh = NULL;
846-
__be64 *top, *bottom, *t2;
870+
__be64 *top, *bottom;
847871
u64 bn;
848872
int error;
849873
int mh_size = sizeof(struct gfs2_meta_header);
@@ -872,26 +896,9 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh,
872896
goto out;
873897

874898
if (height < ip->i_height - 1) {
875-
struct buffer_head *rabh;
876899

877-
for (t2 = top; t2 < bottom; t2++, first = 0) {
878-
if (!*t2)
879-
continue;
900+
gfs2_metapath_ra(ip->i_gl, bh, top);
880901

881-
bn = be64_to_cpu(*t2);
882-
rabh = gfs2_getbuf(ip->i_gl, bn, CREATE);
883-
if (trylock_buffer(rabh)) {
884-
if (buffer_uptodate(rabh)) {
885-
unlock_buffer(rabh);
886-
brelse(rabh);
887-
continue;
888-
}
889-
rabh->b_end_io = end_buffer_read_sync;
890-
submit_bh(READA | REQ_META, rabh);
891-
continue;
892-
}
893-
brelse(rabh);
894-
}
895902
for (; top < bottom; top++, first = 0) {
896903
if (!*top)
897904
continue;

0 commit comments

Comments
 (0)