2019-05-29 15:08:06 |
Dmitrii Shcherbakov |
description |
Currently by-dname symlinks are created based on serial numbers of controllers.
We started getting hardware with multi-path support that uses a different naming scheme and can support multiple namespaces per controller.
It would be good to bind block device symlinks for namespaces to namespace GUIDs (NGUID) instead of controller serial numbers.
See https://bugs.launchpad.net/curtin/+bug/1735839/comments/16 for more details and the NVMe spec reference around NGUID uniqueness and lifetime.
https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/bionic/tree/drivers/nvme/host/multipath.c?id=Ubuntu-4.15.0-51.55#n22
void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
struct nvme_ctrl *ctrl, int *flags)
{
if (!multipath) {
sprintf(disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance);
} else if (ns->head->disk) {
sprintf(disk_name, "nvme%dc%dn%d", ctrl->subsys->instance,
// ... |
Currently by-dname symlinks are created based on serial numbers of controllers.
We started getting hardware with multi-path support that uses a different naming scheme and can support multiple namespaces per controller.
It would be good to bind block device symlinks for namespaces to namespace GUIDs (NGUID) instead of controller serial numbers.
See https://bugs.launchpad.net/curtin/+bug/1735839/comments/16 for more details and the NVMe spec reference around NGUID uniqueness and lifetime.
https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/bionic/tree/drivers/nvme/host/multipath.c?id=Ubuntu-4.15.0-51.55#n17
static bool multipath = true;
module_param(multipath, bool, 0444);
https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/bionic/tree/drivers/nvme/host/multipath.c?id=Ubuntu-4.15.0-51.55#n22
/*
* If multipathing is enabled we need to always use the subsystem instance
* number for numbering our devices to avoid conflicts between subsystems that
* have multiple controllers and thus use the multipath-aware subsystem node
* and those that have a single controller and use the controller node
* directly.
*/
void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
struct nvme_ctrl *ctrl, int *flags)
{
if (!multipath) {
sprintf(disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance);
} else if (ns->head->disk) {
sprintf(disk_name, "nvme%dc%dn%d", ctrl->subsys->instance,
ctrl->cntlid, ns->head->instance);
*flags = GENHD_FL_HIDDEN;
// ...
For example, with this controller and a default namespace that we wanted to use:
81:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller 172Xa/172Xb (rev 01)
uname -a
Linux node-9 4.15.0-50-generic #54-Ubuntu SMP Mon May 6 18:46:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
udevadm info -q all -n /dev/nvme0n1 | grep DEVPATH
E: DEVPATH=/devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1
readlink /sys/class/block/nvme0n1
../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1
readlink /sys/class/block/nvme0c33n1
../../devices/pci0000:80/0000:80:01.0/0000:81:00.0/nvme/nvme0/nvme0c33n1
lsblk -p
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
/dev/sda 8:0 0 1.8T 0 disk
├─/dev/sda1 8:1 0 512M 0 part /boot/efi
└─/dev/sda2 8:2 0 1.8T 0 part /
/dev/sdb 8:16 0 1.8T 0 disk
/dev/sdc 8:32 0 1.8T 0 disk
/dev/sdd 8:48 0 1.8T 0 disk
/dev/sde 8:64 0 1.8T 0 disk
/dev/sdf 8:80 0 1.8T 0 disk
/dev/sdg 8:96 0 1.8T 0 disk
/dev/sdh 8:112 0 1.8T 0 disk
/dev/sdi 8:128 0 1.8T 0 disk
/dev/sdj 8:144 0 1.8T 0 disk
/dev/sdk 8:160 0 1.8T 0 disk
/dev/sdl 8:176 0 111.3G 0 disk
/dev/sdm 8:192 0 3.7T 0 disk
/dev/sr0 11:0 1 1024M 0 rom
/dev/nvme0n1 259:1 0 1.5T 0 disk
ls -la /dev/nvme*
crw------- 1 root root 243, 0 May 29 14:10 /dev/nvme0
brw-rw---- 1 root disk 259, 1 May 29 14:10 /dev/nvme0n1
nvme0c33n1 is hidden is not shown in /dev/ (and lsblk does not report it) because GENHD_FL_HIDDEN is applied to those block device entries:
See:
https://github.com/torvalds/linux/commit/8ddcd653257c18a669fcb75ee42c37054908e0d6
https://patchwork.kernel.org/patch/10015051/ |
|