Skip to content

Commit

Permalink
block: ensure iov_iter advances for added pages
Browse files Browse the repository at this point in the history
There are cases where a bio may not accept additional pages, and the iov
needs to advance to the last data length that was accepted. The zone
append used to handle this correctly, but was inadvertently broken when
the setup was made common with the normal r/w case.

Fixes: 576ed91 ("block: use bio_add_page in bio_iov_iter_get_pages")
Fixes: c58c007 ("block/bio: remove duplicate append pages code")
Signed-off-by: Keith Busch <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
keithbusch authored and axboe committed Aug 3, 2022
1 parent 1042124 commit 325347d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
ssize_t size, left;
unsigned len, i;
size_t offset;
int ret = 0;

/*
* Move page array up in the allocated memory for the bio vecs as far as
Expand All @@ -1235,7 +1236,6 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)

for (left = size, i = 0; left > 0; left -= len, i++) {
struct page *page = pages[i];
int ret;

len = min_t(size_t, PAGE_SIZE - offset, left);
if (bio_op(bio) == REQ_OP_ZONE_APPEND)
Expand All @@ -1246,13 +1246,13 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)

if (ret) {
bio_put_pages(pages + i, left, offset);
return ret;
break;
}
offset = 0;
}

iov_iter_advance(iter, size);
return 0;
iov_iter_advance(iter, size - left);
return ret;
}

/**
Expand Down

0 comments on commit 325347d

Please sign in to comment.