History

block: refactor __bio_iov_bvec_add_pages

Return early on error, and add an unlikely annotation for that case.

Christoph Hellwig committed 7 years ago

Commit a10584c1 parent 8a96a0e1 file · +9 −10Browse files

Unified · Split

block/bio.c+9−10
@@ -873,20 +873,19 @@ static int __bio_iov_bvec_add_pages(struct bio *bio, struct iov_iter *iter) · 872 unmodified lines
873873 len = min_t(size_t, bv->bv_len - iter->iov_offset, iter->count);
874874 size = bio_add_page(bio, bv->bv_page, len,
875875 bv->bv_offset + iter->iov_offset);
876− if (size == len) {
877− if (!bio_flagged(bio, BIO_NO_PAGE_REF)) {
878− struct page *page;
879− int i;
876+ if (unlikely(size != len))
877+ return -EINVAL;
880878
881− mp_bvec_for_each_page(page, bv, i)
882− get_page(page);
883− }
879+ if (!bio_flagged(bio, BIO_NO_PAGE_REF)) {
880+ struct page *page;
881+ int i;
884882
885− iov_iter_advance(iter, size);
886− return 0;
883+ mp_bvec_for_each_page(page, bv, i)
884+ get_page(page);
887885 }
888886
889− return -EINVAL;
887+ iov_iter_advance(iter, size);
888+ return 0;
890889 }
891890
892891 #define PAGE_PTRS_PER_BVEC (sizeof(struct bio_vec) / sizeof(struct page *))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t