Commit d2190452 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Yifan Qiao
Browse files

block: fix pin count management when merging same-page segments

mainline inclusion
from mainline-v6.6-rc1
commit 5905afc2
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IANSAC

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5905afc2c7bb713d52c7c7585565feecbb686b44



--------------------------------

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: d1916c86 ("block: move same page handling from __bio_add_pc_page to the callers")
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20230905124731.328255-1-hch@lst.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Conflicts:
	block/blk-map.c
[Context differences]
Signed-off-by: default avatarYifan Qiao <qiaoyifan4@huawei.com>
parent 02994a9b
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -283,12 +283,11 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter,
					n = bytes;

				if (!bio_add_hw_page(rq->q, bio, page, n, offs,
						     max_sectors, &same_page)) {
					if (same_page)
						put_page(page);
						     max_sectors, &same_page))
					break;
				}

				if (same_page)
					put_page(page);
				added += n;
				bytes -= n;
				offs = 0;