Skip to contentSkip to conversation

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

PATCH Applied Christoph Hellwig 3 participants 3 messages Sep 5, 2023 – Sep 6, 2023 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 d1916c86ccdc ("block: move same page handling from __bio_add_pc_page to the callers")
---
 block/blk-map.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
block/blk-map.c +3 -4
index 44d74a30ddac04..8584babf3ea0ca 100644
@@ -315,12 +315,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)
-						bio_release_page(bio, page);
+						     max_sectors, &same_page))
 					break;
-				}
 
+				if (same_page)
+					bio_release_page(bio, page);
 				bytes -= n;
 				offs = 0;
 			}
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Christoph Hellwig

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 d1916c86ccdc ("block: move same page handling from __bio_add_pc_page to the callers")
Signature · 2 lines
Damien Le Moal
Western Digital Research
maintainer Applied
#2 lore raw
In reply to Christoph Hellwig
Quoted 6 lines · Christoph Hellwig

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.

Applied, thanks!

[1/1] block: fix pin count management when merging same-page segments

      commit: 5905afc2c7bb713d52c7c7585565feecbb686b44

Best regards,

Signature · 1 line
Jens Axboe