Skip to content

Commit 5905afc

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: fix pin count management when merging same-page segments
There is no need to unpin the added page when adding it to the bio fails as that is done by the loop below. Instead we want to unpin it when adding a single page to the bio more than once as bio_release_pages will only unpin it once. Fixes: d1916c8 ("block: move same page handling from __bio_add_pc_page to the callers") Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Link: https://lore.kernel.org/r/20230905124731.328255-1-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 5a26e45 commit 5905afc

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

block/blk-map.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,11 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter,
315315
n = bytes;
316316

317317
if (!bio_add_hw_page(rq->q, bio, page, n, offs,
318-
max_sectors, &same_page)) {
319-
if (same_page)
320-
bio_release_page(bio, page);
318+
max_sectors, &same_page))
321319
break;
322-
}
323320

321+
if (same_page)
322+
bio_release_page(bio, page);
324323
bytes -= n;
325324
offs = 0;
326325
}

0 commit comments

Comments
 (0)