Patch "bio-integrity: create multi-page bvecs in bio_integrity_add_page()" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    bio-integrity: create multi-page bvecs in bio_integrity_add_page()

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:
     bio-integrity-create-multi-page-bvecs-in-bio_integri.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.



commit 64d0f78d6189ecc6614111a893d4c910c4951958
Author: Jinyoung Choi <j-young.choi@xxxxxxxxxxx>
Date:   Thu Aug 3 11:52:02 2023 +0900

    bio-integrity: create multi-page bvecs in bio_integrity_add_page()
    
    [ Upstream commit 0ece1d649b6dd615925a72bc1824d6b9fa5b998a ]
    
    In general, the bvec data structure consists of one for physically
    continuous pages. But, in the bvec configuration for bip, physically
    continuous integrity pages are composed of each bvec.
    
    Allow bio_integrity_add_page() to create multi-page bvecs, just like
    the bio payloads. This simplifies adding larger payloads, and fixes
    support for non-tiny workloads with nvme, which stopped using
    scatterlist for metadata a while ago.
    
    Cc: Christoph Hellwig <hch@xxxxxx>
    Cc: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    
    Fixes: 783b94bd9250 ("nvme-pci: do not build a scatterlist to map metadata")
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Signed-off-by: Jinyoung Choi <j-young.choi@xxxxxxxxxxx>
    Tested-by: "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>
    Reviewed-by: "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230803025202epcms2p82f57cbfe32195da38c776377b55aed59@epcms2p8
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 4533eb4916610..6f81c10757fb9 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -123,17 +123,34 @@ void bio_integrity_free(struct bio *bio)
 int bio_integrity_add_page(struct bio *bio, struct page *page,
 			   unsigned int len, unsigned int offset)
 {
+	struct request_queue *q = bdev_get_queue(bio->bi_bdev);
 	struct bio_integrity_payload *bip = bio_integrity(bio);
 
-	if (bip->bip_vcnt >= bip->bip_max_vcnt) {
-		printk(KERN_ERR "%s: bip_vec full\n", __func__);
+	if (((bip->bip_iter.bi_size + len) >> SECTOR_SHIFT) >
+	    queue_max_hw_sectors(q))
 		return 0;
-	}
 
-	if (bip->bip_vcnt &&
-	    bvec_gap_to_prev(&bdev_get_queue(bio->bi_bdev)->limits,
-			     &bip->bip_vec[bip->bip_vcnt - 1], offset))
-		return 0;
+	if (bip->bip_vcnt > 0) {
+		struct bio_vec *bv = &bip->bip_vec[bip->bip_vcnt - 1];
+		bool same_page = false;
+
+		if (bvec_try_merge_hw_page(q, bv, page, len, offset,
+					   &same_page)) {
+			bip->bip_iter.bi_size += len;
+			return len;
+		}
+
+		if (bip->bip_vcnt >=
+		    min(bip->bip_max_vcnt, queue_max_integrity_segments(q)))
+			return 0;
+
+		/*
+		 * If the queue doesn't support SG gaps and adding this segment
+		 * would create a gap, disallow it.
+		 */
+		if (bvec_gap_to_prev(&q->limits, bv, offset))
+			return 0;
+	}
 
 	bvec_set_page(&bip->bip_vec[bip->bip_vcnt], page, len, offset);
 	bip->bip_vcnt++;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux