nvmet: fix port check in nvmet_subsys_attr_qid_max_show
Subsystems (2)
PATCH 1/1 nvmet: fix port check in nvmet_subsys_attr_qid_max_show
The item passed into nvmet_subsys_attr_qid_max_show is not a member of struct nvmet_port, it is part of nvmet_subsys. Because we don't a link from the subsystem to a port we have to iterate over all ports and see if any of the ports are linked to the subsystem to figure out if the subsystem is in use.
Fixes 2c4282742d04 ("nvmet: Expose max queues to configfs")
Reported-by Shinichiro Kawasaki <[email protected]>
Signed-off-by Daniel Wagner <[email protected]>
--- drivers/nvme/target/configfs.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/nvme/target/configfs.c +14 -4
@@ -1290,11 +1290,21 @@ static ssize_t nvmet_subsys_attr_qid_max_show(struct config_item *item,static ssize_t nvmet_subsys_attr_qid_max_store (struct config_item *item,const char *page,size_t cnt) { -struct nvmet_port *port =to_nvmet_port (item); +struct nvmet_subsys *subsys =to_subsys (item); +struct nvmet_subsys_link *s; +struct nvmet_port *port;u16 qid_max; -if (nvmet_is_port_enabled (port, __func__)) -return -EACCES ; +down_write (&nvmet_config_sem); +list_for_each_entry (port, nvmet_ports, global_entry) { +list_for_each_entry (s, &port->subsystems, entry) { +if (s->subsys != subsys) +continue ; +up_write (&nvmet_config_sem); +return -EACCES ; + } + } +up_write (&nvmet_config_sem);if (sscanf (page,"%hu\n" , &qid_max) !=1 )return -EINVAL ;
@@ -1303,7 +1313,7 @@ static ssize_t nvmet_subsys_attr_qid_max_store(struct config_item *item,return -EINVAL ;down_write (&nvmet_config_sem); -to_subsys (item)->max_qid = qid_max; + subsys->max_qid = qid_max;up_write (&nvmet_config_sem);return cnt; }
Signature · 1 line
2.35.3