nvme: Add new clear_ids attribute for passthru targets
Subsystems (2)
PATCH v2 1/1 nvme: Add new clear_ids attribute for passthru targets
If the clear_ids attribute is set to true, the EUI/GUID/UUID is cleared for the passthru target. By default, loop targets will set clear_ids to true.
This resolves an issue where a connect to a passthru target fails when using a trtype of 'loop' because EUI/GUID/UUID is not unique.
Signed-off-by Alan Adamson <[email protected]>
Reviewed-by Keith Busch <[email protected]>
Reviewed-by Chaitanya Kulkarni <[email protected]>
--- drivers/nvme/target/configfs.c | 20 ++++++++++++ drivers/nvme/target/core.c | 4 +++ drivers/nvme/target/nvmet.h | 1 + drivers/nvme/target/passthru.c | 57 ++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+)
drivers/nvme/target/configfs.c +20 -0
@@ -773,11 +773,31 @@ static ssize_t nvmet_passthru_io_timeout_store(struct config_item *item, }CONFIGFS_ATTR (nvmet_passthru_, io_timeout); +static ssize_t nvmet_passthru_clear_ids_show (struct config_item *item, +char *page) +{ +return sprintf (page,"%u\n" ,to_subsys (item->ci_parent)->clear_ids); +} + +static ssize_t nvmet_passthru_clear_ids_store (struct config_item *item, +const char *page,size_t count) +{ +struct nvmet_subsys *subsys =to_subsys (item->ci_parent); +unsigned int clear_ids; + +if (kstrtouint (page,0 , &clear_ids)) +return -EINVAL ; + subsys->clear_ids = clear_ids; +return count; +} +CONFIGFS_ATTR (nvmet_passthru_, clear_ids); +static struct configfs_attribute *nvmet_passthru_attrs[] = { &nvmet_passthru_attr_device_path, &nvmet_passthru_attr_enable, &nvmet_passthru_attr_admin_timeout, &nvmet_passthru_attr_io_timeout, + &nvmet_passthru_attr_clear_ids,NULL , };
drivers/nvme/target/core.c +4 -0
@@ -1374,6 +1374,10 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn, ctrl->port = req->port; ctrl->ops = req->ops; +/* By default, set loop targets to clear IDS by default */ +if (ctrl->port->disc_addr.trtype ==NVMF_TRTYPE_LOOP ) + subsys->clear_ids =1 ; +INIT_WORK (&ctrl->async_event_work, nvmet_async_event_work);INIT_LIST_HEAD (&ctrl->async_events);INIT_RADIX_TREE (&ctrl->p2p_ns_map,GFP_KERNEL );
drivers/nvme/target/nvmet.h +1 -0
@@ -249,6 +249,7 @@ struct nvmet_subsys {struct config_group passthru_group;unsigned int admin_timeout;unsigned int io_timeout; +unsigned int clear_ids;#endif /* CONFIG_NVME_TARGET_PASSTHRU */ #ifdef CONFIG_BLK_DEV_ZONED
drivers/nvme/target/passthru.c +57 -0
75 lines not on this page · raw message
Signature · 1 line
2.31.1
Christoph Hellwig
maintainerThanks,
I've added this to nvme-5.19 with a Fixes attribute.