Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvme disconnect -d fails to disconnect nvme block device #563

Closed
pszczerx opened this issue Sep 4, 2019 · 3 comments
Closed

nvme disconnect -d fails to disconnect nvme block device #563

pszczerx opened this issue Sep 4, 2019 · 3 comments

Comments

@pszczerx
Copy link
Contributor

pszczerx commented Sep 4, 2019

Issue description

The latest version of nvme CLI tool fails to disconnect nvme block device.
Example:
$ nvme disconnect -d /dev/nvme0n1
The command will succeed only if you pass NVMe character device (controller) as an argument.
Example:
$ sudo nvme disconnect -d /dev/nvme0

As far as I can tell, this issue was introduced by commit: 986a935
strcmp() function in line 986a935#diff-43e749b3fb33e89f12c38df0ad81a1c5R203 returns a non-zero return value, because content of char d[64]; array does not contain namespace suffix (i.e. device=nvme0n1 d=nvme0).

Older version of nvme CLI tool used to disconnect the controller when you passed a path to nvme block device.

nvme CLI help snippet

nvme --help                 
nvme-1.9.9.g5221                                                   
usage: nvme <command> [<device>] [<args>]                     
                                                              
The '<device>' may be either an NVMe character device (ex: /dev/nvme0) or an
nvme block device (ex: /dev/nvme0n1). 

Version Information

$ sudo nvme version
nvme version 1.9.9.g5221

Steps to reproduce

$ sudo nvme list | cut -d ' ' -f 1
Node
----------------
/dev/nvme0n1
/dev/nvme0n2
/dev/nvme0n3
/dev/nvme0n4
/dev/nvme0n5
/dev/nvme0n6
/dev/nvme0n7

$ sudo nvme disconnect -d /dev/nvme0n1
Failed to disconnect by device name: /dev/nvme0n1
$ 
$ sudo nvme list | cut -d ' ' -f 1
Node
----------------
/dev/nvme0n1
/dev/nvme0n2
/dev/nvme0n3
/dev/nvme0n4
/dev/nvme0n5
/dev/nvme0n6
/dev/nvme0n7

$ sudo nvme disconnect -d /dev/nvme0q
$ sudo nvme list | cut -d ' ' -f 1
$

Logs from nvme CLI 1.7

$ sudo nvme version
nvme version 1.7
$ sudo nvme list | cut -d ' ' -f 1
Node
----------------
/dev/nvme0n1
/dev/nvme0n2
/dev/nvme0n3
/dev/nvme0n4
/dev/nvme0n5
/dev/nvme0n6
/dev/nvme0n7
$ sudo nvme disconnect -d /dev/nvme0n1
$ sudo nvme list
$ 

Could you clarify whether this change was intentional?

Thanks for help,
Przemek

@keithbusch
Copy link
Contributor

I think that was intentional due to the namespace and character name swizzling. I'll double check with the author.

@keithbusch
Copy link
Contributor

Okay, the removal is done by writing to /sys/class/nvme/nvme/delete_controler, but you can't get to that unique path from a namespace handle with multipathing because the namespace may have more than one controller. We wouldn't be able to figure out the intended one to remove from a namespace handle.

@pszczerx
Copy link
Contributor Author

Thanks for looking into the issue @keithbusch. If this change was intentional, then I think this issue can be closed.

openstack-gerrit pushed a commit to openstack/os-brick that referenced this issue Oct 16, 2019
nvme-cli no longer allows to use a path to nvme block device
(e.g. /dev/nvme0n1) as an argument to nvme disconnect command.
For more details, please see:
linux-nvme/nvme-cli#563

To address this issue, change the command that is executed to
disconnect a volume from:

$ nvme disconnect -d <device>

to:

$ nvme disconnect -n <subnqn>

Change-Id: I51a30825da5e7378ebc1d6f4a12645d73d7feb19
Closes-Bug: #1843431
Signed-off-by: Szczerbik, Przemyslaw <przemyslawx.szczerbik@intel.com>
openstack-gerrit pushed a commit to openstack/openstack that referenced this issue Oct 16, 2019
* Update os-brick from branch 'master'
  - nvmeof: Use subnqn to disconnect a volume
    
    nvme-cli no longer allows to use a path to nvme block device
    (e.g. /dev/nvme0n1) as an argument to nvme disconnect command.
    For more details, please see:
    linux-nvme/nvme-cli#563
    
    To address this issue, change the command that is executed to
    disconnect a volume from:
    
    $ nvme disconnect -d <device>
    
    to:
    
    $ nvme disconnect -n <subnqn>
    
    Change-Id: I51a30825da5e7378ebc1d6f4a12645d73d7feb19
    Closes-Bug: #1843431
    Signed-off-by: Szczerbik, Przemyslaw <przemyslawx.szczerbik@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants