From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 03/10] nvme: simplify the API for getting log pages
Date: Wed, 6 Jun 2018 16:33:04 +0200 [thread overview]
Message-ID: <20180606143311.23076-4-hch@lst.de> (raw)
In-Reply-To: <20180606143311.23076-1-hch@lst.de>
Merge nvme_get_log and nvme_get_log_ext into a single helper, which takes
a plain nsid instead of the nvme_ns pointer. Also add support for the
log specific field while we're at it.
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
drivers/nvme/host/core.c | 32 +++++++++++---------------------
drivers/nvme/host/lightnvm.c | 5 +++--
drivers/nvme/host/nvme.h | 4 ++--
3 files changed, 16 insertions(+), 25 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 62d70419e12a..5e60cfeb81a9 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2254,21 +2254,16 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
return ret;
}
-int nvme_get_log_ext(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
- u8 log_page, void *log,
- size_t size, u64 offset)
+int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp,
+ void *log, size_t size, u64 offset)
{
struct nvme_command c = { };
unsigned long dwlen = size / 4 - 1;
c.get_log_page.opcode = nvme_admin_get_log_page;
-
- if (ns)
- c.get_log_page.nsid = cpu_to_le32(ns->head->ns_id);
- else
- c.get_log_page.nsid = cpu_to_le32(NVME_NSID_ALL);
-
+ c.get_log_page.nsid = cpu_to_le32(nsid);
c.get_log_page.lid = log_page;
+ c.get_log_page.lsp = lsp;
c.get_log_page.numdl = cpu_to_le16(dwlen & ((1 << 16) - 1));
c.get_log_page.numdu = cpu_to_le16(dwlen >> 16);
c.get_log_page.lpol = cpu_to_le32(lower_32_bits(offset));
@@ -2277,12 +2272,6 @@ int nvme_get_log_ext(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
return nvme_submit_sync_cmd(ctrl->admin_q, &c, log, size);
}
-static int nvme_get_log(struct nvme_ctrl *ctrl, u8 log_page, void *log,
- size_t size)
-{
- return nvme_get_log_ext(ctrl, NULL, log_page, log, size, 0);
-}
-
static int nvme_get_effects_log(struct nvme_ctrl *ctrl)
{
int ret;
@@ -2293,8 +2282,8 @@ static int nvme_get_effects_log(struct nvme_ctrl *ctrl)
if (!ctrl->effects)
return 0;
- ret = nvme_get_log(ctrl, NVME_LOG_CMD_EFFECTS, ctrl->effects,
- sizeof(*ctrl->effects));
+ ret = nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_CMD_EFFECTS, 0,
+ ctrl->effects, sizeof(*ctrl->effects), 0);
if (ret) {
kfree(ctrl->effects);
ctrl->effects = NULL;
@@ -3213,7 +3202,8 @@ static void nvme_clear_changed_ns_log(struct nvme_ctrl *ctrl)
* raced with us in reading the log page, which could cause us to miss
* updates.
*/
- error = nvme_get_log(ctrl, NVME_LOG_CHANGED_NS, log, log_size);
+ error = nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_CHANGED_NS, 0, log,
+ log_size, 0);
if (error)
dev_warn(ctrl->device,
"reading changed ns log failed: %d\n", error);
@@ -3330,9 +3320,9 @@ static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl)
if (!log)
return;
- if (nvme_get_log(ctrl, NVME_LOG_FW_SLOT, log, sizeof(*log)))
- dev_warn(ctrl->device,
- "Get FW SLOT INFO log error\n");
+ if (nvme_get_log(ctrl, NVME_NSID_ALL, 0, NVME_LOG_FW_SLOT, log,
+ sizeof(*log), 0))
+ dev_warn(ctrl->device, "Get FW SLOT INFO log error\n");
kfree(log);
}
diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 41279da799ed..5fc695e37a88 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -598,8 +598,9 @@ static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev,
while (left) {
len = min_t(unsigned int, left, ctrl->max_hw_sectors << 9);
- ret = nvme_get_log_ext(ctrl, ns, NVME_NVM_LOG_REPORT_CHUNK,
- dev_meta, len, offset);
+ ret = nvme_get_log(ctrl, ns->head->ns_id,
+ NVME_NVM_LOG_REPORT_CHUNK, 0, dev_meta, len,
+ offset);
if (ret) {
dev_err(ctrl->device, "Get REPORT CHUNK log error\n");
break;
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index de24fe77c80b..0b0a14ce0ab5 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -437,8 +437,8 @@ int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl);
int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
int nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl);
-int nvme_get_log_ext(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
- u8 log_page, void *log, size_t size, u64 offset);
+int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp,
+ void *log, size_t size, u64 offset);
extern const struct attribute_group nvme_ns_id_attr_group;
extern const struct block_device_operations nvme_ns_head_ops;
--
2.14.2
next prev parent reply other threads:[~2018-06-06 14:33 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-06 14:33 draft ANA support v3 Christoph Hellwig
2018-06-06 14:33 ` [PATCH 01/10] nvme.h: add support for the log specific field Christoph Hellwig
2018-06-07 7:27 ` Johannes Thumshirn
2018-06-07 7:58 ` Hannes Reinecke
2018-06-07 12:34 ` Sagi Grimberg
2018-06-06 14:33 ` [PATCH 02/10] nvme.h: add ANA definitions Christoph Hellwig
2018-06-07 7:59 ` Hannes Reinecke
2018-06-07 8:30 ` Johannes Thumshirn
2018-06-07 12:35 ` Sagi Grimberg
2018-06-06 14:33 ` Christoph Hellwig [this message]
2018-06-07 7:39 ` [PATCH 03/10] nvme: simplify the API for getting log pages Johannes Thumshirn
2018-06-07 7:59 ` Hannes Reinecke
2018-06-07 12:35 ` Sagi Grimberg
2018-06-06 14:33 ` [PATCH 04/10] nvme: remove nvme_req_needs_failover Christoph Hellwig
2018-06-07 7:40 ` Johannes Thumshirn
2018-06-07 8:01 ` Hannes Reinecke
2018-06-07 11:57 ` Christoph Hellwig
2018-06-07 12:36 ` Sagi Grimberg
2018-06-06 14:33 ` [PATCH 05/10] nvme: add ANA support Christoph Hellwig
2018-06-07 8:01 ` Hannes Reinecke
2018-06-07 12:49 ` Sagi Grimberg
2018-06-07 13:05 ` Christoph Hellwig
2018-06-07 13:55 ` Christoph Hellwig
2018-06-06 14:33 ` [PATCH 06/10] nvme: don't set gendisks live that don't have an I/O capable path Christoph Hellwig
2018-06-06 14:33 ` [PATCH 07/10] nvmet: track and limit the number of namespaces per subsystem Christoph Hellwig
2018-06-07 7:54 ` Johannes Thumshirn
2018-06-07 8:02 ` Hannes Reinecke
2018-06-06 14:33 ` [PATCH 08/10] nvmet: add minimal ANA support Christoph Hellwig
2018-06-07 8:03 ` Hannes Reinecke
2018-06-07 12:52 ` Sagi Grimberg
2018-06-06 14:33 ` [PATCH 09/10] nvmet: support configuring ANA groups Christoph Hellwig
2018-06-07 8:09 ` Hannes Reinecke
2018-06-07 12:02 ` Christoph Hellwig
2018-06-07 12:58 ` Sagi Grimberg
2018-06-07 13:08 ` Christoph Hellwig
2018-06-06 14:33 ` [PATCH 10/10] host fold Christoph Hellwig
2018-06-06 14:46 ` Christoph Hellwig
2018-06-06 15:18 ` Hannes Reinecke
2018-06-07 12:34 ` draft ANA support v3 Sagi Grimberg
2018-06-07 13:06 ` Christoph Hellwig
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=20180606143311.23076-4-hch@lst.de \
--to=hch@lst.de \
/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