nvme: add nvme_is_disc_subsys() helper
PATCH 1/1 nvme: add nvme_is_disc_subsys() helper
Mirror the target's nvmet_is_disc_subsys() with a host-side nvme_is_disc_subsys() helper, and use it for the open-coded subtype == NVME_NQN_DISC checks in the host code to help maintain consistency and improve code readability.
And while here, fix an error message to refer to the subsystem rather than the controller.
--- drivers/nvme/host/core.c | 4 ++-- drivers/nvme/host/multipath.c | 6 +++--- drivers/nvme/host/nvme.h | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-)
drivers/nvme/host/core.c +2 -2
@@ -3329,9 +3329,9 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)else subsys->subtype =NVME_NQN_NVME ; -if (nvme_discovery_ctrl (ctrl) && subsys->subtype !=NVME_NQN_DISC ) { +if (nvme_discovery_ctrl (ctrl) && !nvme_is_disc_subsys (subsys)) {dev_err (ctrl->device, -"Subsystem %s is not a discovery controller" , +"Subsystem %s is not a discovery subsystem" , subsys->subnqn);kfree (subsys);return -EINVAL ;
drivers/nvme/host/multipath.c +3 -3
@@ -1072,7 +1072,7 @@ static ssize_t nvme_subsys_iopolicy_show(struct device *dev, container_of(dev, struct nvme_subsystem, dev);/* A discovery subsystem has no namespaces and hence no I/O paths */ -if (subsys->subtype ==NVME_NQN_DISC ) +if (nvme_is_disc_subsys (subsys))return sysfs_emit (buf,"none\n" ); return sysfs_emit(buf, "%s\n",
@@ -1109,7 +1109,7 @@ static ssize_t nvme_subsys_iopolicy_store(struct device *dev, container_of(dev, struct nvme_subsystem, dev);int policy; -if (subsys->subtype ==NVME_NQN_DISC ) +if (nvme_is_disc_subsys (subsys))return -EOPNOTSUPP ; policy =nvme_iopolicy_parse (buf);
@@ -1129,7 +1129,7 @@ static ssize_t iopolicies_show(struct device *dev, container_of(dev, struct nvme_subsystem, dev);int i, len =0 ; -if (subsys->subtype ==NVME_NQN_DISC ) +if (nvme_is_disc_subsys (subsys))return sysfs_emit (buf,"none\n" );for (i =0 ; i <ARRAY_SIZE (nvme_iopolicy_names); i++)
drivers/nvme/host/nvme.h +5 -0
@@ -522,6 +522,11 @@ struct nvme_subsystem {#endif }; +static inline bool nvme_is_disc_subsys (struct nvme_subsystem *subsys) +{ +return subsys->subtype !=NVME_NQN_NVME ; +} +/* * Container structure for uniqueue namespace identifiers. */
Signature · 1 line
2.43.0
Christoph Hellwig
maintainerQuoted 7 lines · Martin George
Mirror the target's
nvmet_is_disc_subsys()with a host-sidenvme_is_disc_subsys()helper, and use it for the open-coded subtype ==NVME_NQN_DISCchecks in the host code to help maintain consistency and improve code readability.And while here, fix an error message to refer to the subsystem rather than the controller.
Not going to NAK it, but the helper feels a bit pointless to me. Do you have any bigger plans with it?
Quoted 6 lines · Christoph Hellwig
Quoted 5 lines · Martin George
Mirror the target's
nvmet_is_disc_subsys()with a host-sidenvme_is_disc_subsys()helper, and use it for the open-coded subtype ==NVME_NQN_DISCchecks in the host code to help maintain consistency and improve code readability.
Quoted 6 lines
Quoted 2 lines
And while here, fix an error message to refer to the subsystem rather than the controller.
Not going to NAK it, but the helper feels a bit pointless to me. Do you have any bigger plans with it?
No bigger plans - it's just a small cleanup. Mainly two things:
- Consistency with the target, which already has something similar
- It folds the open-coded discovery subtype checks into one self- documenting helper for current & future use.
So a minor net improvement rather than a prerequisite for anything.
-Martin
Christoph Hellwig
maintainerQuoted 7 lines · Martin George
No bigger plans - it's just a small cleanup. Mainly two things:
- Consistency with the target, which already has something similar
- It folds the open-coded discovery subtype checks into one self- documenting helper for current & future use.So a minor net improvement rather than a prerequisite for anything.
Not sure a helper is more self-documenting than a field check.
I don't really care strongly, but this feels a bit like churn without a real purpose to me.