[PATCH] nvme: Mark external NVMe devices as removable
Kai-Heng Feng
kai.heng.feng at canonical.com
Tue Jan 11 17:31:54 PST 2022
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.
Cc: Rajat Jain <rajatja at google.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng at canonical.com>
---
drivers/nvme/host/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 1af8a4513708a..1c3b04883965f 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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);
--
2.33.1
More information about the Linux-nvme
mailing list