Skip to contentSkip to conversation

nvme: fail cancelled commands with NVME_SC_HOST_PATH_ERROR

PATCH Chaitanya Kulkarni 3 participants 8 messages Aug 30, 2019 – Sep 9, 2019 6 messages not in the archive NVMe

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Chaitanya Kulkarni

author Reviewed-by
#2 lore raw

Looks good.

Quoted 34 lines · Sagi Grimberg

NVME_SC_ABORT_REQ means that the request was aborted due to an abort command received. In our case, this is a transport cancellation, so host pathing error is much more appropriate.

Also, convert NVME_SC_HOST_PATH_ERROR to BLK_STS_TRANSPORT for such that callers can understand that the status is a transport related error. This will be used by the ns scanning code to understand if it got an error from the controller or that the controller happens to be unreachable by the transport.

---
  drivers/nvme/host/core.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +2 -0
index 0eb5c1bb2f48..11ef174e8399 100644
@@ -226,6 +226,8 @@ static blk_status_t nvme_error_status(struct request *req)
  		return BLK_STS_PROTECTION;
  	case NVME_SC_RESERVATION_CONFLICT:
  		return BLK_STS_NEXUS;
+	case NVME_SC_HOST_PATH_ERROR:
+		return BLK_STS_TRANSPORT;
  	default:
  		return BLK_STS_IOERR;
  	}

drivers/nvme/host/core.c bool nvme_cancel_request(struct request *req, void *data, bool reserved) · line 302

Quoted 8 lines
drivers/nvme/host/core.c +1 -1
@@ -294,7 +296,7 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved)
  	if (blk_mq_request_completed(req))
  		return true;
 
-	nvme_req(req)->status = NVME_SC_ABORT_REQ;
+	nvme_req(req)->status = NVME_SC_HOST_PATH_ERROR;
  	blk_mq_complete_request(req);
  	return true;
  }

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

A message that is not in the archive (sent off-list or not yet received): [email protected]

author Reviewed-by
#4 lore raw

Re: [PATCH v9 2/9] nvme: make nvme_identify_ns propagate errors back

Looks good.

drivers/nvme/host/core.c

Quoted 15 lines · Sagi Grimberg

right now callers of nvme_identify_ns only know that it failed, but don't know why. Make nvme_identify_ns propagate the error back. Because nvme_submit_sync_cmd may return a positive status code, we make nvme_identify_ns receive the id by reference and return that status up the call chain.

---
  drivers/nvme/host/core.c | 30 +++++++++++++-----------------
  1 file changed, 13 insertions(+), 17 deletions(-)
drivers/nvme/host/core.c +0 -0

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

A message that is not in the archive (sent off-list or not yet received): [email protected]

author Reviewed-by
#6 lore raw

Re: [PATCH v9 3/9] nvme: make nvme_report_ns_ids propagate error back

Starting commit log with "And" seems little bit odd.

Otherwise, looks good.

Quoted 10 lines · Sagi Grimberg

And make the callers check the return status and propagate back accordingly. Also print the return status.

---
  drivers/nvme/host/core.c | 24 ++++++++++++++++++------
  1 file changed, 18 insertions(+), 6 deletions(-)

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

Re: [PATCH v9 6/9] block_dev: split disk size check out of revalidate_disk

Quoted 5 lines · Sagi Grimberg

Allow callers to call separately the ->revalidate_disk() callout and the disk size change check separately. This will help the caller to take action based on the return status of ->revalidate_disk() and run the disk size check afterwards.

Commit message looks odd as compare to other commits, please have a look at following message which uses limit of 72 car per line :-

Allow callers to call separately the ->revalidate_disk() callout and the disk size change check separately. This will help the caller to take action based on the return status of ->revalidate_disk() and run the disk size check afterwards.

Quoted 60 lines
---
  fs/block_dev.c     | 29 +++++++++++++++++------------
  include/linux/fs.h |  1 +
  2 files changed, 18 insertions(+), 12 deletions(-)
fs/block_dev.c +17 -12
index a6f7c892cb4a..4939a093e2f8 100644
@@ -1482,6 +1482,21 @@ void check_disk_size_change(struct gendisk *disk, struct block_device *bdev,
  	}
  }
 
+void check_disk_size(struct gendisk *disk, bool verbose)
+{
+	struct block_device *bdev = bdget_disk(disk, 0);
+
+	if (!bdev)
+		return;
+
+	mutex_lock(&bdev->bd_mutex);
+	check_disk_size_change(disk, bdev, verbose);
+	bdev->bd_invalidated = 0;
+	mutex_unlock(&bdev->bd_mutex);
+	bdput(bdev);
+}
+EXPORT_SYMBOL_GPL(check_disk_size);
+
  /**
   * revalidate_disk - wrapper for lower-level driver's revalidate_disk call-back
   * @disk: struct gendisk to be revalidated
@@ -1501,18 +1516,8 @@ int revalidate_disk(struct gendisk *disk)
  	 * Hidden disks don't have associated bdev so there's no point in
  	 * revalidating it.
  	 */
-	if (!(disk->flags & GENHD_FL_HIDDEN)) {
-		struct block_device *bdev = bdget_disk(disk, 0);
-
-		if (!bdev)
-			return ret;
-
-		mutex_lock(&bdev->bd_mutex);
-		check_disk_size_change(disk, bdev, ret == 0);
-		bdev->bd_invalidated = 0;
-		mutex_unlock(&bdev->bd_mutex);
-		bdput(bdev);
-	}
+	if (!(disk->flags & GENHD_FL_HIDDEN))
+		check_disk_size(disk, ret == 0);
  	return ret;
  }
  EXPORT_SYMBOL(revalidate_disk);
include/linux/fs.h +0 -0
index 997a530ff4e9..6649ad157317 100644

include/linux/fs.h extern bool is_bad_inode(struct inode *); · line 2685

Quoted 7 lines
include/linux/fs.h +1 -0
@@ -2679,6 +2679,7 @@ extern bool is_bad_inode(struct inode *);
  extern void check_disk_size_change(struct gendisk *disk,
  		struct block_device *bdev, bool verbose);
  extern int revalidate_disk(struct gendisk *);
+extern void check_disk_size(struct gendisk *disk, bool verbose);
  extern int check_disk_change(struct block_device *);
  extern int __invalidate_device(struct block_device *, bool);
  extern int invalidate_partition(struct gendisk *, int);

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

Reviewed-by
#9 lore raw

Re: [PATCH v9 6/9] block_dev: split disk size check out of revalidate_disk

In reply to a message not in the archive
Quoted 6 lines · Sagi Grimberg

Allow callers to call separately the ->revalidate_disk() callout and the disk size change check separately. This will help the caller to take action based on the return status of ->revalidate_disk() and run the disk size check afterwards.

Quoted 6 lines
---
 fs/block_dev.c     | 29 +++++++++++++++++------------
 include/linux/fs.h |  1 +
 2 files changed, 18 insertions(+), 12 deletions(-)

Cheers,

Hannes

Signature · 9 lines
Dr. Hannes Reinecke		      Teamlead Storage & Networking
[email protected]			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 247165 (AG München), GF: Felix Imendörffer

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw

Re: [PATCH v9 7/9] nvme: pass status to nvme_error_status

Do you find any issue with passing request structure ? or it is more of a normal cleanup ?

Quoted 25 lines · Sagi Grimberg

No need for the full blown request structure.

---
  drivers/nvme/host/core.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/nvme/host/core.c +2 -2
index 0916c0e8d572..8f0881dec907 100644
@@ -197,9 +197,9 @@ static inline bool nvme_ns_has_pi(struct nvme_ns *ns)
  	return ns->pi_type && ns->ms == sizeof(struct t10_pi_tuple);
  }
 
-static blk_status_t nvme_error_status(struct request *req)
+static blk_status_t nvme_error_status(u16 status)
  {
-	switch (nvme_req(req)->status & 0x7ff) {
+	switch (status & 0x7ff) {
  	case NVME_SC_SUCCESS:
  		return BLK_STS_OK;
  	case NVME_SC_CAP_EXCEEDED:

drivers/nvme/host/core.c static void nvme_retry_req(struct request *req) · line 268

Quoted 8 lines
drivers/nvme/host/core.c +1 -1
@@ -262,7 +262,7 @@ static void nvme_retry_req(struct request *req)
 
  void nvme_complete_rq(struct request *req)
  {
-	blk_status_t status = nvme_error_status(req);
+	blk_status_t status = nvme_error_status(nvme_req(req)->status);
 
  	trace_nvme_complete_rq(req);
 

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

Reviewed-by
#13 lore raw

Re: [PATCH v9 7/9] nvme: pass status to nvme_error_status

In reply to a message not in the archive
Quoted 25 lines · Sagi Grimberg

No need for the full blown request structure.

---
 drivers/nvme/host/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/nvme/host/core.c +2 -2
index 0916c0e8d572..8f0881dec907 100644
@@ -197,9 +197,9 @@ static inline bool nvme_ns_has_pi(struct nvme_ns *ns)
 	return ns->pi_type && ns->ms == sizeof(struct t10_pi_tuple);
 }
 
-static blk_status_t nvme_error_status(struct request *req)
+static blk_status_t nvme_error_status(u16 status)
 {
-	switch (nvme_req(req)->status & 0x7ff) {
+	switch (status & 0x7ff) {
 	case NVME_SC_SUCCESS:
 		return BLK_STS_OK;
 	case NVME_SC_CAP_EXCEEDED:

drivers/nvme/host/core.c static void nvme_retry_req(struct request *req) · line 268

Quoted 8 lines
drivers/nvme/host/core.c +1 -1
@@ -262,7 +262,7 @@ static void nvme_retry_req(struct request *req)
 
 void nvme_complete_rq(struct request *req)
 {
-	blk_status_t status = nvme_error_status(req);
+	blk_status_t status = nvme_error_status(nvme_req(req)->status);
 
 	trace_nvme_complete_rq(req);
 

Cheers,

Hannes

Signature · 9 lines
Dr. Hannes Reinecke		      Teamlead Storage & Networking
[email protected]			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 247165 (AG München), GF: Felix Imendörffer

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme