WSL2-Linux-Kernel/drivers/scsi
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
..
aacraid aacraid: add missing curly braces 2016-03-21 20:25:31 -04:00
aic7xxx aic7xxx: Fix queue depth handling 2016-02-23 21:27:02 -05:00
aic94xx
arcmsr arcmsr: change driver version to v1.30.00.22-20151126 2015-11-30 18:51:20 -05:00
arm scsi: fas216: avoid fas216_log_setup for loadable module 2016-02-23 21:27:02 -05:00
be2iscsi be2iscsi: set the boot_kset pointer to NULL in case of failure 2016-03-14 15:50:11 -04:00
bfa bfa: deinline __bfa_trc() and __bfa_trc32() 2016-02-23 21:27:02 -05:00
bnx2fc bnx2fc: bnx2fc_eh_abort(): fix wrong return code. 2016-02-23 21:27:02 -05:00
bnx2i
csiostor
cxgbi cxgbi: Typo in MODULE_PARM_DESC 2016-01-08 12:51:04 -05:00
cxlflash cxlflash: Move to exponential back-off when cmd_room is not available 2016-03-28 20:43:34 -04:00
device_handler scsi_dh_alua: Fix a recently introduced deadlock 2016-03-29 20:32:02 -04:00
dpt
esas2r esas2r: Fix array overrun 2016-02-23 21:27:02 -05:00
fcoe fcoe: fix reset of fip selection time. 2016-02-29 21:02:20 -05:00
fnic fnic: move printk()s outside of the critical code section. 2016-03-18 15:28:17 -04:00
hisi_sas hisi_sas: update driver version to 1.3 2016-02-29 21:00:03 -05:00
ibmvscsi ibmvfc: byteswap scsi_id, wwpn, and node_name prior to logging 2016-02-23 21:27:02 -05:00
isci
libfc
libsas
lpfc lpfc: fix misleading indentation 2016-03-18 15:21:23 -04:00
megaraid megaraid_sas: add missing curly braces in ioctl handler 2016-03-18 15:22:55 -04:00
mpt3sas mpt3sas: Don't overreach ioc->reply_post[] during initialization 2016-03-23 16:33:09 -04:00
mvsas Merge branch 'jejb-scsi' into misc 2016-01-07 15:51:13 -08:00
osd osd: remove deadcode 2016-02-25 21:11:42 -05:00
pcmcia
pm8001
qla2xxx qla2xxx: avoid maybe_uninitialized warning 2016-03-18 15:25:07 -04:00
qla4xxx scsi: qla4xxx: shut up warning for rd_reg_indirect 2016-02-23 21:27:02 -05:00
snic snic: correctly check for array overrun on overly long version number 2016-03-01 20:08:49 -05:00
sym53c8xx_2
ufs scsi: ufs: select CONFIG_NLS 2016-03-18 15:35:23 -04:00
.gitignore
3w-9xxx.c
3w-9xxx.h
3w-sas.c
3w-sas.h
3w-xxxx.c 3w-xxxx: Pass through compat mode ioctls 2016-01-08 12:51:03 -05:00
3w-xxxx.h
53c700.c
53c700.h
53c700.scr
53c700_d.h_shipped
BusLogic.c
BusLogic.h
FlashPoint.c
Kconfig scsi: storvsc: Fix a build issue reported by kbuild test robot 2016-03-05 17:01:04 -05:00
Makefile
NCR53c406a.c
NCR5380.c ncr5380: Call scsi_eh_prep_cmnd() and scsi_eh_restore_cmnd() as and when appropriate 2016-03-01 09:38:58 -05:00
NCR5380.h ncr5380: Use runtime register mapping 2016-01-06 21:43:10 -05:00
NCR_D700.c
NCR_D700.h
NCR_Q720.c
NCR_Q720.h
a100u2w.c
a100u2w.h
a2091.c
a2091.h
a3000.c
a3000.h
a4000t.c
advansys.c Merge branch 'mkp-fixes' into fixes 2015-12-03 09:32:33 -08:00
aha152x.c
aha152x.h
aha1542.c scsi: aha1542: avoid uninitialized variable warnings 2016-02-23 21:27:02 -05:00
aha1542.h
aha1740.c
aha1740.h
am53c974.c
atari_NCR5380.c ncr5380: Call scsi_eh_prep_cmnd() and scsi_eh_restore_cmnd() as and when appropriate 2016-03-01 09:38:58 -05:00
atari_scsi.c atari_scsi, sun3_scsi: Remove global Scsi_Host pointer 2016-01-06 21:43:08 -05:00
atp870u.c
atp870u.h
bvme6000_scsi.c
ch.c
constants.c
dc395x.c
dc395x.h
dmx3191d.c ncr5380: Fix soft lockups 2016-01-06 21:43:09 -05:00
dpt_i2o.c dpt_i2o: fix build warning 2016-02-23 21:27:02 -05:00
dpti.h
dtc.c ncr5380: Fix soft lockups 2016-01-06 21:43:09 -05:00
dtc.h ncr5380: Fix and cleanup scsi_host_template initializers 2016-01-06 21:43:03 -05:00
eata.c
eata_generic.h
eata_pio.c
eata_pio.h
esp_scsi.c
esp_scsi.h
fdomain.c scsi: fdomain: drop fdomain_pci_tbl when built-in 2016-02-23 21:27:02 -05:00
fdomain.h
g_NCR5380.c ncr5380: Add support for HP C2502 2016-01-06 21:43:13 -05:00
g_NCR5380.h ncr5380: Add support for HP C2502 2016-01-06 21:43:13 -05:00
g_NCR5380_mmio.c
gdth.c gdth: replace struct timeval with ktime_get_real_seconds() 2016-02-25 21:16:49 -05:00
gdth.h
gdth_ioctl.h
gdth_proc.c gdth: replace struct timeval with ktime_get_real_seconds() 2016-02-25 21:16:49 -05:00
gdth_proc.h
gvp11.c
gvp11.h
hosts.c scsi: Use ida for host number management 2016-02-23 21:27:02 -05:00
hpsa.c hpsa: update copyright information 2016-02-23 21:27:02 -05:00
hpsa.h hpsa: update copyright information 2016-02-23 21:27:02 -05:00
hpsa_cmd.h hpsa: update copyright information 2016-02-23 21:27:02 -05:00
hptiop.c
hptiop.h
imm.c imm: check parport_claim 2016-02-25 21:10:53 -05:00
imm.h
in2000.c
in2000.h
initio.c
initio.h
ipr.c Initial roundup of 4.5 merge window patches 2016-01-23 18:45:06 -08:00
ipr.h irq_poll: make blk-iopoll available outside the block layer 2015-12-11 11:52:24 -08:00
ips.c
ips.h
iscsi_boot_sysfs.c
iscsi_tcp.c
iscsi_tcp.h
jazz_esp.c
lasi700.c
libiscsi.c
libiscsi_tcp.c
mac53c94.c
mac53c94.h
mac_esp.c
mac_scsi.c ncr5380: Fix soft lockups 2016-01-06 21:43:09 -05:00
megaraid.c
megaraid.h
mesh.c
mesh.h
mvme16x_scsi.c
mvme147.c
mvme147.h
mvumi.c scsi: mvumi: use __maybe_unused to hide pm functions 2016-03-05 17:07:46 -05:00
mvumi.h
ncr53c8xx.c
ncr53c8xx.h
nsp32.c
nsp32.h
nsp32_debug.c
nsp32_io.h
osst.c
osst.h
osst_detect.h
osst_options.h
pas16.c ncr5380: Fix soft lockups 2016-01-06 21:43:09 -05:00
pas16.h ncr5380: Fix and cleanup scsi_host_template initializers 2016-01-06 21:43:03 -05:00
pmcraid.c
pmcraid.h
ppa.c scsi: ppa: use new parport device model 2016-02-23 21:27:02 -05:00
ppa.h
ps3rom.c
qla1280.c
qla1280.h
qlogicfas.c
qlogicfas408.c
qlogicfas408.h
qlogicpti.c qlogicpti: Return correct error code 2016-03-01 20:06:49 -05:00
qlogicpti.h
raid_class.c
script_asm.pl
scsi.c
scsi.h
scsi_common.c scsi_common: do not clobber fixed sense information 2016-03-18 15:49:44 -04:00
scsi_debug.c Merge branch 'jejb-scsi' into misc 2016-01-07 15:51:13 -08:00
scsi_devinfo.c scsi_dh_alua: Add new blacklist flag 'BLIST_SYNC_ALUA' 2016-02-23 21:27:02 -05:00
scsi_dh.c scsi_dh: move 'dh_state' sysfs attribute to generic code 2015-12-02 16:29:19 -05:00
scsi_error.c
scsi_ioctl.c
scsi_lib.c scsi_dh: add 'rescan' callback 2016-02-23 21:27:02 -05:00
scsi_lib_dma.c
scsi_logging.c
scsi_logging.h
scsi_module.c
scsi_netlink.c
scsi_pm.c Revert "SCSI: Fix NULL pointer dereference in runtime PM" 2015-12-10 12:24:44 -05:00
scsi_priv.h scsi_dh: move 'dh_state' sysfs attribute to generic code 2015-12-02 16:29:19 -05:00
scsi_proc.c
scsi_sas_internal.h scsi_transport_sas: add 'scsi_target_id' sysfs attribute 2016-03-14 21:05:04 -04:00
scsi_scan.c scsi_dh: add 'rescan' callback 2016-02-23 21:27:02 -05:00
scsi_sysctl.c
scsi_sysfs.c scsi: Declare local symbols static 2016-03-29 20:29:55 -04:00
scsi_trace.c
scsi_transport_api.h
scsi_transport_fc.c
scsi_transport_iscsi.c scsi_transport_iscsi: Add 25G and 40G speed definition 2016-02-23 21:27:02 -05:00
scsi_transport_sas.c scsi_transport_sas: add 'scsi_target_id' sysfs attribute 2016-03-14 21:05:04 -04:00
scsi_transport_spi.c
scsi_transport_srp.c
scsi_typedefs.h
scsicam.c
sd.c sd: Fix discard granularity when LBPRZ=1 2016-03-14 15:50:06 -04:00
sd.h
sd_dif.c
ses.c ses: fix discovery of SATA devices in SAS enclosures 2015-12-18 19:29:50 -08:00
sg.c sg: fix dxferp in from_to case 2016-03-14 15:50:25 -04:00
sgiwd93.c
sim710.c scsi: sim710: fix build warning 2016-02-23 21:27:02 -05:00
sni_53c710.c
sr.c SCSI: fix crashes in sd and sr runtime PM 2016-01-26 17:24:16 -08:00
sr.h
sr_ioctl.c
sr_vendor.c
st.c st: Fix MTMKPART to work with newer drives 2016-02-23 21:27:02 -05:00
st.h
st_options.h
stex.c stex: Add S3/S4 support 2016-02-23 21:27:02 -05:00
storvsc_drv.c scsi: storvsc: fix SRB_STATUS_ABORTED handling 2016-03-14 15:50:16 -04:00
sun3_scsi.c atari_scsi, sun3_scsi: Remove global Scsi_Host pointer 2016-01-06 21:43:08 -05:00
sun3_scsi.h
sun3_scsi_vme.c
sun3x_esp.c
sun_esp.c
sym53c416.c
sym53c416.h
t128.c ncr5380: Fix soft lockups 2016-01-06 21:43:09 -05:00
t128.h ncr5380: Fix and cleanup scsi_host_template initializers 2016-01-06 21:43:03 -05:00
u14-34f.c
ultrastor.c
ultrastor.h
virtio_scsi.c
vmw_pvscsi.c VMW_PVSCSI: Fix the issue of DMA-API related warnings. 2015-12-10 12:57:04 -05:00
vmw_pvscsi.h VMW_PVSCSI: Fix the issue of DMA-API related warnings. 2015-12-10 12:57:04 -05:00
wd33c93.c
wd33c93.h
wd719x.c
wd719x.h
wd7000.c
xen-scsifront.c
zalon.c
zorro7xx.c