alistair23-linux/drivers
Bart Van Assche 38c3159923 scsi_dh_alua: Fix a recently introduced deadlock
While retesting the SRP initiator I ran the command "rmmod mlx4_ib"
while I/O was in progress. That command triggers SCSI device removal
indirectly. Avoid that this action triggers the following deadlock:

=================================
[ INFO: inconsistent lock state ]
4.6.0-rc0-dbg+ #2 Tainted: G           O
---------------------------------
inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage.
multipathd/484 [HC0[0]:SC0[0]:HE1:SE1] takes:
 (&(&pg->lock)->rlock){+.?...}, at: [<ffffffffa04f50a2>] alua_bus_detach+0x52/0xa0 [scsi_dh_alua]
{IN-SOFTIRQ-W} state was registered at:
  [<ffffffff810a64a9>] __lock_acquire+0x7e9/0x1ad0
  [<ffffffff810a7fd0>] lock_acquire+0x60/0x80
  [<ffffffff8159910e>] _raw_spin_lock_irqsave+0x3e/0x60
  [<ffffffffa04f5131>] alua_rtpg_queue+0x41/0x1d0 [scsi_dh_alua]
  [<ffffffffa04f5531>] alua_check+0xe1/0x220 [scsi_dh_alua]
  [<ffffffffa04f5709>] alua_check_sense+0x99/0xb0 [scsi_dh_alua]
  [<ffffffff813f0d01>] scsi_check_sense+0x71/0x3f0
  [<ffffffff813f2f8b>] scsi_decide_disposition+0x18b/0x1d0
  [<ffffffff813f6e52>] scsi_softirq_done+0x52/0x140
  [<ffffffff812a26f2>] blk_done_softirq+0x52/0x90
  [<ffffffff8105bc1f>] __do_softirq+0x10f/0x230
  [<ffffffff8105bec8>] irq_exit+0xa8/0xb0
  [<ffffffff8101a675>] do_IRQ+0x65/0x110
  [<ffffffff8159a2c9>] ret_from_intr+0x0/0x19
  [<ffffffff811732f1>] kmem_cache_alloc+0x151/0x190
  [<ffffffff8118e534>] create_object+0x34/0x2d0
  [<ffffffff8158eaa6>] kmemleak_alloc_percpu+0x56/0xd0
  [<ffffffff8113ab0d>] pcpu_alloc+0x38d/0x660
  [<ffffffff8113aded>] __alloc_percpu_gfp+0xd/0x10
  [<ffffffff812e56a5>] __percpu_counter_init+0x55/0xb0
  [<ffffffff812b4989>] blkg_alloc+0x79/0x230
  [<ffffffff812b6756>] blkcg_init_queue+0x26/0x1d0
  [<ffffffff81297eed>] blk_alloc_queue_node+0x27d/0x2e0
  [<ffffffffa017766c>] dm_create+0x20c/0x570 [dm_mod]
  [<ffffffffa017e356>] dev_create+0x56/0x2c0 [dm_mod]
  [<ffffffffa017dcae>] ctl_ioctl+0x26e/0x520 [dm_mod]
  [<ffffffffa017df6e>] dm_ctl_ioctl+0xe/0x20 [dm_mod]
  [<ffffffff811aa8ee>] do_vfs_ioctl+0x8e/0x660
  [<ffffffff811aaefc>] SyS_ioctl+0x3c/0x70
  [<ffffffff81599929>] entry_SYSCALL_64_fastpath+0x1c/0xac
irq event stamp: 4290931
hardirqs last  enabled at (4290931): [ 1662.892772]
[<ffffffff81599341>] _raw_spin_unlock_irqrestore+0x31/0x50
hardirqs last disabled at (4290930): [<ffffffff815990e7>] _raw_spin_lock_irqsave+0x17/0x60
softirqs last  enabled at (4290774): [<ffffffff8105bcdb>] __do_softirq+0x1cb/0x230
softirqs last disabled at (4289831): [<ffffffff8105bec8>] irq_exit+0xa8/0xb0

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&(&pg->lock)->rlock);
  <Interrupt>
    lock(&(&pg->lock)->rlock);

 *** DEADLOCK ***

2 locks held by multipathd/484:
 #0:  (&bdev->bd_mutex){+.+.+.}, at: [<ffffffff811d1cc3>] __blkdev_put+0x33/0x360
 #1:  (sd_ref_mutex){+.+...}, at: [<ffffffff81400afc>] scsi_disk_put+0x1c/0x40

stack backtrace:
CPU: 6 PID: 484 Comm: multipathd Tainted: G           O    4.6.0-rc0-dbg+ #2
Call Trace:
 [<ffffffff812bd115>] dump_stack+0x67/0x92
 [<ffffffff810a5175>] print_usage_bug+0x215/0x240
 [<ffffffff810a56ea>] mark_lock+0x54a/0x610
 [<ffffffff810a6505>] __lock_acquire+0x845/0x1ad0
 [<ffffffff810a7fd0>] lock_acquire+0x60/0x80
 [<ffffffff81598f23>] _raw_spin_lock+0x33/0x50
 [<ffffffffa04f50a2>] alua_bus_detach+0x52/0xa0 [scsi_dh_alua]
 [<ffffffff813ff6f7>] scsi_dh_release_device+0x17/0x50
 [<ffffffff813fb8da>] scsi_device_dev_release_usercontext+0x2a/0x120
 [<ffffffff810701f0>] execute_in_process_context+0x80/0x90
 [<ffffffff813fb8a7>] scsi_device_dev_release+0x17/0x20
 [<ffffffff813c8cfd>] device_release+0x2d/0x90
 [<ffffffff812bfa8a>] kobject_release+0x7a/0x190
 [<ffffffff812bf946>] kobject_put+0x26/0x50
 [<ffffffff813c8ee2>] put_device+0x12/0x20
 [<ffffffff813edc86>] scsi_device_put+0x26/0x30
 [<ffffffff81400b0d>] scsi_disk_put+0x2d/0x40
 [<ffffffff81400b68>] sd_release+0x48/0xb0
 [<ffffffff811d1f2e>] __blkdev_put+0x29e/0x360
 [<ffffffff811d24b9>] blkdev_put+0x49/0x170
 [<ffffffff811d2600>] blkdev_close+0x20/0x30
 [<ffffffff81198f48>] __fput+0xe8/0x1f0
 [<ffffffff81199089>] ____fput+0x9/0x10
 [<ffffffff81075d9e>] task_work_run+0x6e/0xa0
 [<ffffffff81001119>] exit_to_usermode_loop+0xa9/0xb0
 [<ffffffff81001590>] syscall_return_slowpath+0xb0/0xc0
 [<ffffffff815999b7>] entry_SYSCALL_64_fastpath+0xaa/0xac

Fixes: cb0a168cb6 (scsi_dh_alua: update 'access_state' field)
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Laurence Oberman <loberman@redhat.com>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-03-29 20:32:02 -04:00
..
accessibility
acpi Merge branches 'pm-core' and 'pm-domains' 2016-02-06 00:34:01 +01:00
amba
android
ata ahci: Intel DNV device IDs SATA 2016-02-10 11:35:55 -05:00
atm
auxdisplay
base Merge branch 'component' of git://ftp.arm.linux.org.uk/~rmk/linux-arm 2016-02-14 10:40:21 -08:00
bcma GPIO bulk updates for the v4.5 kernel cycle: 2016-01-17 12:32:01 -08:00
block null_blk: oops when initializing without lightnvm 2016-02-11 08:56:09 -07:00
bluetooth
bus vexpress fixes for v4.5 2016-02-01 12:27:18 -08:00
cdrom
char hpet: Drop stale URLs 2016-02-17 09:39:56 +01:00
clk clk: gpio: Really allow an optional clock= DT property 2016-02-18 19:10:22 -08:00
clocksource Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-01-31 15:49:06 -08:00
connector
cpufreq Merge branches 'pm-cpuidle', 'pm-cpufreq', 'pm-domains' and 'pm-sleep' 2016-01-29 21:45:17 +01:00
cpuidle Merge branches 'pm-cpuidle', 'pm-cpufreq', 'pm-domains' and 'pm-sleep' 2016-01-29 21:45:17 +01:00
crypto crypto: marvell/cesa - fix test in mv_cesa_dev_dma_init() 2016-02-06 15:23:56 +08:00
dca
devfreq PM / devfreq: Do not show statistics if it's not ready. 2016-01-13 17:30:33 +09:00
dio
dma dmaengine: dw: disable BLOCK IRQs for non-cyclic xfer 2016-02-15 22:19:32 +05:30
dma-buf
edac
eisa
extcon
firewire
firmware efi: Add pstore variables to the deletion whitelist 2016-02-16 12:48:18 +00:00
fmc
fpga
gpio gpio: davinci: Fix the number of controllers allocated 2016-02-10 11:00:49 +01:00
gpu drm/nouveau: use post-decrement in error handling 2016-02-19 13:36:05 +10:00
hid asm-generic changes for 4.5 2016-01-20 17:30:20 -08:00
hsi
hv char/misc patches for 4.5-rc1 2016-01-13 10:23:36 -08:00
hwmon hwmon: (gpio-fan) Remove un-necessary speed_index lookup for thermal hook 2016-02-19 17:14:25 -08:00
hwspinlock drivers/hwspinlock: fix race between radix tree insertion and lookup 2016-02-03 08:28:43 -08:00
hwtracing
i2c i2c: i801: Adding Intel Lewisburg support for iTCO 2016-02-18 13:18:48 +01:00
ide drivers/ide: make ide-scan-pci.c driver explicitly non-modular 2016-01-18 14:12:33 -05:00
idle
iio Second set of IIO fixes for the 4.5 cycle. These ones are mostly 2016-02-01 13:08:26 -08:00
infiniband Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-02-22 12:18:07 -08:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2016-02-10 12:21:57 -08:00
iommu SVM fixes for Linux 4.5 2016-02-16 08:04:06 -08:00
ipack
irqchip irqchip/gic: Only set the EOImodeNS bit for the root controller 2016-02-11 10:20:02 +00:00
isdn ser_gigaset: use container_of() instead of detour 2016-02-19 15:52:41 -05:00
leds GPIO bulk updates for the v4.5 kernel cycle: 2016-01-17 12:32:01 -08:00
lguest lguest: Map switcher text R/O 2016-01-12 12:17:28 +01:00
lightnvm lightnvm: allow to force mm initialization 2016-02-04 09:19:45 -07:00
macintosh
mailbox mailbox: Fix dependencies for !HAS_IOMEM archs 2016-02-02 16:47:14 +05:30
mcb
md Merge branch 'mymd/for-next' into mymd/for-linus 2016-02-03 15:43:59 -08:00
media [media] saa7134-alsa: Only frees registered sound cards 2016-02-04 16:26:10 -02:00
memory ARM: SoC driver updates for v4.5 2016-01-20 18:42:30 -08:00
memstick memstick: use sector_div instead of do_div 2016-01-20 17:09:18 -08:00
message mptbase: fixup error handling paths in mpt_attach() 2016-02-23 21:27:02 -05:00
mfd thermal: allow u8500-thermal driver to be a module 2016-02-09 14:18:23 -08:00
misc mei: validate request value in client notify request ioctl 2016-02-06 22:12:56 -08:00
mmc Revert "mmc: block: don't use parameter prefix if built as module" 2016-02-11 16:49:35 +01:00
mtd Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2016-01-24 12:50:56 -08:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-02-22 12:18:07 -08:00
nfc
ntb NTB: Fix macro parameter conflict with field name 2016-01-21 19:53:10 -05:00
nubus
nvdimm libnvdimm, pfn: fix restoring memmap location 2016-01-29 17:43:16 -08:00
nvme NVMe: Rate limit nvme IO warnings 2016-02-12 08:10:31 -07:00
nvmem nvmem: qfprom: Specify LE device endianness 2016-02-07 23:09:13 -08:00
of DeviceTree fixes for 4.5-rc5: 2016-02-17 11:50:53 -08:00
oprofile wrappers for ->i_mutex access 2016-01-22 18:04:28 -05:00
parisc parisc: convert to dma_map_ops 2016-01-20 17:09:18 -08:00
parport
pci Xen bug fixes for 4.5-rc5 2016-02-22 13:57:01 -08:00
pcmcia
perf
phy phy: twl4030-usb: Fix unbalanced pm_runtime_enable on module reload 2016-02-10 11:46:01 +05:30
pinctrl pinctrl: samsung: fix SMP race condition 2016-02-15 20:45:50 +01:00
platform intel_scu_ipcutil: underflow in scu_reg_access() 2016-01-30 09:40:35 -08:00
pnp PNP: Add Haswell-ULT to Intel MCH size workaround 2016-02-03 01:00:29 +01:00
power power: bq27xxx_battery: Fix bq27541 AveragePower register address 2016-01-14 01:03:18 +01:00
powercap Merge branch 'powercap' 2016-01-12 01:12:40 +01:00
pps
ps3
ptp ptp: ixp46x: use helpers for converting ns to timespec 2016-01-29 12:38:59 -08:00
pwm pwm: Mark all devices as "might sleep" 2016-01-21 15:04:59 +01:00
rapidio rapidio: use kobj_to_dev() 2016-01-20 17:09:18 -08:00
ras
regulator regulator: Update for v4.5 2016-01-15 12:14:47 -08:00
remoteproc virtio: make find_vqs() checkpatch.pl-friendly 2016-01-12 20:47:06 +02:00
reset
rpmsg virtio: make find_vqs() checkpatch.pl-friendly 2016-01-12 20:47:06 +02:00
rtc RTC for 4.5 2016-01-18 12:10:45 -08:00
s390 s390/dasd: fix performance drop 2016-02-17 09:24:07 +01:00
sbus
scsi scsi_dh_alua: Fix a recently introduced deadlock 2016-03-29 20:32:02 -04:00
sfi
sh
sn
soc ARM: SoC support for Tegra platforms for v4.5 2016-01-22 17:30:52 -08:00
spi Merge remote-tracking branches 'spi/fix/atmel', 'spi/fix/bcm2835aux', 'spi/fix/fsl-espi', 'spi/fix/imx', 'spi/fix/loopback' and 'spi/fix/omap2-mcspi' into spi-linus 2016-02-12 23:04:41 +00:00
spmi
ssb ssb: mark ssb_bus_register as __maybe_unused 2016-01-19 21:25:57 +02:00
staging Staging / IIO driver fixes for 4.5-rc3 2016-02-06 22:13:16 -08:00
target target/transport: add flag to indicate CPU Affinity is observed 2016-02-10 23:08:55 -08:00
tc
thermal thermal: cpu_cooling: fix out of bounds access in time_in_idle 2016-02-11 07:13:29 -08:00
thunderbolt
tty Revert "8250: uniphier: allow modular build with 8250 console" 2016-02-07 18:22:54 -08:00
uio
usb xhci: harden xhci_find_next_ext_cap against device removal 2016-02-04 17:00:10 -08:00
uwb
vfio vfio/noiommu: Don't use iommu_present() to track fake groups 2016-01-27 11:22:25 -07:00
vhost
video video: fbdev: imxfb: Provide a reset mechanism 2016-01-29 14:20:16 +02:00
virt
virtio virtio_pci: fix use after free on release 2016-01-26 10:18:28 +02:00
vlynq
vme
w1
watchdog watchdog: Fix dependencies for !HAS_IOMEM archs 2016-01-31 16:54:36 +01:00
xen Xen bug fixes for 4.5-rc5 2016-02-22 13:57:01 -08:00
zorro
Kconfig
Makefile