Skip to content

Commit 325347d

Browse files
keithbuschaxboe
authored andcommitted
block: ensure iov_iter advances for added pages
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]>
1 parent 1042124 commit 325347d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

block/bio.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
12111211
ssize_t size, left;
12121212
unsigned len, i;
12131213
size_t offset;
1214+
int ret = 0;
12141215

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

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

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

12471247
if (ret) {
12481248
bio_put_pages(pages + i, left, offset);
1249-
return ret;
1249+
break;
12501250
}
12511251
offset = 0;
12521252
}
12531253

1254-
iov_iter_advance(iter, size);
1255-
return 0;
1254+
iov_iter_advance(iter, size - left);
1255+
return ret;
12561256
}
12571257

12581258
/**

0 commit comments

Comments
 (0)