Re: [PATCH v2 1/2] nvmet: defer setting ns->enabled to false in nvmet_ns_disable()
From: Shin'ichiro Kawasaki
Date: Thu Oct 01 2026 - 23:22:58 EST
On Oct 01, 2026 / 17:12, Nilay Shroff wrote:
[...]
> > Recent blktests-ci trial runs for nvme-7.3 branch reported failure of nvme/052
> > [*]. It is required to repeat the test case 3 to 20 times to recreate the
> > failure on my test system. I bisected and find this patch is the trigger of the
> > failure.
> >
> > Nilay, may I ask you to take a look in the failure? I'm not sure if this should
> > be addressed in kernel side of blktests side.
>
> Thanks for the report! I looked into the failure and I think I found the root cause.
> I couldn't reproduce it on my system, but I see there is a narrow race window that can
> potentially trigger the observed failure.
>
> I don't think this is a new race introduced by this patch. However, the changes in this
> patch may have altered the timing enough to make the race easier to trigger.
>
> In nvmet_ns_enable(), we currently queue the asynchronous namespace-change event
> before setting ns->enabled and the corresponding NVMET_NS_ENABLED xarray mark.
> Therefore, if the asynchronous namespace-change event is received and processed
> by the host before the namespace is fully enabled on the target, the host may not
> find the namespace while scanning the active namespace list.
>
> To close this race, I think we should send the namespace-change notification only
> after the namespace has been fully enabled in nvmet_ns_enable(). In particular,
> we can move nvmet_ns_changed() after setting ns->enabled, the NVMET_NS_ENABLED
> xarray mark, and NVMET_NS_IO_LIVE.
>
> Could you please try the following change on your test system and let me know if
> it fixes the failure? If this resolves the issue, I'll send a formal patch:
(snip)
Thank you for this swift action. I applied the fix trial change on top of the
kernel at the nvme-7.3 branch (git hash 4a5e49ba0abb), and confirmed the failure
goes away by repeating the test case nvme/052 one hundred times. Good :)
When you post the fix as the formal patch, please feel free to add,
Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx>