linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Balbir Singh <sblbir@amazon.com>
To: <linux-nvme@lists.infradead.org>
Cc: Sagi Grimberg <sagi@grimberg.me>, Jens Axboe <axboe@fb.com>,
	Someswarudu Sangaraju <ssomesh@amazon.com>,
	Keith Busch <kbusch@kernel.org>, Balbir Singh <sblbir@amazon.com>,
	Christoph Hellwig <hch@lst.de>
Subject: [RFC][PATCH] nvme/core: Notify udev about capacity change
Date: Fri, 29 Nov 2019 00:27:46 +0000	[thread overview]
Message-ID: <20191129002746.6622-1-sblbir@amazon.com> (raw)

From: Someswarudu Sangaraju <ssomesh@amazon.com>

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.

Signed-off-by: Someswarudu Sangaraju <ssomesh@amazon.com>
[Balbir - send the notification only on capacity change and wrote the
changelog]
Signed-off-by: Balbir Singh <sblbir@amazon.com>
---
 drivers/nvme/host/core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index dfe37a525f3a..a413aee3107d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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);
-- 
2.16.5


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

             reply	other threads:[~2019-11-29  0:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-29  0:27 Balbir Singh [this message]
2019-11-29  8:24 ` [RFC][PATCH] nvme/core: Notify udev about capacity change Christoph Hellwig
2019-12-02 23:35   ` Singh, Balbir
2019-12-03  6:54     ` hch
2019-12-03  7:26       ` Chaitanya Kulkarni
2019-12-03  7:34         ` hch
2019-12-03 12:43           ` Johannes Thumshirn
2019-12-03 12:52             ` hch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191129002746.6622-1-sblbir@amazon.com \
    --to=sblbir@amazon.com \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=ssomesh@amazon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).