linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Max Gurtovoy <mgurtovoy@nvidia.com>
To: Logan Gunthorpe <logang@deltatee.com>, <linux-nvme@lists.infradead.org>
Cc: Christoph Hellwig <hch@lst.de>,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
	Sagi Grimberg <sagi@grimberg.me>
Subject: Re: [PATCH v2 1/2] nvmet-passthru: Limit mdts by BIO_MAX_PAGES
Date: Mon, 19 Oct 2020 14:20:52 +0300	[thread overview]
Message-ID: <7fbd6b56-cda5-a9b3-7323-99d9704fbec5@nvidia.com> (raw)
In-Reply-To: <20201016221905.4686-1-logang@deltatee.com>


On 10/17/2020 1:19 AM, Logan Gunthorpe wrote:
> 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@lst.de>
> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
>   drivers/nvme/target/passthru.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
> index dacfa7435d0b..1ab88df3310f 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);

can 9 be replaced with SECTOR_SHIFT ?


> +
>   	page_shift = NVME_CAP_MPSMIN(ctrl->cap) + 12;
>   
>   	id->mdts = ilog2(max_hw_sectors) + 9 - page_shift;
>
> base-commit: bbf5c979011a099af5dc76498918ed7df445635b

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2020-10-19 11:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16 22:19 [PATCH v2 1/2] nvmet-passthru: Limit mdts by BIO_MAX_PAGES Logan Gunthorpe
2020-10-16 22:19 ` [PATCH v2 2/2] nvmet-passthru: Cleanup nvmet_passthru_map_sg() Logan Gunthorpe
2020-10-19 11:20 ` Max Gurtovoy [this message]
2020-10-19 15:40   ` [PATCH v2 1/2] nvmet-passthru: Limit mdts by BIO_MAX_PAGES Logan Gunthorpe
     [not found]     ` <BYAPR04MB4965B1360F5F6A1D13FF1DD0861F0@BYAPR04MB4965.namprd04.prod.outlook.com>
2020-10-20  2:05       ` Logan Gunthorpe
2020-10-22 13:29 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7fbd6b56-cda5-a9b3-7323-99d9704fbec5@nvidia.com \
    --to=mgurtovoy@nvidia.com \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=linux-nvme@lists.infradead.org \
    --cc=logang@deltatee.com \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).