linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Yufen Yu <yuyufen@huawei.com>,
	Sagi Grimberg <sagi@grimberg.me>,
	Bart Van Assche <bvanassche@acm.org>,
	Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.9 27/62] nvme-loop: init nvmet_ctrl fatal_err_work when allocate
Date: Mon,  6 May 2019 16:32:58 +0200	[thread overview]
Message-ID: <20190506143053.394168522@linuxfoundation.org> (raw)
In-Reply-To: <20190506143051.102535767@linuxfoundation.org>

[ Upstream commit d11de63f2b519f0a162b834013b6d3a46dbf3886 ]

After commit 4d43d395fe (workqueue: Try to catch flush_work() without
INIT_WORK()), it can cause warning when delete nvme-loop device, trace
like:

[   76.601272] Call Trace:
[   76.601646]  ? del_timer+0x72/0xa0
[   76.602156]  __cancel_work_timer+0x1ae/0x270
[   76.602791]  cancel_work_sync+0x14/0x20
[   76.603407]  nvmet_ctrl_free+0x1b7/0x2f0 [nvmet]
[   76.604091]  ? free_percpu+0x168/0x300
[   76.604652]  nvmet_sq_destroy+0x106/0x240 [nvmet]
[   76.605346]  nvme_loop_destroy_admin_queue+0x30/0x60 [nvme_loop]
[   76.606220]  nvme_loop_shutdown_ctrl+0xc3/0xf0 [nvme_loop]
[   76.607026]  nvme_loop_delete_ctrl_host+0x19/0x30 [nvme_loop]
[   76.607871]  nvme_do_delete_ctrl+0x75/0xb0
[   76.608477]  nvme_sysfs_delete+0x7d/0xc0
[   76.609057]  dev_attr_store+0x24/0x40
[   76.609603]  sysfs_kf_write+0x4c/0x60
[   76.610144]  kernfs_fop_write+0x19a/0x260
[   76.610742]  __vfs_write+0x1c/0x60
[   76.611246]  vfs_write+0xfa/0x280
[   76.611739]  ksys_write+0x6e/0x120
[   76.612238]  __x64_sys_write+0x1e/0x30
[   76.612787]  do_syscall_64+0xbf/0x3a0
[   76.613329]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

We fix it by moving fatal_err_work init to nvmet_alloc_ctrl(), which may
more reasonable.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/nvme/target/core.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index f12753eb3216..96ea6c76be6e 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -709,6 +709,15 @@ bool nvmet_host_allowed(struct nvmet_req *req, struct nvmet_subsys *subsys,
 		return __nvmet_host_allowed(subsys, hostnqn);
 }
 
+static void nvmet_fatal_error_handler(struct work_struct *work)
+{
+	struct nvmet_ctrl *ctrl =
+			container_of(work, struct nvmet_ctrl, fatal_err_work);
+
+	pr_err("ctrl %d fatal error occurred!\n", ctrl->cntlid);
+	ctrl->ops->delete_ctrl(ctrl);
+}
+
 u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
 		struct nvmet_req *req, u32 kato, struct nvmet_ctrl **ctrlp)
 {
@@ -747,6 +756,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
 
 	INIT_WORK(&ctrl->async_event_work, nvmet_async_event_work);
 	INIT_LIST_HEAD(&ctrl->async_events);
+	INIT_WORK(&ctrl->fatal_err_work, nvmet_fatal_error_handler);
 
 	memcpy(ctrl->subsysnqn, subsysnqn, NVMF_NQN_SIZE);
 	memcpy(ctrl->hostnqn, hostnqn, NVMF_NQN_SIZE);
@@ -849,21 +859,11 @@ void nvmet_ctrl_put(struct nvmet_ctrl *ctrl)
 	kref_put(&ctrl->ref, nvmet_ctrl_free);
 }
 
-static void nvmet_fatal_error_handler(struct work_struct *work)
-{
-	struct nvmet_ctrl *ctrl =
-			container_of(work, struct nvmet_ctrl, fatal_err_work);
-
-	pr_err("ctrl %d fatal error occurred!\n", ctrl->cntlid);
-	ctrl->ops->delete_ctrl(ctrl);
-}
-
 void nvmet_ctrl_fatal_error(struct nvmet_ctrl *ctrl)
 {
 	mutex_lock(&ctrl->lock);
 	if (!(ctrl->csts & NVME_CSTS_CFS)) {
 		ctrl->csts |= NVME_CSTS_CFS;
-		INIT_WORK(&ctrl->fatal_err_work, nvmet_fatal_error_handler);
 		schedule_work(&ctrl->fatal_err_work);
 	}
 	mutex_unlock(&ctrl->lock);
-- 
2.20.1




  parent reply	other threads:[~2019-05-06 14:48 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-06 14:32 [PATCH 4.9 00/62] 4.9.174-stable review Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 01/62] ALSA: line6: use dynamic buffers Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 02/62] ipv4: ip_do_fragment: Preserve skb_iif during fragmentation Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 03/62] ipv6/flowlabel: wait rcu grace period before put_pid() Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 04/62] ipv6: invert flowlabel sharing check in process and user mode Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 05/62] packet: validate msg_namelen in send directly Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 06/62] bnxt_en: Improve multicast address setup logic Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 07/62] net: phy: marvell: Fix buffer overrun with stats counters Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 08/62] x86/suspend: fix false positive KASAN warning on suspend/resume Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 09/62] kasan: turn on -fsanitize-address-use-after-scope Greg Kroah-Hartman
2019-05-06 14:55   ` Andrey Ryabinin
2019-05-06 15:10     ` Greg Kroah-Hartman
2019-05-06 15:36       ` Andrey Ryabinin
2019-05-06 15:42         ` Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 10/62] kasan: rework Kconfig settings Greg Kroah-Hartman
2019-05-06 14:58   ` Andrey Ryabinin
2019-05-06 15:42     ` Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 11/62] mm/kasan: Switch to using __pa_symbol and lm_alias Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 12/62] x86/unwind: Disable KASAN checks for non-current tasks Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 13/62] arm64: kasan: avoid bad virt_to_pfn() Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 14/62] kasan: add a prototype of task_struct to avoid warning Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 15/62] kasan: avoid -Wmaybe-uninitialized warning Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 16/62] kasan: remove redundant initialization of variable real_size Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 17/62] arm64: proc: Set PTE_NG for table entries to avoid traversing them twice Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 18/62] kasan: prevent compiler from optimizing away memset in tests Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 19/62] arm64: mm: print out correct page table entries Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 20/62] arm64: mm: dont print out page table entries on EL0 faults Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 21/62] caif: reduce stack size with KASAN Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 22/62] USB: yurex: Fix protection fault after device removal Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 23/62] USB: w1 ds2490: Fix bug caused by improper use of altsetting array Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 24/62] usb: usbip: fix isoc packet num validation in get_pipe Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 25/62] USB: core: Fix unterminated string returned by usb_string() Greg Kroah-Hartman
2019-05-06 14:32 ` [PATCH 4.9 26/62] USB: core: Fix bug caused by duplicate interface PM usage counter Greg Kroah-Hartman
2019-05-06 14:32 ` Greg Kroah-Hartman [this message]
2019-05-06 14:32 ` [PATCH 4.9 28/62] HID: logitech: check the return value of create_singlethread_workqueue Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 29/62] HID: debug: fix race condition with between rdesc_show() and device removal Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 30/62] rtc: sh: Fix invalid alarm warning for non-enabled alarm Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 31/62] batman-adv: Reduce claim hash refcnt only for removed entry Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 32/62] batman-adv: Reduce tt_local " Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 33/62] batman-adv: Reduce tt_global " Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 34/62] igb: Fix WARN_ONCE on runtime suspend Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 35/62] net/mlx5: E-Switch, Fix esw manager vport indication for more vport commands Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 36/62] bonding: show full hw address in sysfs for slave entries Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 37/62] net: stmmac: dont overwrite discard_frame status Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 38/62] net: stmmac: fix dropping of multi-descriptor RX frames Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 39/62] net: stmmac: dont log oversized frames Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 40/62] jffs2: fix use-after-free on symlink traversal Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 41/62] debugfs: " Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 42/62] rtc: da9063: set uie_unsupported when relevant Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 43/62] vfio/pci: use correct format characters Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 44/62] scsi: core: add new RDAC LENOVO/DE_Series device Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 45/62] scsi: storvsc: Fix calculation of sub-channel count Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 46/62] net: hns: fix KASAN: use-after-free in hns_nic_net_xmit_hw() Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 47/62] net: hns: Use NAPI_POLL_WEIGHT for hns driver Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 48/62] net: hns: Fix WARNING when remove HNS driver with SMMU enabled Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 49/62] hugetlbfs: fix memory leak for resv_map Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 50/62] sh: fix multiple function definition build errors Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 51/62] xsysace: Fix error handling in ace_setup Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 52/62] ARM: orion: dont use using 64-bit DMA masks Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 53/62] ARM: iop: " Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 54/62] perf/x86/amd: Update generic hardware cache events for Family 17h Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 55/62] staging: iio: adt7316: allow adt751x to use internal vref for all dacs Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 56/62] staging: iio: adt7316: fix the dac read calculation Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 57/62] staging: iio: adt7316: fix the dac write calculation Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 58/62] scsi: RDMA/srpt: Fix a credit leak for aborted commands Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 59/62] Input: snvs_pwrkey - initialize necessary driver data before enabling IRQ Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 60/62] selinux: never allow relabeling on context mounts Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 61/62] x86/mce: Improve error message when kernel cannot recover, p2 Greg Kroah-Hartman
2019-05-06 14:33 ` [PATCH 4.9 62/62] media: v4l2: i2c: ov7670: Fix PLL bypass register values Greg Kroah-Hartman
2019-05-07  8:12 ` [PATCH 4.9 00/62] 4.9.174-stable review Naresh Kamboju
2019-05-07 12:44 ` Jon Hunter
2019-05-07 18:38 ` Guenter Roeck
2019-05-07 20:34 ` shuah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190506143053.394168522@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sagi@grimberg.me \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=yuyufen@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).