All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: move protection information check into nvme_setup_rw
@ 2017-06-12 16:36 Christoph Hellwig
  2017-06-13  8:00 ` Johannes Thumshirn
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Christoph Hellwig @ 2017-06-12 16:36 UTC (permalink / raw)


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) &&
+	    !blk_integrity_rq(req) && !blk_rq_is_passthrough(req))
+		return BLK_STS_NOTSUPP;
+
 	if (req->cmd_flags & REQ_FUA)
 		control |= NVME_RW_FUA;
 	if (req->cmd_flags & (REQ_FAILFAST_DEV | REQ_RAHEAD))
@@ -386,6 +395,7 @@ static inline void nvme_setup_rw(struct nvme_ns *ns, struct request *req,
 
 	cmnd->rw.control = cpu_to_le16(control);
 	cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt);
+	return 0;
 }
 
 blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
@@ -414,7 +424,7 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
 		break;
 	case REQ_OP_READ:
 	case REQ_OP_WRITE:
-		nvme_setup_rw(ns, req, cmd);
+		ret = nvme_setup_rw(ns, req, cmd);
 		break;
 	default:
 		WARN_ON_ONCE(1);
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 0a816910cf0e..92c1325251f0 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -692,18 +692,7 @@ static blk_status_t nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
 	struct nvme_dev *dev = nvmeq->dev;
 	struct request *req = bd->rq;
 	struct nvme_command cmnd;
-	blk_status_t ret = BLK_STS_OK;
-
-	/*
-	 * 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 && !blk_integrity_rq(req)) {
-		if (!(ns->pi_type && ns->ms == 8) &&
-		    !blk_rq_is_passthrough(req))
-			return BLK_STS_NOTSUPP;
-	}
+	blk_status_t ret;
 
 	ret = nvme_setup_cmd(ns, req, &cmnd);
 	if (ret)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] nvme: move protection information check into nvme_setup_rw
  2017-06-12 16:36 [PATCH] nvme: move protection information check into nvme_setup_rw Christoph Hellwig
@ 2017-06-13  8:00 ` Johannes Thumshirn
  2017-06-13  8:03   ` Christoph Hellwig
  2017-06-13 14:55 ` Keith Busch
  2017-06-15  9:21 ` Sagi Grimberg
  2 siblings, 1 reply; 7+ messages in thread
From: Johannes Thumshirn @ 2017-06-13  8:00 UTC (permalink / raw)


On 06/12/2017 06:36 PM, Christoph Hellwig wrote:
> +static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
> +		struct request *req, struct nvme_command *cmnd)
>  {

Hmm here you're changing nvme_setup_rw to return blk_status_t

[...]

> @@ -386,6 +395,7 @@ static inline void nvme_setup_rw(struct nvme_ns *ns, struct request *req,
>  
>  	cmnd->rw.control = cpu_to_le16(control);
>  	cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt);
> +	return 0;
>  }

And here you're returning 0 instead of BLK_STATUS_OK.

Intentional?

-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] nvme: move protection information check into nvme_setup_rw
  2017-06-13  8:00 ` Johannes Thumshirn
@ 2017-06-13  8:03   ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2017-06-13  8:03 UTC (permalink / raw)


On Tue, Jun 13, 2017@10:00:23AM +0200, Johannes Thumshirn wrote:
> > @@ -386,6 +395,7 @@ static inline void nvme_setup_rw(struct nvme_ns *ns, struct request *req,
> >  
> >  	cmnd->rw.control = cpu_to_le16(control);
> >  	cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt);
> > +	return 0;
> >  }
> 
> And here you're returning 0 instead of BLK_STATUS_OK.
> 
> Intentional?

Yes, at least sort of.  Even for __bitwise types 0 is special, so
this is perfectly fine.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] nvme: move protection information check into nvme_setup_rw
  2017-06-12 16:36 [PATCH] nvme: move protection information check into nvme_setup_rw Christoph Hellwig
  2017-06-13  8:00 ` Johannes Thumshirn
@ 2017-06-13 14:55 ` Keith Busch
  2017-06-15  9:21 ` Sagi Grimberg
  2 siblings, 0 replies; 7+ messages in thread
From: Keith Busch @ 2017-06-13 14:55 UTC (permalink / raw)


On Mon, Jun 12, 2017@06:36:32PM +0200, 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>

Looks good to me.

Reviewed-by: Keith Busch <keith.busch at intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] nvme: move protection information check into nvme_setup_rw
  2017-06-12 16:36 [PATCH] nvme: move protection information check into nvme_setup_rw Christoph Hellwig
  2017-06-13  8:00 ` Johannes Thumshirn
  2017-06-13 14:55 ` Keith Busch
@ 2017-06-15  9:21 ` Sagi Grimberg
  2017-06-15 12:11   ` Christoph Hellwig
  2017-06-15 12:17   ` Christoph Hellwig
  2 siblings, 2 replies; 7+ messages in thread
From: Sagi Grimberg @ 2017-06-15  9:21 UTC (permalink / raw)




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?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] nvme: move protection information check into nvme_setup_rw
  2017-06-15  9:21 ` Sagi Grimberg
@ 2017-06-15 12:11   ` Christoph Hellwig
  2017-06-15 12:17   ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2017-06-15 12:11 UTC (permalink / raw)


On Thu, Jun 15, 2017@12:21:45PM +0300, Sagi Grimberg wrote:
> 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?

Yes, please do.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] nvme: move protection information check into nvme_setup_rw
  2017-06-15  9:21 ` Sagi Grimberg
  2017-06-15 12:11   ` Christoph Hellwig
@ 2017-06-15 12:17   ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2017-06-15 12:17 UTC (permalink / raw)


On Thu, Jun 15, 2017@12:21:45PM +0300, Sagi Grimberg wrote:
> 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?

Yes, please do.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-06-15 12:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-12 16:36 [PATCH] nvme: move protection information check into nvme_setup_rw Christoph Hellwig
2017-06-13  8:00 ` Johannes Thumshirn
2017-06-13  8:03   ` Christoph Hellwig
2017-06-13 14:55 ` Keith Busch
2017-06-15  9:21 ` Sagi Grimberg
2017-06-15 12:11   ` Christoph Hellwig
2017-06-15 12:17   ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.