Skip to content

Commit

Permalink
block: don't allow multiple bio_iov_iter_get_pages calls per bio
Browse files Browse the repository at this point in the history
No caller uses bio_iov_iter_get_pages multiple times on a given bio,
and that funtionality isn't all that useful.  Removing it will make
some future changes a little easier and also simplifies the function
a bit.

Reviewed-by: Ming Lei <[email protected]>
Reviewed-by: Bart Van Assche <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Apr 12, 2019
1 parent a10584c commit 14eacf1
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,10 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
{
const bool is_bvec = iov_iter_is_bvec(iter);
unsigned short orig_vcnt = bio->bi_vcnt;
int ret;

if (WARN_ON_ONCE(bio->bi_vcnt))
return -EINVAL;

/*
* If this is a BVEC iter, then the pages are kernel pages. Don't
Expand All @@ -968,19 +971,13 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
bio_set_flag(bio, BIO_NO_PAGE_REF);

do {
int ret;

if (is_bvec)
ret = __bio_iov_bvec_add_pages(bio, iter);
else
ret = __bio_iov_iter_get_pages(bio, iter);
} while (!ret && iov_iter_count(iter) && !bio_full(bio));

if (unlikely(ret))
return bio->bi_vcnt > orig_vcnt ? 0 : ret;

} while (iov_iter_count(iter) && !bio_full(bio));

return 0;
return bio->bi_vcnt ? 0 : ret;
}

static void submit_bio_wait_endio(struct bio *bio)
Expand Down

0 comments on commit 14eacf1

Please sign in to comment.