[PATCH] nvme: move protection information check into nvme_setup_rw

Sagi Grimberg sagi at grimberg.me
Thu Jun 15 02:21:45 PDT 2017



On 12/06/17 19:36, Christoph Hellwig wrote:
> It only applies to read/write commands, and this way non-PCIe drivers
> get the check as well instead of having to duplicate it when adding
> metadata support.
> 
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>   drivers/nvme/host/core.c | 16 +++++++++++++---
>   drivers/nvme/host/pci.c  | 13 +------------
>   2 files changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 1a8b0bd77673..c24267a95e66 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -347,12 +347,21 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req,
>   	return BLK_STS_OK;
>   }
>   
> -static inline void nvme_setup_rw(struct nvme_ns *ns, struct request *req,
> -		struct nvme_command *cmnd)
> +static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
> +		struct request *req, struct nvme_command *cmnd)
>   {
>   	u16 control = 0;
>   	u32 dsmgmt = 0;
>   
> +	/*
> +	 * If formated with metadata, require the block layer provide a buffer
> +	 * unless this namespace is formated such that the metadata can be
> +	 * stripped/generated by the controller with PRACT=1.
> +	 */
> +	if (ns && ns->ms && (!ns->pi_type || ns->ms != 8) &&

Not directly related to this patch, but 8 should be replaced with
sizeof(struct t10_pi_tuple).

Otherwise looks good,

Reviewed-by: Sagi Grimberg <sagi at grimberg.me>

Should I send out an incremental change?




More information about the Linux-nvme mailing list