* FAILED: patch "[PATCH] nvme: stop asynchronous event work before ANA teardown" failed to apply to 6.6-stable tree
@ 2026-12-02 13:51 gregkh
2026-12-03 8:52 ` [PATCH 6.6.y] nvme: stop asynchronous event work before ANA teardown Yaohan Li
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2026-12-02 13:51 UTC (permalink / raw)
To: shunsheng1218, hch, kbusch; +Cc: stable
The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 9b657c565984f28976b1e471e3ce2f81cc269238
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026120251-gaming-frenzied-7095@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 9b657c565984f28976b1e471e3ce2f81cc269238 Mon Sep 17 00:00:00 2001
From: Yaohan Li <shunsheng1218@gmail.com>
Date: Thu, 5 Nov 2026 19:41:49 +0800
Subject: [PATCH] nvme: stop asynchronous event work before ANA teardown
NVMe ANA work has several producers, including ANA AER completion,
namespace scanning and failover processing.
An AER completion can queue ana_work for an ANA notice and can
separately queue async_event_work, which sends the AEN uevent and
submits the next asynchronous event request. These work items access
controller-owned state during asynchronous processing.
This issue was investigated and the fix was developed with AI
assistance (ZCode/GLM-4).
Fixes: 0d0b660f214dc ("nvme: add ANA support")
Cc: stable@vger.kernel.org
Signed-off-by: Yaohan Li <shunsheng1218@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ed44d7882dd4..cd0df9b03806 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -5198,6 +5198,15 @@ EXPORT_SYMBOL_GPL(nvme_start_ctrl);
void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
{
nvme_stop_keep_alive(ctrl);
+
+ /*
+ * An AER completion can queue async_event_work; drain it before the
+ * controller's final release. Note that ana_work has additional
+ * producers (namespace scanning via nvme_scan_work, and the failover
+ * path in nvme_failover_req), which is why nvme_mpath_uninit()
+ * separately cancels ana_work after this point.
+ */
+ cancel_work_sync(&ctrl->async_event_work);
nvme_hwmon_exit(ctrl);
nvme_fault_inject_fini(&ctrl->fault_inject);
dev_pm_qos_hide_latency_tolerance(ctrl->device);
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index ae8059366b57..27facdbb3d4c 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -1608,6 +1608,13 @@ int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
{
+ /*
+ * ANA work can be queued by nvme_handle_aen_notice, nvme_scan_work,
+ * and nvme_failover_req. Drain remaining work before releasing the ANA
+ * resources.
+ */
+ cancel_work_sync(&ctrl->ana_work);
+
kvfree(ctrl->ana_log_buf);
ctrl->ana_log_buf = NULL;
ctrl->ana_log_size = 0;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 6.6.y] nvme: stop asynchronous event work before ANA teardown
2026-12-02 13:51 FAILED: patch "[PATCH] nvme: stop asynchronous event work before ANA teardown" failed to apply to 6.6-stable tree gregkh
@ 2026-12-03 8:52 ` Yaohan Li
2026-12-03 13:47 ` Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Yaohan Li @ 2026-12-03 8:52 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, Sasha Levin, Christoph Hellwig, Keith Busch,
linux-nvme
commit 9b657c565984f28976b1e471e3ce2f81cc269238 upstream.
NVMe ANA work has several producers, including ANA AER completion,
namespace scanning and failover processing.
An AER completion can queue ana_work for an ANA notice and can
separately queue async_event_work, which sends the AEN uevent and
submits the next asynchronous event request. These work items access
controller-owned state during asynchronous processing.
This issue was investigated and the fix was developed with AI
assistance (ZCode/GLM-4).
Fixes: 0d0b660f214dc ("nvme: add ANA support")
Cc: stable@vger.kernel.org
Signed-off-by: Yaohan Li <shunsheng1218@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
[Yaohan: resolved context conflict in nvme_uninit_ctrl() because commit
a54a93d0e359 ("nvme: move stopping keep-alive into nvme_uninit_ctrl()")
is not present in 6.6.y; nvme_stop_keep_alive() still runs earlier in
nvme_stop_ctrl().]
Signed-off-by: Yaohan Li <shunsheng1218@gmail.com>
---
Hi Greg, Sasha,
Here is the manual backport for linux-6.6.y. The only conflict was in
nvme_uninit_ctrl() because 6.6.y does not have commit a54a93d0e359
("nvme: move stopping keep-alive into nvme_uninit_ctrl()").
Build-tested and stress-tested on 6.6.163 (KASAN + PROVE_LOCKING) over
25 nvme-loop connect/disconnect rounds with concurrent ANA state
transitions (4,649 successful transitions, 0 KASAN/lockdep warnings).
drivers/nvme/host/core.c | 8 ++++++++
drivers/nvme/host/multipath.c | 7 +++++++
2 files changed, 15 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 17f511362..730476b37 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4484,6 +4484,14 @@ EXPORT_SYMBOL_GPL(nvme_start_ctrl);
void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
{
+ /*
+ * An AER completion can queue async_event_work; drain it before the
+ * controller's final release. Note that ana_work has additional
+ * producers (namespace scanning via nvme_scan_work, and the failover
+ * path in nvme_failover_req), which is why nvme_mpath_uninit()
+ * separately cancels ana_work after this point.
+ */
+ cancel_work_sync(&ctrl->async_event_work);
nvme_hwmon_exit(ctrl);
nvme_fault_inject_fini(&ctrl->fault_inject);
dev_pm_qos_hide_latency_tolerance(ctrl->device);
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 923c00c04..26af8a75b 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -1107,6 +1107,13 @@ int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
{
+ /*
+ * ANA work can be queued by nvme_handle_aen_notice, nvme_scan_work,
+ * and nvme_failover_req. Drain remaining work before releasing the ANA
+ * resources.
+ */
+ cancel_work_sync(&ctrl->ana_work);
+
kvfree(ctrl->ana_log_buf);
ctrl->ana_log_buf = NULL;
ctrl->ana_log_size = 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 6.6.y] nvme: stop asynchronous event work before ANA teardown
2026-12-03 8:52 ` [PATCH 6.6.y] nvme: stop asynchronous event work before ANA teardown Yaohan Li
@ 2026-12-03 13:47 ` Sasha Levin
0 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2026-12-03 13:47 UTC (permalink / raw)
To: stable
Cc: Sasha Levin, Greg Kroah-Hartman, Christoph Hellwig, Keith Busch,
linux-nvme, Yaohan Li
> Here is the manual backport for linux-6.6.y. The only conflict was in
> nvme_uninit_ctrl() because 6.6.y does not have commit a54a93d0e359
> ("nvme: move stopping keep-alive into nvme_uninit_ctrl()").
Queued for 6.6, and your 6.1 backport for 6.1, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-03 13:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 13:51 FAILED: patch "[PATCH] nvme: stop asynchronous event work before ANA teardown" failed to apply to 6.6-stable tree gregkh
2026-12-03 8:52 ` [PATCH 6.6.y] nvme: stop asynchronous event work before ANA teardown Yaohan Li
2026-12-03 13:47 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox