diff options
author | Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> | 2020-05-19 10:06:28 +0200 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2020-05-27 07:12:38 +0200 |
commit | de124f427347b0a1eb9708b1007251fc4c8a222f (patch) | |
tree | 4b0c402ceed1c8ea1728da4d2eb472fd4e7f6ab9 /drivers/nvme | |
parent | nvmet: add helper to revalidate bdev and file ns (diff) | |
download | linux-de124f427347b0a1eb9708b1007251fc4c8a222f.tar.xz linux-de124f427347b0a1eb9708b1007251fc4c8a222f.zip |
nvmet: generate AEN for ns revalidate size change
The newly added function nvmet_ns_revalidate() does update the ns size
in the identify namespace in-core target data structure when host issues
id-ns command. This can lead to host having inconsistencies between size
of the namespace present in the id-ns command result and size of the
corresponding block device until host scans the namespaces explicitly.
To avoid this scenario generate AEN if old size is not same as the new
one in nvmet_ns_revalidate().
This will allow automatic AEN generation when host calls id-ns command
and also allows target to install userspace rules so that it can trigger
nvmet_ns_revalidate() (using configfs interface with the help of next
patch) resulting in appropriate AEN generation when underlying namespace
size change is detected.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Sagi Grimberg <sagi@grimbeg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/target/core.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index ee5865568588..fb78b165c123 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -517,10 +517,15 @@ static void nvmet_p2pmem_ns_add_p2p(struct nvmet_ctrl *ctrl, void nvmet_ns_revalidate(struct nvmet_ns *ns) { + loff_t oldsize = ns->size; + if (ns->bdev) nvmet_bdev_ns_revalidate(ns); else nvmet_file_ns_revalidate(ns); + + if (oldsize != ns->size) + nvmet_ns_changed(ns->subsys, ns->nsid); } int nvmet_ns_enable(struct nvmet_ns *ns) |