This is a note to let you know that I've just added the patch titled block: fix pin count management when merging same-page segments to the 6.5-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: block-fix-pin-count-management-when-merging-same-page-segments.patch and it can be found in the queue-6.5 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 5905afc2c7bb713d52c7c7585565feecbb686b44 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig <hch@xxxxxx> Date: Tue, 5 Sep 2023 14:47:31 +0200 Subject: block: fix pin count management when merging same-page segments From: Christoph Hellwig <hch@xxxxxx> commit 5905afc2c7bb713d52c7c7585565feecbb686b44 upstream. 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") Signed-off-by: Christoph Hellwig <hch@xxxxxx> Reviewed-by: Damien Le Moal <dlemoal@xxxxxxxxxx> Link: https://lore.kernel.org/r/20230905124731.328255-1-hch@xxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- block/blk-map.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/block/blk-map.c +++ b/block/blk-map.c @@ -315,12 +315,11 @@ static int bio_map_user_iov(struct reque 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; } Patches currently in stable-queue which might be from hch@xxxxxx are queue-6.5/virtio_pmem-add-the-missing-req_op_write-for-flush-bio.patch queue-6.5/block-move-the-bi_size-overflow-check-in-__bio_try_m.patch queue-6.5/block-move-the-bio_cloned-checks-out-of-__bio_try_me.patch queue-6.5/block-don-t-add-or-resize-partition-on-the-disk-with-genhd_fl_no_part.patch queue-6.5/iomap-remove-large-folio-handling-in-iomap_invalidat.patch queue-6.5/f2fs-don-t-reopen-the-main-block-device-in-f2fs_scan.patch queue-6.5/eventfd-prevent-underflow-for-eventfd-semaphores.patch queue-6.5/block-don-t-allow-enabling-a-cache-on-devices-that-d.patch queue-6.5/nfs-blocklayout-use-the-passed-in-gfp-flags.patch queue-6.5/md-raid5-cache-fix-null-ptr-deref-for-r5l_flush_stri.patch queue-6.5/block-move-the-bi_size-update-out-of-__bio_try_merge.patch queue-6.5/media-dvb-symbol-fixup-for-dvb_attach.patch queue-6.5/blk-flush-fix-rq-flush.seq-for-post-flush-requests.patch queue-6.5/documentation-devices.txt-remove-ttyioc.patch queue-6.5/documentation-devices.txt-remove-ttysioc.patch queue-6.5/block-don-t-pass-a-bio-to-bio_try_merge_hw_seg.patch queue-6.5/block-make-bvec_try_merge_hw_page-non-static.patch queue-6.5/block-move-the-bi_vcnt-check-out-of-__bio_try_merge_.patch queue-6.5/block-fix-pin-count-management-when-merging-same-page-segments.patch queue-6.5/nfsd-da_addr_body-field-missing-in-some-getdeviceinf.patch queue-6.5/bio-integrity-create-multi-page-bvecs-in-bio_integri.patch queue-6.5/block-cleanup-queue_wc_store.patch