* [PATCH] nvmet: send namespace changed event after namespace is fully initialized
@ 2026-10-02 7:01 Nilay Shroff
2026-10-13 14:37 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Nilay Shroff @ 2026-10-02 7:01 UTC (permalink / raw)
To: linux-nvme, linux-kernel
Cc: shinichiro.kawasaki, hch, kbusch, sagi, gjoyce, chaitanyak,
Nilay Shroff, stable
nvmet_ns_enable() queues the asynchronous namespace change event before
the namespace is enabled and the corresponding xarray entry is marked
with NVMET_NS_ENABLED. This may create a narrow race if the host
receives the namespace change event before the namespace is fully
initialized on the target. In that case, scanning the active namespace
list on the host may fail to find the namespace that is being enabled
on the target.
The blktests nvme/052 failure was reported[1] due to this race.
Fix the race by moving nvmet_ns_changed() in nvmet_ns_enable() after
the namespace is enabled, the xarray entry is marked with
NVMET_NS_ENABLED, and the NVMET_NS_IO_LIVE flag is set.
Cc: stable@vger.kernel.org
Fixes: 74d16965d7ac ("nvmet-loop: avoid using mutex in IO hotpath")
Reported-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Closes: https://lore.kernel.org/all/ar30Q5H1fuyFtDwM@shinmob/ [1]
Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
drivers/nvme/target/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 8eea0a504308..da98e5cae7f6 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -626,11 +626,11 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
if (ret)
goto out_pr_exit;
- nvmet_ns_changed(subsys, ns->nsid);
ns->enabled = true;
xa_set_mark(&subsys->namespaces, ns->nsid, NVMET_NS_ENABLED);
nvmet_debugfs_ns_setup(ns);
set_bit(NVMET_NS_IO_LIVE, &ns->flags);
+ nvmet_ns_changed(subsys, ns->nsid);
ret = 0;
out_unlock:
mutex_unlock(&subsys->lock);
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nvmet: send namespace changed event after namespace is fully initialized
2026-10-02 7:01 [PATCH] nvmet: send namespace changed event after namespace is fully initialized Nilay Shroff
@ 2026-10-13 14:37 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2026-10-13 14:37 UTC (permalink / raw)
To: Nilay Shroff
Cc: linux-nvme, linux-kernel, shinichiro.kawasaki, hch, kbusch, sagi,
gjoyce, chaitanyak, stable
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-13 14:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-02 7:01 [PATCH] nvmet: send namespace changed event after namespace is fully initialized Nilay Shroff
2026-10-13 14:37 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®