[PATCH V4 3/9] nvme: fix race condition between connected uevent and STARTED_ONCE flag

Daniel Wagner dwagner at suse.de
Fri May 8 09:57:40 PDT 2026


On Fri, May 08, 2026 at 03:33:29PM +0200, Maurizio Lombardi wrote:
> When a controller connects, nvme_start_ctrl() emits the
> "NVME_EVENT=connected" uevent and sets the NVME_CTRL_STARTED_ONCE flag.
> Currently, the uevent is emitted before the flag is set.
> 
> This creates a race condition for userspace tools (like udev rules)
> that might rely on the "connected" event to configure sysfs attributes.
> Specifically, if a udev rule attempts to set the newly introduced
> `admin_timeout` attribute immediately after receiving the uevent,
> the sysfs store function might evaluate the NVME_CTRL_STARTED_ONCE
> bit before it is actually set, resulting in spurious -EBUSY error.
> 
> Swap the order of operations in nvme_start_ctrl() so that the
> NVME_CTRL_STARTED_ONCE flag is set before the uevent is sent.
> This guarantees that the admin_timeout can already be changed
> when userspace is notified.
> 
> Signed-off-by: Maurizio Lombardi <mlombard at redhat.com>

Reviewed-by: Daniel Wagner <dwagner at suse.de>



More information about the Linux-nvme mailing list