From: Mike Christie <michael.christie@oracle.com>
To: chaitanyak@nvidia.com, kbusch@kernel.org, axboe@fb.com,
hch@lst.de, sagi@grimberg.me, martin.petersen@oracle.com,
jejb@linux.ibm.com, linux-scsi@vger.kernel.org,
linux-nvme@lists.infradead.org, linux-block@vger.kernel.org
Cc: Mike Christie <michael.christie@oracle.com>,
Chaitanya Kulkarni <kch@nvidia.com>
Subject: [PATCH v3 4/4] nvme: Convert NVMe errors to PR errors
Date: Mon, 21 Nov 2022 21:26:03 -0600 [thread overview]
Message-ID: <20221122032603.32766-5-michael.christie@oracle.com> (raw)
In-Reply-To: <20221122032603.32766-1-michael.christie@oracle.com>
This converts the NVMe errors we commonly see during PR handling to PR_STS
errors or -Exyz errors. pr_ops callers can then handle scsi and nvme errors
without knowing the device types.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/core.c | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index da55ce45ac70..6cd66f6d5e9b 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2103,11 +2103,34 @@ static int nvme_send_ns_pr_command(struct nvme_ns *ns, struct nvme_command *c,
return nvme_submit_sync_cmd(ns->queue, c, data, 16);
}
+static int nvme_sc_to_pr_err(int nvme_sc)
+{
+ if (nvme_is_path_error(nvme_sc))
+ return PR_STS_PATH_FAILED;
+
+ switch (nvme_sc) {
+ case NVME_SC_SUCCESS:
+ return PR_STS_SUCCESS;
+ case NVME_SC_RESERVATION_CONFLICT:
+ return PR_STS_RESERVATION_CONFLICT;
+ case NVME_SC_ONCS_NOT_SUPPORTED:
+ return -EOPNOTSUPP;
+ case NVME_SC_BAD_ATTRIBUTES:
+ case NVME_SC_INVALID_OPCODE:
+ case NVME_SC_INVALID_FIELD:
+ case NVME_SC_INVALID_NS:
+ return -EINVAL;
+ default:
+ return PR_STS_IOERR;
+ }
+}
+
static int nvme_pr_command(struct block_device *bdev, u32 cdw10,
u64 key, u64 sa_key, u8 op)
{
struct nvme_command c = { };
u8 data[16] = { 0, };
+ int ret;
put_unaligned_le64(key, &data[0]);
put_unaligned_le64(sa_key, &data[8]);
@@ -2117,8 +2140,14 @@ static int nvme_pr_command(struct block_device *bdev, u32 cdw10,
if (IS_ENABLED(CONFIG_NVME_MULTIPATH) &&
bdev->bd_disk->fops == &nvme_ns_head_ops)
- return nvme_send_ns_head_pr_command(bdev, &c, data);
- return nvme_send_ns_pr_command(bdev->bd_disk->private_data, &c, data);
+ ret = nvme_send_ns_head_pr_command(bdev, &c, data);
+ else
+ ret = nvme_send_ns_pr_command(bdev->bd_disk->private_data, &c,
+ data);
+ if (ret < 0)
+ return ret;
+
+ return nvme_sc_to_pr_err(ret);
}
static int nvme_pr_register(struct block_device *bdev, u64 old,
--
2.25.1
next prev parent reply other threads:[~2022-11-22 3:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 3:25 [PATCH v3 0/4] block/scsi/nvme: Add error codes for PR ops Mike Christie
2022-11-22 3:26 ` [PATCH v3 1/4] block: Add error codes for common PR failures Mike Christie
2022-11-22 3:26 ` [PATCH v3 2/4] scsi: Rename status_byte to sg_status_byte Mike Christie
2022-11-22 3:26 ` [PATCH v3 3/4] scsi: Convert SCSI errors to PR errors Mike Christie
2022-11-22 3:26 ` Mike Christie [this message]
2022-11-26 2:48 ` [PATCH v3 0/4] block/scsi/nvme: Add error codes for PR ops Martin K. Petersen
2022-11-29 4:18 ` Chaitanya Kulkarni
2022-11-29 13:28 ` hch
2022-11-29 14:00 ` Jens Axboe
2022-11-29 21:31 ` Mike Christie
2022-12-01 3:28 ` Martin K. Petersen
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=20221122032603.32766-5-michael.christie@oracle.com \
--to=michael.christie@oracle.com \
--cc=axboe@fb.com \
--cc=chaitanyak@nvidia.com \
--cc=hch@lst.de \
--cc=jejb@linux.ibm.com \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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).