stable.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, Mikulas Patocka <mpatocka@redhat.com>,
	Mike Snitzer <snitzer@redhat.com>
Subject: [PATCH 3.10 61/78] dm delay: fix a possible deadlock due to shared workqueue
Date: Wed, 18 Dec 2013 13:11:29 -0800	[thread overview]
Message-ID: <20131218211113.621976044@linuxfoundation.org> (raw)
In-Reply-To: <20131218211111.903835960@linuxfoundation.org>

3.10-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mikulas Patocka <mpatocka@redhat.com>

commit 718822c1c112dc99e0c72c8968ee1db9d9d910f0 upstream.

The dm-delay target uses a shared workqueue for multiple instances.  This
can cause deadlock if two or more dm-delay targets are stacked on the top
of each other.

This patch changes dm-delay to use a per-instance workqueue.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/dm-delay.c |   23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

--- a/drivers/md/dm-delay.c
+++ b/drivers/md/dm-delay.c
@@ -20,6 +20,7 @@
 struct delay_c {
 	struct timer_list delay_timer;
 	struct mutex timer_lock;
+	struct workqueue_struct *kdelayd_wq;
 	struct work_struct flush_expired_bios;
 	struct list_head delayed_bios;
 	atomic_t may_delay;
@@ -45,14 +46,13 @@ struct dm_delay_info {
 
 static DEFINE_MUTEX(delayed_bios_lock);
 
-static struct workqueue_struct *kdelayd_wq;
 static struct kmem_cache *delayed_cache;
 
 static void handle_delayed_timer(unsigned long data)
 {
 	struct delay_c *dc = (struct delay_c *)data;
 
-	queue_work(kdelayd_wq, &dc->flush_expired_bios);
+	queue_work(dc->kdelayd_wq, &dc->flush_expired_bios);
 }
 
 static void queue_timeout(struct delay_c *dc, unsigned long expires)
@@ -191,6 +191,12 @@ out:
 		goto bad_dev_write;
 	}
 
+	dc->kdelayd_wq = alloc_workqueue("kdelayd", WQ_MEM_RECLAIM, 0);
+	if (!dc->kdelayd_wq) {
+		DMERR("Couldn't start kdelayd");
+		goto bad_queue;
+	}
+
 	setup_timer(&dc->delay_timer, handle_delayed_timer, (unsigned long)dc);
 
 	INIT_WORK(&dc->flush_expired_bios, flush_expired_bios);
@@ -203,6 +209,8 @@ out:
 	ti->private = dc;
 	return 0;
 
+bad_queue:
+	mempool_destroy(dc->delayed_pool);
 bad_dev_write:
 	if (dc->dev_write)
 		dm_put_device(ti, dc->dev_write);
@@ -217,7 +225,7 @@ static void delay_dtr(struct dm_target *
 {
 	struct delay_c *dc = ti->private;
 
-	flush_workqueue(kdelayd_wq);
+	destroy_workqueue(dc->kdelayd_wq);
 
 	dm_put_device(ti, dc->dev_read);
 
@@ -350,12 +358,6 @@ static int __init dm_delay_init(void)
 {
 	int r = -ENOMEM;
 
-	kdelayd_wq = alloc_workqueue("kdelayd", WQ_MEM_RECLAIM, 0);
-	if (!kdelayd_wq) {
-		DMERR("Couldn't start kdelayd");
-		goto bad_queue;
-	}
-
 	delayed_cache = KMEM_CACHE(dm_delay_info, 0);
 	if (!delayed_cache) {
 		DMERR("Couldn't create delayed bio cache.");
@@ -373,8 +375,6 @@ static int __init dm_delay_init(void)
 bad_register:
 	kmem_cache_destroy(delayed_cache);
 bad_memcache:
-	destroy_workqueue(kdelayd_wq);
-bad_queue:
 	return r;
 }
 
@@ -382,7 +382,6 @@ static void __exit dm_delay_exit(void)
 {
 	dm_unregister_target(&delay_target);
 	kmem_cache_destroy(delayed_cache);
-	destroy_workqueue(kdelayd_wq);
 }
 
 /* Module hooks */



  parent reply	other threads:[~2013-12-18 21:11 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18 21:10 [PATCH 3.10 00/78] 3.10.25-stable review Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 01/78] MIPS: DMA: For BMIPS5000 cores flush region just like non-coherent R10000 Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 02/78] Input: xpad - add signature for Razer Onza Classic Edition Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 03/78] ALSA: compress: Fix 64bit ABI incompatibility Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 04/78] ALSA: memalloc.h - fix wrong truncation of dma_addr_t Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 05/78] ALSA: hda - Add static DAC/pin mapping for AD1986A codec Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 06/78] ALSA: hda - Mute all aamix inputs as default Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 07/78] ALSA: hda - hdmi: Fix IEC958 ctl indexes for some simple HDMI devices Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 08/78] ARM: pxa: tosa: fix keys mapping Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 09/78] ARM: pxa: prevent PXA270 occasional reboot freezes Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 10/78] ARM: OMAP3: hwmod data: Dont prevent RESET of USB Host module Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 11/78] ARM: 7912/1: check stack pointer in get_wchan Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 12/78] ARM: 7913/1: fix framepointer check in unwind_frame Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 13/78] KVM: Improve create VCPU parameter (CVE-2013-4587) Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 14/78] KVM: x86: Fix potential divide by 0 in lapic (CVE-2013-6367) Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 15/78] KVM: x86: Convert vapic synchronization to _cached functions (CVE-2013-6368) Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 16/78] KVM: x86: fix guest-initiated crash with x2apic (CVE-2013-6376) Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 17/78] hwmon: Prevent some divide by zeros in FAN_TO_REG() Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 19/78] hwmon: (w83l786ng) Fix fan speed control mode setting and reporting Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 20/78] hwmon: (w83l768ng) Fix fan speed control range Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 21/78] xfs: growfs overruns AGFL buffer on V4 filesystems Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 22/78] xfs: underflow bug in xfs_attrlist_by_handle() Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 23/78] PCI: Disable Bus Master only on kexec reboot Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 24/78] futex: fix handling of read-only-mapped hugepages Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 25/78] nfsd: when reusing an existing repcache entry, unhash it first Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 26/78] usb: hub: Use correct reset for wedged USB3 devices that are NOTATTACHED Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 27/78] usb: dwc3: fix implementation of endpoint wedge Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 28/78] usb: gadget: composite: reset delayed_status on reset_config Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 29/78] USB: serial: option: blacklist interface 1 for Huawei E173s-6 Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 30/78] USB: option: support new huawei devices Greg Kroah-Hartman
2013-12-18 21:10 ` [PATCH 3.10 31/78] Input: usbtouchscreen - separate report and transmit buffer size handling Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 32/78] media: af9035: fix broken I2C and USB I/O Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 33/78] powerpc: Fix PTE page address mismatch in pgtable ctor/dtor Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 34/78] drivers/rtc/rtc-at91rm9200.c: correct alarm over day/month wrap Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 36/78] ath9k: Fix QuickDrop usage Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 37/78] ath9k: Fix XLNA bias strength Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 38/78] selinux: handle TCP SYN-ACK packets correctly in selinux_ip_output() Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 39/78] selinux: handle TCP SYN-ACK packets correctly in selinux_ip_postroute() Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 40/78] Revert "mac80211: allow disable power save in mesh" Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 41/78] mac80211: dont attempt to reorder multicast frames Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 42/78] iwlwifi: mvm: check sta_id/drain values in debugfs Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 43/78] mwifiex: fix memory leak issue for ibss join Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 44/78] igb: Fix for issue where values could be too high for udelay function Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 45/78] drm/radeon: program DCE2 audio dto just like DCE3 Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 46/78] drm/radeon: fixup bad vram size on SI Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 47/78] x86, efi: Dont use (U)EFI time services on 32 bit Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 48/78] x86, build: Pass in additional -mno-mmx, -mno-sse options Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 49/78] x86, build, icc: Remove uninitialized_var() from compiler-intel.h Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 50/78] media: saa7164: fix return value check in saa7164_initdev() Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 52/78] media: af9033: fix broken I2C Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 53/78] media: wm8775: fix broken audio routing Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 54/78] media: af9035: add [0413:6a05] Leadtek WinFast DTV Dongle Dual Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 55/78] media: af9035: unlock on error in af9035_i2c_master_xfer() Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 56/78] Btrfs: fix access_ok() check in btrfs_ioctl_send() Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 57/78] btrfs: call mnt_drop_write after interrupted subvol deletion Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 58/78] dm bufio: initialize read-only module parameters Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 59/78] dm snapshot: avoid snapshot space leak on crash Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 60/78] dm array: fix a reference counting bug in shadow_ablock Greg Kroah-Hartman
2013-12-18 21:11 ` Greg Kroah-Hartman [this message]
2013-12-18 21:11 ` [PATCH 3.10 62/78] dm space map metadata: return on failure in sm_metadata_new_block Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 63/78] dm table: fail dm_table_create on dm_round_up overflow Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 64/78] dm thin: switch to read only mode if a mapping insert fails Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 66/78] [media] cxd2820r_core: fix sparse warnings Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 67/78] sched: Avoid throttle_cfs_rq() racing with period_timer stopping Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 68/78] staging: comedi: pcmuio: fix possible NULL deref on detach Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 69/78] staging: comedi: drivers: use comedi_dio_update_state() for simple cases Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 70/78] staging: comedi: ssv_dnp: use comedi_dio_update_state() Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 71/78] sc1200_wdt: Fix oops Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 72/78] NFSv4 wait on recovery for async session errors Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 73/78] [PATCH linux-3.10.y] ip6tnl: fix use after free of fb_tnl_dev Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 74/78] Revert "net: update consumers of MSG_MORE to recognize MSG_SENDPAGE_NOTLAST" Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 75/78] Btrfs: fix memory leak of chunks extent map Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 76/78] Btrfs: fix hole check in log_one_extent Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 77/78] Btrfs: fix incorrect inode acl reset Greg Kroah-Hartman
2013-12-18 21:11 ` [PATCH 3.10 78/78] Btrfs: do not run snapshot-aware defragment on error Greg Kroah-Hartman
2013-12-19  2:04 ` [PATCH 3.10 00/78] 3.10.25-stable review Guenter Roeck
2013-12-19  3:40   ` Greg Kroah-Hartman
2013-12-19 20:47 ` Shuah Khan

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=20131218211113.621976044@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@redhat.com \
    --cc=stable@vger.kernel.org \
    /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).