Commit a10584c3 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: refactor __bio_iov_bvec_add_pages

Return early on error, and add an unlikely annotation for that case.
Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 8a96a0e4
...@@ -873,20 +873,19 @@ static int __bio_iov_bvec_add_pages(struct bio *bio, struct iov_iter *iter) ...@@ -873,20 +873,19 @@ static int __bio_iov_bvec_add_pages(struct bio *bio, struct iov_iter *iter)
len = min_t(size_t, bv->bv_len - iter->iov_offset, iter->count); len = min_t(size_t, bv->bv_len - iter->iov_offset, iter->count);
size = bio_add_page(bio, bv->bv_page, len, size = bio_add_page(bio, bv->bv_page, len,
bv->bv_offset + iter->iov_offset); bv->bv_offset + iter->iov_offset);
if (size == len) { if (unlikely(size != len))
if (!bio_flagged(bio, BIO_NO_PAGE_REF)) { return -EINVAL;
struct page *page;
int i;
mp_bvec_for_each_page(page, bv, i) if (!bio_flagged(bio, BIO_NO_PAGE_REF)) {
get_page(page); struct page *page;
} int i;
iov_iter_advance(iter, size); mp_bvec_for_each_page(page, bv, i)
return 0; get_page(page);
} }
return -EINVAL; iov_iter_advance(iter, size);
return 0;
} }
#define PAGE_PTRS_PER_BVEC (sizeof(struct bio_vec) / sizeof(struct page *)) #define PAGE_PTRS_PER_BVEC (sizeof(struct bio_vec) / sizeof(struct page *))
......
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