Skip to contentSkip to conversation

nvme: Mark external NVMe devices as removable

PATCH In review Kai-Heng Feng 3 participants 7 messages Jan 12, 2022 – Jan 14, 2022 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: Mark external NVMe devices as removable

Commit c037b6c818c3 ("PCI: Add sysfs "removable" attribute") can mark entire Thunderbolt hierarchy as removable, if system firmware provides correct attribute.

So apply GENHD_FL_REMOVABLE for NVMe if removable bit is set, to make userspace daemon like Udisks knows it can be automount.

---
 drivers/nvme/host/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/nvme/host/core.c +3 -0
index 1af8a4513708a..1c3b04883965f 100644
@@ -3851,6 +3851,9 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
 	ns->disk = disk;
 	ns->queue = disk->queue;
 
+	if (dev_is_removable(ctrl->dev))
+		ns->disk->flags |= GENHD_FL_REMOVABLE;
+
 	if (ctrl->opts && ctrl->opts->data_digest)
 		blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, ns->queue);
 
Signature · 1 line
2.33.1
#1 lore raw
Quoted 6 lines · Kai-Heng Feng

Commit c037b6c818c3 ("PCI: Add sysfs "removable" attribute") can mark entire Thunderbolt hierarchy as removable, if system firmware provides correct attribute.

So apply GENHD_FL_REMOVABLE for NVMe if removable bit is set, to make userspace daemon like Udisks knows it can be automount.

GENHD_FL_REMOVABLE means removable media as in floppies or CD-ROMs, which does not apply to NVMe at all.

#2 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Kai-Heng Feng

Commit c037b6c818c3 ("PCI: Add sysfs "removable" attribute") can mark entire Thunderbolt hierarchy as removable, if system firmware provides correct attribute.

So apply GENHD_FL_REMOVABLE for NVMe if removable bit is set, to make userspace daemon like Udisks knows it can be automount.

GENHD_FL_REMOVABLE means removable media as in floppies or CD-ROMs, which does not apply to NVMe at all.

USB thumb drives also use this flag, so I am not sure why it's not applicable to NVMe?

Kai-Heng

#3 lore raw
Quoted 2 lines · Kai-Heng Feng

USB thumb drives also use this flag, so I am not sure why it's not applicable to NVMe?

They shouldn't report this flag and might need fixing.

#4 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Kai-Heng Feng

USB thumb drives also use this flag, so I am not sure why it's not applicable to NVMe?

They shouldn't report this flag and might need fixing.

So what should we do? Introduce a different flag but with identical usage for external USB and NVMe storages?

Kai-Heng

maintainer
#5 lore raw
Quoted 10 lines · Kai-Heng Feng
Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Kai-Heng Feng

USB thumb drives also use this flag, so I am not sure why it's not applicable to NVMe?

They shouldn't report this flag and might need fixing.

So what should we do? Introduce a different flag but with identical usage for external USB and NVMe storages?

What's the user visible result with this flag set? Does some rule automatically mount a 'removable' block device's filesystem partitions to something like /media/?

#6 lore raw
Quoted 8 lines · Keith Busch
Quoted 6 lines · Kai-Heng Feng
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Kai-Heng Feng

USB thumb drives also use this flag, so I am not sure why it's not applicable to NVMe?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

They shouldn't report this flag and might need fixing.

So what should we do? Introduce a different flag but with identical usage for external USB and NVMe storages?

What's the user visible result with this flag set? Does some rule automatically mount a 'removable' block device's filesystem partitions to something like /media/?

Udisks uses 'removable' to flag its 'HintAuto' attribute, and GNOME Shell will automount the disk based on 'HintAuto'.

Kai-Heng