Patch "nvmet: limit passthru MTDS by BIO_MAX_PAGES" has been added to the 5.9-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

    nvmet: limit passthru MTDS by BIO_MAX_PAGES

to the 5.9-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:
     nvmet-limit-passthru-mtds-by-bio_max_pages.patch
and it can be found in the queue-5.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 37af318b7d1c639385078148bb9fef99f33cd889
Author: Logan Gunthorpe <logang@xxxxxxxxxxxx>
Date:   Fri Oct 16 16:19:04 2020 -0600

    nvmet: limit passthru MTDS by BIO_MAX_PAGES
    
    [ Upstream commit df06047d54276f73782c9d97882b305fca745d3f ]
    
    nvmet_passthru_map_sg() only supports mapping a single BIO, not a chain
    so the effective maximum transfer should also be limitted by
    BIO_MAX_PAGES (presently this works out to 1MB).
    
    For PCI passthru devices the max_sectors would typically be more
    limitting than BIO_MAX_PAGES, but this may not be true for all passthru
    devices.
    
    Fixes: c1fef73f793b ("nvmet: add passthru code to process commands")
    Suggested-by: Christoph Hellwig <hch@xxxxxx>
    Signed-off-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>
    Cc: Christoph Hellwig <hch@xxxxxx>
    Cc: Sagi Grimberg <sagi@xxxxxxxxxxx>
    Cc: Chaitanya Kulkarni <chaitanya.kulkarni@xxxxxxx>
    Signed-off-by: Christoph Hellwig <hch@xxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
index dacfa7435d0b2..1ab88df3310f6 100644
--- a/drivers/nvme/target/passthru.c
+++ b/drivers/nvme/target/passthru.c
@@ -26,7 +26,7 @@ static u16 nvmet_passthru_override_id_ctrl(struct nvmet_req *req)
 	struct nvme_ctrl *pctrl = ctrl->subsys->passthru_ctrl;
 	u16 status = NVME_SC_SUCCESS;
 	struct nvme_id_ctrl *id;
-	u32 max_hw_sectors;
+	int max_hw_sectors;
 	int page_shift;
 
 	id = kzalloc(sizeof(*id), GFP_KERNEL);
@@ -48,6 +48,13 @@ static u16 nvmet_passthru_override_id_ctrl(struct nvmet_req *req)
 	max_hw_sectors = min_not_zero(pctrl->max_segments << (PAGE_SHIFT - 9),
 				      pctrl->max_hw_sectors);
 
+	/*
+	 * nvmet_passthru_map_sg is limitted to using a single bio so limit
+	 * the mdts based on BIO_MAX_PAGES as well
+	 */
+	max_hw_sectors = min_not_zero(BIO_MAX_PAGES << (PAGE_SHIFT - 9),
+				      max_hw_sectors);
+
 	page_shift = NVME_CAP_MPSMIN(ctrl->cap) + 12;
 
 	id->mdts = ilog2(max_hw_sectors) + 9 - page_shift;



[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