[PATCH v3 1/2] nvmet-passthru: Limit mdts by BIO_MAX_PAGES

Sagi Grimberg sagi at grimberg.me
Tue Oct 20 04:18:04 EDT 2020


> diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
> index dacfa7435d0b..ed6b0586173e 100644
> --- a/drivers/nvme/target/passthru.c
> +++ b/drivers/nvme/target/passthru.c
> @@ -22,11 +22,12 @@ static DEFINE_XARRAY(passthru_subsystems);
> 
>   static u16 nvmet_passthru_override_id_ctrl(struct nvmet_req *req)
>   {
> +	const int PG_TO_SECTOR = PAGE_SHIFT - SECTOR_SHIFT;
>   	struct nvmet_ctrl *ctrl = req->sq->ctrl;
>   	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);
> @@ -45,9 +46,16 @@ static u16 nvmet_passthru_override_id_ctrl(struct nvmet_req *req)
>   	 * which depends on the host's memory fragementation. To solve this,
>   	 * ensure mdts is limited to the pages equal to the number of segments.
>   	 */
> -	max_hw_sectors = min_not_zero(pctrl->max_segments << (PAGE_SHIFT - 9),
> +	max_hw_sectors = min_not_zero(pctrl->max_segments << PG_TO_SECTOR,
>   				      pctrl->max_hw_sectors);

I also liked the previous one better...



More information about the Linux-nvme mailing list