* [PATCH] nvme: Mark external NVMe devices as removable
@ 2022-01-12 1:31 Kai-Heng Feng
2022-01-12 7:16 ` Christoph Hellwig
0 siblings, 1 reply; 7+ messages in thread
From: Kai-Heng Feng @ 2022-01-12 1:31 UTC (permalink / raw)
To: kbusch, axboe, hch, sagi
Cc: Kai-Heng Feng, Rajat Jain, linux-nvme, linux-kernel
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] nvme: Mark external NVMe devices as removable
2022-01-12 1:31 [PATCH] nvme: Mark external NVMe devices as removable Kai-Heng Feng
@ 2022-01-12 7:16 ` Christoph Hellwig
2022-01-12 12:50 ` Kai-Heng Feng
0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2022-01-12 7:16 UTC (permalink / raw)
To: Kai-Heng Feng
Cc: kbusch, axboe, hch, sagi, Rajat Jain, linux-nvme, linux-kernel
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] nvme: Mark external NVMe devices as removable
2022-01-12 7:16 ` Christoph Hellwig
@ 2022-01-12 12:50 ` Kai-Heng Feng
2022-01-12 14:03 ` Christoph Hellwig
0 siblings, 1 reply; 7+ messages in thread
From: Kai-Heng Feng @ 2022-01-12 12:50 UTC (permalink / raw)
To: Christoph Hellwig
Cc: kbusch, axboe, sagi, Rajat Jain, linux-nvme, linux-kernel
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] nvme: Mark external NVMe devices as removable
2022-01-12 12:50 ` Kai-Heng Feng
@ 2022-01-12 14:03 ` Christoph Hellwig
2022-01-13 6:39 ` Kai-Heng Feng
0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2022-01-12 14:03 UTC (permalink / raw)
To: Kai-Heng Feng
Cc: Christoph Hellwig, kbusch, axboe, sagi, Rajat Jain, linux-nvme,
linux-kernel
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] nvme: Mark external NVMe devices as removable
2022-01-12 14:03 ` Christoph Hellwig
@ 2022-01-13 6:39 ` Kai-Heng Feng
2022-01-13 16:12 ` Keith Busch
0 siblings, 1 reply; 7+ messages in thread
From: Kai-Heng Feng @ 2022-01-13 6:39 UTC (permalink / raw)
To: Christoph Hellwig
Cc: kbusch, axboe, sagi, Rajat Jain, linux-nvme, linux-kernel
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] nvme: Mark external NVMe devices as removable
2022-01-13 6:39 ` Kai-Heng Feng
@ 2022-01-13 16:12 ` Keith Busch
2022-01-14 2:38 ` Kai-Heng Feng
0 siblings, 1 reply; 7+ messages in thread
From: Keith Busch @ 2022-01-13 16:12 UTC (permalink / raw)
To: Kai-Heng Feng
Cc: Christoph Hellwig, axboe, sagi, Rajat Jain, linux-nvme, linux-kernel
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/?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] nvme: Mark external NVMe devices as removable
2022-01-13 16:12 ` Keith Busch
@ 2022-01-14 2:38 ` Kai-Heng Feng
0 siblings, 0 replies; 7+ messages in thread
From: Kai-Heng Feng @ 2022-01-14 2:38 UTC (permalink / raw)
To: Keith Busch
Cc: Christoph Hellwig, axboe, sagi, Rajat Jain, linux-nvme, linux-kernel
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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-01-14 2:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 1:31 [PATCH] nvme: Mark external NVMe devices as removable Kai-Heng Feng
2022-01-12 7:16 ` Christoph Hellwig
2022-01-12 12:50 ` Kai-Heng Feng
2022-01-12 14:03 ` Christoph Hellwig
2022-01-13 6:39 ` Kai-Heng Feng
2022-01-13 16:12 ` Keith Busch
2022-01-14 2:38 ` Kai-Heng Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).