Skip to content

Commit

Permalink
nvmet: generate AEN for ns revalidate size change
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Sagi Grimberg <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
ChaitanayaKulkarni authored and Christoph Hellwig committed May 27, 2020
1 parent 463c5fa commit de124f4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/nvme/target/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit de124f4

Please sign in to comment.