nvme/core: Notify udev about capacity change
RFC PATCH 1/1 nvme/core: Notify udev about capacity change
From: Someswarudu Sangaraju <[email protected]>
NVME capacity can change asynchronously via NVME_AER_NOTICE_NS_CHANGED The current stack does the right thing and resizes the disk via set_capacity() called from nvme_update_disk_info(). This patch adds a user space notification via uevent to let udev know that a resize occurred if the capacity changes.
[Balbir - send the notification only on capacity change and wrote the changelog]
--- drivers/nvme/host/core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/nvme/host/core.c +6 -0
@@ -1757,6 +1757,7 @@ static void nvme_update_disk_info(struct gendisk *disk, struct nvme_ns *ns, struct nvme_id_ns *id) { sector_t capacity = nvme_lba_to_sect(ns, le64_to_cpu(id->nsze)); +sector_t old_capacity =get_capacity (disk);unsigned short bs =1 << ns->lba_shift;u32 atomic_bs, phys_bs, io_opt;
@@ -1807,6 +1808,11 @@ static void nvme_update_disk_info(struct gendisk *disk, capacity =0 ;set_capacity (disk, capacity); +if (old_capacity != capacity) { +char *envp[] = {"RESIZE=1" ,NULL }; + +kobject_uevent_env (&disk_to_dev (disk)->kobj,KOBJ_CHANGE , envp); + }nvme_config_discard (disk, ns);nvme_config_write_zeroes (disk, ns);
Signature · 7 lines
2.16.5 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerI don't think this makes sense, and they way it has been done in virtio_blk and xen-blkfront is an utter hack. Please first add a properly documented block helper, and then make sure it doesn't send the even for the first call that moves from a 0 capacity. SCSI also will need updating to use the helper.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 5 lines · Christoph Hellwig
I don't think this makes sense, and they way it has been done in
virtio_blkand xen-blkfront is an utter hack. Please first add a properly documented block helper, and then make sure it doesn't send the even for the first call that moves from a 0 capacity. SCSI also will need updating to use the helper.
Makes sense, I am wondering if I should refactor set_capacity to __set_capacity and have set_capacity do notifcations for
oldsize vs newsize where oldsize is not 0
Balbir Singh.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
[email protected]
maintainerQuoted 7 lines · Balbir
Quoted 5 lines · Christoph Hellwig
I don't think this makes sense, and they way it has been done in
virtio_blkand xen-blkfront is an utter hack. Please first add a properly documented block helper, and then make sure it doesn't send the even for the first call that moves from a 0 capacity. SCSI also will need updating to use the helper.
Quoted 5 lines
Makes sense, I am wondering if I should refactor
set_capacityto__set_capacityand haveset_capacitydo notifcations foroldsize vs newsize where oldsize is not 0
I pretty much hate the set_capacity name to start with, so what about a more descriptive name for new the helper? blk_set_capacity?
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 2 lines · On 12/02/2019 10:54 PM, [email protected] wrote:
I pretty much hate the
set_capacityname to start with, so what about a more descriptive name for new the helper?blk_set_capacity?
Do we also need a blk_mq_ops or appropriate block layer callback capacity change function, so that file systems can register a callback function to take an appropriate action, e.g. rebuilding the metadata with new size ?
If this make sense I'll be happy to take a look.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
[email protected]
maintainerQuoted 10 lines · Chaitanya Kulkarni
Quoted 2 lines · On 12/02/2019 10:54 PM, [email protected] wrote:
I pretty much hate the
set_capacityname to start with, so what about a more descriptive name for new the helper?blk_set_capacity?Do we also need a
blk_mq_opsor appropriate block layer callback capacity change function, so that file systems can register a callback function to take an appropriate action, e.g. rebuilding the metadata with new size ?If this make sense I'll be happy to take a look.
Well, and op isn't going to help with file system notifications as that goes the other way around. We'd probably need some way how file systems can register a new callback into the existing block device events framework that is used for media changes.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 10 lines · On Tue, Dec 03, 2019 at 08:34:47AM +0100, [email protected] wrote:
Quoted 9 lines · Chaitanya Kulkarni
Quoted 2 lines · On 12/02/2019 10:54 PM, [email protected] wrote:
I pretty much hate the
set_capacityname to start with, so what about a more descriptive name for new the helper?blk_set_capacity?Do we also need a
blk_mq_opsor appropriate block layer callback capacity change function, so that file systems can register a callback function to take an appropriate action, e.g. rebuilding the metadata with new size ?
Quoted 6 lines
Quoted 1 line
If this make sense I'll be happy to take a look.
Well, and op isn't going to help with file system notifications as that goes the other way around. We'd probably need some way how file systems can register a new callback into the existing block device events framework that is used for media changes.
I had this on my TODO List but one thing stopped my endeavors, having a "notifier" for resize is easy when we only grow the block-device, but what should the FS do when we shrink it?
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
[email protected]
maintainerQuoted 3 lines · Johannes Thumshirn
I had this on my TODO List but one thing stopped my endeavors, having a "notifier" for resize is easy when we only grow the block-device, but what should the FS do when we shrink it?
Assuming this is a "normal" fs and not something fancy with built in redundancy - shut the file system down and stop any new access to it as that would just make things worse.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme