drivers/nvme/host/core.c | 3 +++ 1 file changed, 3 insertions(+)
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@google.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@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
On Wed, Jan 12, 2022 at 09:31:54AM +0800, Kai-Heng Feng wrote:
> 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.
On Wed, Jan 12, 2022 at 3:17 PM Christoph Hellwig <hch@lst.de> wrote:
>
> On Wed, Jan 12, 2022 at 09:31:54AM +0800, Kai-Heng Feng wrote:
> > 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
On Wed, Jan 12, 2022 at 08:50:33PM +0800, Kai-Heng Feng wrote: > 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.
On Wed, Jan 12, 2022 at 10:03 PM Christoph Hellwig <hch@lst.de> wrote: > > On Wed, Jan 12, 2022 at 08:50:33PM +0800, Kai-Heng Feng wrote: > > 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
On Thu, Jan 13, 2022 at 02:39:02PM +0800, Kai-Heng Feng wrote: > On Wed, Jan 12, 2022 at 10:03 PM Christoph Hellwig <hch@lst.de> wrote: > > > > On Wed, Jan 12, 2022 at 08:50:33PM +0800, Kai-Heng Feng wrote: > > > 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/?
On Fri, Jan 14, 2022 at 12:12 AM Keith Busch <kbusch@kernel.org> wrote: > > On Thu, Jan 13, 2022 at 02:39:02PM +0800, Kai-Heng Feng wrote: > > On Wed, Jan 12, 2022 at 10:03 PM Christoph Hellwig <hch@lst.de> wrote: > > > > > > On Wed, Jan 12, 2022 at 08:50:33PM +0800, Kai-Heng Feng wrote: > > > > 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/? Udisks uses 'removable' to flag its 'HintAuto' attribute, and GNOME Shell will automount the disk based on 'HintAuto'. Kai-Heng
© 2016 - 2026 Red Hat, Inc.