nvme-cli: fix disconnect-all for pcie tp
cover nvme-cli: fix disconnect-all for pcie tp
The first patch fixes that it tries to delete_controller even it's a controller with PCIe transport type. If so, the rest of the controller with fabrics type might not be disconnected properly.
The second one is just a trivial clean-up patch.
Minwoo Im (2):
nvme-cli: don't try to disconnect for ctrl with pcie transport
nvme-cli: remove unnecessary initialize of local var
fabrics.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Signature · 1 line
2.21.0
PATCH 1/2 nvme-cli: don't try to disconnect for ctrl with pcie transport
If a host system has both pcie and fabrics controllers, the following nvme-cli disconnect-all command will might not be working because contrlller with pcie transport does not have delete_controller in sysfs.
root at target:~# nvme list
Node SN Model Namespace Usage Format FW Rev
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1 foo QEMU NVMe Ctrl 1 536.87 MB / 536.87 MB 512 B + 0 B 1.0 /dev/nvme1n1 b92326b9b2323bf0 Linux 1 134.22 MB / 134.22 MB 512 B + 0 B 5.1.0-rc /dev/nvme2n1 65fa04eddd9bbac0 Linux 1 134.22 MB / 134.22 MB 512 B + 0 B 5.1.0-rc
root at target:~/nvme-cli.git# nvme disconnect-all
Failed to open /sys/class/nvme/nvme0/delete_controller: No such file or directory
This patch checks the transport type of the controller in iteration.
--- fabrics.c | 2 ++ 1 file changed, 2 insertions(+)
fabrics.c +2 -0
@@ -1196,6 +1196,8 @@ int disconnect_all(const char *desc, int argc, char **argv)for (j =0 ; j < subsys->nctrls; j++) {struct ctrl_list_item *ctrl = &subsys->ctrls[j]; +if (!strcmp (ctrl->transport,"pcie" )) +continue ; ret =disconnect_by_device (ctrl->name);if (ret)
Signature · 1 line
2.21.0
PATCH 2/2 nvme-cli: remove unnecessary initialize of local var
In reply to Minwoo ImThis patch does not have any functional changes here. Just clean-up the unnecessary initialize.
--- fabrics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fabrics.c +1 -1
@@ -1180,7 +1180,7 @@ int disconnect(const char *desc, int argc, char **argv)int disconnect_all (const char *desc,int argc,char **argv) {struct subsys_list_item *slist; -int i, j, ret =0 , subcnt =0 ; +int i, j, ret, subcnt =0 ;const struct argconfig_commandline_options command_line_options[] = { {NULL }, };
Signature · 1 line
2.21.0
PATCH 2/2 nvme-cli: remove unnecessary initialize of local var
Looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
Quoted 21 lines · Minwoo Im
This patch does not have any functional changes here. Just clean-up the unnecessary initialize.
Signed-off-by Minwoo Im <minwoo.im.dev at gmail.com>--- fabrics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fabrics.c +1
-1@@ -1180,7 +1180,7 @@ int disconnect(const char *desc, int argc, char **argv)int disconnect_all (const char *desc,int argc,char **argv) {struct subsys_list_item *slist; -int i, j, ret =0 , subcnt =0 ; +int i, j, ret, subcnt =0 ;const struct argconfig_commandline_options command_line_options[] = { {NULL }, };
PATCH 1/2 nvme-cli: don't try to disconnect for ctrl with pcie transport
In reply to Minwoo ImLooks good.
Quoted 3 lines · Minwoo Im
If a host system has both pcie and fabrics controllers, the following nvme-cli disconnect-all command will might not be working because contrlller with pcie transport does not have
delete_controllerin sysfs.
Can we please move following block of the output into the comment(not sure if that is the right name)
of the patch section ? i.e. after signoff... line. This can be done at the merge time also.
---
output
---
fabrics.c | 2 ++
Quoted 23 lines
root at target:~# nvme list
Node SN Model Namespace Usage Format FW Rev
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------/dev/nvme0n1 foo QEMU NVMe Ctrl 1 536.87 MB / 536.87 MB 512 B + 0 B 1.0 /dev/nvme1n1 b92326b9b2323bf0 Linux 1 134.22 MB / 134.22 MB 512 B + 0 B 5.1.0-rc /dev/nvme2n1 65fa04eddd9bbac0 Linux 1 134.22 MB / 134.22 MB 512 B + 0 B 5.1.0-rcroot at target:~/nvme-cli.git# nvme disconnect-all
Failed to open/sys/class/nvme/nvme0/delete_controller: No such file or directoryThis patch checks the transport type of the controller in iteration.
Signed-off-by Minwoo Im <minwoo.im.dev at gmail.com>--- fabrics.c | 2 ++ 1 file changed, 2 insertions(+)fabrics.c +0
-0
fabrics.c int disconnect_all(const char *desc, int argc, char **argv) · line 1199
Quoted 4 lines
fabrics.c +1
-0@@ -1196,6 +1196,8 @@ int disconnect_all(const char *desc, int argc, char **argv)for (j =0 ; j < subsys->nctrls; j++) {struct ctrl_list_item *ctrl = &subsys->ctrls[j]; +if (!strcmp (ctrl->transport,"pcie" ))
I didn't looked into the case but it is safe to use strcasecmp()? if you are sure strcmp()
will do the job, please disregard this comment.
Quoted 4 lines
fabrics.c +1
-0+continue ; ret =disconnect_by_device (ctrl->name);if (ret)
cover nvme-cli: fix disconnect-all for pcie tp
In reply to Minwoo ImGentle ping here.
Sagi Grimberg
maintainercover nvme-cli: fix disconnect-all for pcie tp
For both patches:
Keith Busch
maintainercover nvme-cli: fix disconnect-all for pcie tp
In reply to Minwoo ImQuoted 5 lines · Minwoo Im
The first patch fixes that it tries to
delete_controllereven it's a controller with PCIe transport type. If so, the rest of the controller with fabrics type might not be disconnected properly.The second one is just a trivial clean-up patch.
Thanks, added with Sagi and Chaitanya's reviews.
PATCH 1/2 nvme-cli: don't try to disconnect for ctrl with pcie transport
In reply to Chaitanya KulkarniQuoted 9 lines · Chaitanya Kulkarni
Looks good.
Reviewed-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>Quoted 3 lines · Minwoo Im
If a host system has both pcie and fabrics controllers, the following nvme-cli disconnect-all command will might not be working because contrlller with pcie transport does not have
delete_controllerin sysfs.
Quoted 5 lines
Can we please move following block of the output into the comment(not sure if that is the right name)
of the patch section ? i.e. after signoff... line. This can be done at the merge time also.
Chaitanya,
Sorry for lately response here. I don't get what you really mean here. Could you please explain why should we move the following output lines to after --- blocks ?
Quoted 33 lines
---
output
---
fabrics.c| 2 ++Quoted 24 lines
root at target:~# nvme list
Node SN Model Namespace Usage Format FW Rev
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------/dev/nvme0n1 foo QEMU NVMe Ctrl 1 536.87 MB / 536.87 MB 512 B + 0 B 1.0 /dev/nvme1n1 b92326b9b2323bf0 Linux 1 134.22 MB / 134.22 MB 512 B + 0 B 5.1.0-rc /dev/nvme2n1 65fa04eddd9bbac0 Linux 1 134.22 MB / 134.22 MB 512 B + 0 B 5.1.0-rcroot at target:~/nvme-cli.git# nvme disconnect-all
Failed to open/sys/class/nvme/nvme0/delete_controller: No such file or directoryThis patch checks the transport type of the controller in iteration.
Signed-off-by Minwoo Im <minwoo.im.dev at gmail.com>--- fabrics.c | 2 ++ 1 file changed, 2 insertions(+)fabrics.c +0
-0@@ -1196,6 +1196,8 @@ int disconnect_all(const char *desc, int argc, char **argv)
Quoted 8 lines
fabrics.c int disconnect_all(const char *desc, int argc, char **argv) · line 1199
Quoted 3 lines
fabrics.c +1
-0for (j =0 ; j < subsys->nctrls; j++) {struct ctrl_list_item *ctrl = &subsys->ctrls[j]; +if (!strcmp (ctrl->transport,"pcie" ))I didn't looked into the case but it is safe to use
strcasecmp()? if you are surestrcmp()will do the job, please disregard this comment.
strcmp() is enough to go here :)