Patch "nvmet: confirm sq percpu has scheduled and switched to atomic" has been added to the 4.9-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
nvmet: confirm sq percpu has scheduled and switched to atomic
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
nvmet-confirm-sq-percpu-has-scheduled-and-switched-to-atomic.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Mon Dec 18 14:12:34 CET 2017
From: Sagi Grimberg <[email protected]>
Date: Mon, 6 Mar 2017 18:46:20 +0200
Subject: nvmet: confirm sq percpu has scheduled and switched to atomic
From: Sagi Grimberg <[email protected]>
[ Upstream commit d11ea004a458b982e19b188c386e25a9b66ec446 ]
percpu_ref_kill is not enough to prevent subsequent percpu_ref_tryget_live from failing. Hence call perfcpu_ref_kill_confirm to make it safe.
--- drivers/nvme/target/core.c | 11 ++++++++++- drivers/nvme/target/nvmet.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/nvme/target/core.c +10 -1
@@ -422,6 +422,13 @@ void nvmet_sq_setup(struct nvmet_ctrl *c ctrl->sqs[qid] = sq; } +static void nvmet_confirm_sq (struct percpu_ref *ref) +{ + struct nvmet_sq *sq = container_of(ref, struct nvmet_sq, ref); + +complete (&sq->confirm_done); +} +void nvmet_sq_destroy (struct nvmet_sq *sq) {/*
@@ -430,7 +437,8 @@ void nvmet_sq_destroy(struct nvmet_sq *s*/ if (sq->ctrl && sq->ctrl->sqs && sq->ctrl->sqs[0 ] == sq)nvmet_async_events_free (sq->ctrl); -percpu_ref_kill (&sq->ref); +percpu_ref_kill_and_confirm (&sq->ref, nvmet_confirm_sq); +wait_for_completion (&sq->confirm_done);wait_for_completion (&sq->free_done);percpu_ref_exit (&sq->ref);
@@ -458,6 +466,7 @@ int nvmet_sq_init(struct nvmet_sq *sq)return ret; }init_completion (&sq->free_done); +init_completion (&sq->confirm_done);return 0 ; }
drivers/nvme/target/nvmet.h +1 -0
@@ -73,6 +73,7 @@ struct nvmet_sq {u16 qid;u16 size;struct completion free_done; +struct completion confirm_done; };/**
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/blk-mq-fix-tagset-reinit-in-the-presence-of-cpu-hot-unplug.patch queue-4.9/nvmet-confirm-sq-percpu-has-scheduled-and-switched-to-atomic.patch queue-4.9/nvme-use-kref_get_unless_zero-in-nvme_find_get_ns.patch queue-4.9/nvme-loop-fix-a-possible-use-after-free-when-destroying-the-admin-queue.patch queue-4.9/nvmet-rdma-fix-a-possible-uninitialized-variable-dereference.patch