Commit 23e5671a authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Bob Peterson

gfs2: Fix extended attribute readahead optimization

Commit 39b0555f didn't check for a failing bio_add_page in
gfs2_submit_bhs. This could cause I/O requests to get lost, and the
affected buffer heads to stay locked forever.  Fix that by submitting
the current bio and allocating another one when bio_add_page fails.  (It
is guaranteed that we can at least add one page to a bio.)
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
parent 1c185c02
...@@ -216,23 +216,26 @@ static void gfs2_meta_read_endio(struct bio *bio) ...@@ -216,23 +216,26 @@ static void gfs2_meta_read_endio(struct bio *bio)
static void gfs2_submit_bhs(int op, int op_flags, struct buffer_head *bhs[], static void gfs2_submit_bhs(int op, int op_flags, struct buffer_head *bhs[],
int num) int num)
{ {
struct buffer_head *bh = bhs[0]; while (num > 0) {
struct bio *bio; struct buffer_head *bh = *bhs;
int i; struct bio *bio;
if (!num) bio = bio_alloc(GFP_NOIO, num);
return; bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
bio->bi_bdev = bh->b_bdev;
bio = bio_alloc(GFP_NOIO, num); while (num > 0) {
bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); bh = *bhs;
bio->bi_bdev = bh->b_bdev; if (!bio_add_page(bio, bh->b_page, bh->b_size, bh_offset(bh))) {
for (i = 0; i < num; i++) { BUG_ON(bio->bi_iter.bi_size == 0);
bh = bhs[i]; break;
bio_add_page(bio, bh->b_page, bh->b_size, bh_offset(bh)); }
bhs++;
num--;
}
bio->bi_end_io = gfs2_meta_read_endio;
bio_set_op_attrs(bio, op, op_flags);
submit_bio(bio);
} }
bio->bi_end_io = gfs2_meta_read_endio;
bio_set_op_attrs(bio, op, op_flags);
submit_bio(bio);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment