From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>,
Keith Busch <keith.busch@wdc.com>,
Chaitanya Kulkarni <chaitanyak@nvidia.com>,
linux-nvme@lists.infradead.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 3/7] nvmet: add nvmet_is_disc_subsys() helper
Date: Wed, 22 Sep 2021 08:35:21 +0200 [thread overview]
Message-ID: <20210922063525.143045-4-hare@suse.de> (raw)
In-Reply-To: <20210922063525.143045-1-hare@suse.de>
Add a helper function to determine if a given subsystem is a discovery
subsystem.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/nvme/target/admin-cmd.c | 2 +-
drivers/nvme/target/core.c | 6 +++---
drivers/nvme/target/nvmet.h | 5 +++++
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index aa6d84d8848e..b653ea4244fe 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -1008,7 +1008,7 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
if (nvme_is_fabrics(cmd))
return nvmet_parse_fabrics_cmd(req);
- if (nvmet_req_subsys(req)->type == NVME_NQN_DISC)
+ if (nvmet_is_disc_subsys(nvmet_req_subsys(req)))
return nvmet_parse_discovery_cmd(req);
ret = nvmet_check_ctrl_status(req);
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 88ed746c675f..61ceb42717f1 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -1140,7 +1140,7 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl)
* should verify iosqes,iocqes are zeroed, however that
* would break backwards compatibility, so don't enforce it.
*/
- if (ctrl->subsys->type != NVME_NQN_DISC &&
+ if (!nvmet_is_disc_subsys(ctrl->subsys) &&
(nvmet_cc_iosqes(ctrl->cc) != NVME_NVM_IOSQES ||
nvmet_cc_iocqes(ctrl->cc) != NVME_NVM_IOCQES)) {
ctrl->csts = NVME_CSTS_CFS;
@@ -1278,7 +1278,7 @@ bool nvmet_host_allowed(struct nvmet_subsys *subsys, const char *hostnqn)
if (subsys->allow_any_host)
return true;
- if (subsys->type == NVME_NQN_DISC) /* allow all access to disc subsys */
+ if (nvmet_is_disc_subsys(subsys)) /* allow all access to disc subsys */
return true;
list_for_each_entry(p, &subsys->hosts, entry) {
@@ -1411,7 +1411,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
* Discovery controllers may use some arbitrary high value
* in order to cleanup stale discovery sessions
*/
- if ((ctrl->subsys->type == NVME_NQN_DISC) && !kato)
+ if (nvmet_is_disc_subsys(ctrl->subsys) && !kato)
kato = NVMET_DISC_KATO_MS;
/* keep-alive timeout in seconds */
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 7143c7fa7464..93a86d6053ef 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -576,6 +576,11 @@ static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req)
return req->sq->ctrl->subsys;
}
+static inline bool nvmet_is_disc_subsys(struct nvmet_subsys *subsys)
+{
+ return subsys->type == NVME_NQN_DISC;
+}
+
#ifdef CONFIG_NVME_TARGET_PASSTHRU
void nvmet_passthru_subsys_free(struct nvmet_subsys *subsys);
int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys);
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2021-09-22 6:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-22 6:35 [PATCHv3 0/7] nvme: support unique discovery controller NQN Hannes Reinecke
2021-09-22 6:35 ` [PATCH 1/7] nvmet: make discovery NQN configurable Hannes Reinecke
2021-09-22 7:07 ` Chaitanya Kulkarni
2021-09-22 13:36 ` Himanshu Madhani
2021-09-22 6:35 ` [PATCH 2/7] nvme: add CNTRLTYPE definitions for 'identify controller' Hannes Reinecke
2021-09-22 13:37 ` Himanshu Madhani
2021-09-22 6:35 ` Hannes Reinecke [this message]
2021-09-22 7:06 ` [PATCH 3/7] nvmet: add nvmet_is_disc_subsys() helper Chaitanya Kulkarni
2021-09-22 13:36 ` Himanshu Madhani
2021-09-22 6:35 ` [PATCH 4/7] nvmet: set 'CNTRLTYPE' in the identify controller data Hannes Reinecke
2021-09-22 7:08 ` Chaitanya Kulkarni
2021-09-22 6:35 ` [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype' Hannes Reinecke
2021-09-22 8:02 ` Daniel Wagner
2021-10-12 13:10 ` Christoph Hellwig
2021-10-12 13:43 ` Hannes Reinecke
2021-10-12 13:44 ` Christoph Hellwig
2021-09-22 6:35 ` [PATCH 6/7] nvme: Add connect option 'discovery' Hannes Reinecke
2021-09-22 16:59 ` James Smart
2021-09-23 6:11 ` Hannes Reinecke
2021-09-22 6:35 ` [PATCH 7/7] nvme: display correct subsystem NQN Hannes Reinecke
2021-10-12 13:10 ` [PATCHv3 0/7] nvme: support unique discovery controller NQN 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=20210922063525.143045-4-hare@suse.de \
--to=hare@suse.de \
--cc=chaitanyak@nvidia.com \
--cc=hch@lst.de \
--cc=keith.busch@wdc.com \
--cc=linux-nvme@lists.infradead.org \
--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 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.