linux/drivers
James Smart a0785edff7 [SCSI] fc transport: resolve scan vs delete deadlocks
In a prior posting to linux-scsi on the fc transport and workq
deadlocks, we noted a second error that did not have a patch:
  http://marc.theaimsgroup.com/?l=linux-scsi&m=114467847711383&w=2
  - There's a deadlock where scsi_remove_target() has to sit behind
    scsi_scan_target() due to contention over the scan_lock().

Subsequently we posted a request for comments about the deadlock:
  http://marc.theaimsgroup.com/?l=linux-scsi&m=114469358829500&w=2

This posting resolves the second error. Here's what we now understand,
and are implementing:

  If the lldd deletes the rport while a scan is active, the sdev's queue
  is blocked which stops the issuing of commands associated with the scan.
  At this point, the scan stalls, and does so with the shost->scan_mutex held.
  If, at this point, if any scan or delete request is made on the host, it
  will stall waiting for the scan_mutex.

  For the FC transport, we queue all delete work to a single workq.
  So, things worked fine when competing with the scan, as long as the
  target blocking the scan was the same target at the top of our delete
  workq, as the delete workq routine always unblocked just prior to
  requesting the delete.  Unfortunately, if the top of our delete workq
  was for a different target, we deadlock.  Additionally, if the target
  blocking scan returned, we were unblocking it in the scan workq routine,
  which really won't execute until the existing stalled scan workq
  completes (e.g. we're re-scheduling it while it is in the midst of its
  execution).

  This patch moves the unblock out of the workq routines and moves it to
  the context that is scheduling the work. This ensures that at some point,
  we will unblock the target that is blocking scan.  Please note, however,
  that the deadlock condition may still occur while it waits for the
  transport to timeout an unblock on a target.  Worst case, this is bounded
  by the transport dev_loss_tmo (default: 30 seconds).

Finally, Michael Reed deserves the credit for the bulk of this patch,
analysis, and it's testing. Thank you for your help.

Note: The request for comments statements about the gross-ness of the
  scan_mutex still stand.

Signed-off-by: Michael Reed <mdr@sgi.com>
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-06-27 10:52:49 -05:00
..
acorn
acpi
amba
atm
base
block [PATCH] CCISS: tidy up product table indentation 2006-06-25 10:01:22 -07:00
bluetooth
cdrom [PATCH] cdrom/mcdx: section fixes 2006-06-25 10:01:16 -07:00
char [PATCH] synclink_gt: add GT2 adapter support 2006-06-25 10:01:24 -07:00
connector
cpufreq
crypto
dio
dma
edac
eisa
fc4
firmware [PATCH] DMI: cleanup kernel-doc, add to DocBook 2006-06-25 10:01:24 -07:00
hwmon
i2c
ide [PATCH] ide-floppy: fix debug-only syntax error 2006-06-25 10:01:20 -07:00
ieee1394 [PATCH] ieee1394: nodemgr: do not peek into struct semaphore 2006-06-25 10:00:54 -07:00
infiniband Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband 2006-06-25 16:07:58 -07:00
input [PATCH] random: remove redundant SA_SAMPLE_RANDOM from touchscreen drivers 2006-06-25 10:01:00 -07:00
isdn
leds [PATCH] LED: add LED heartbeat trigger 2006-06-25 10:01:23 -07:00
macintosh [PATCH] Rewritten backlight infrastructure for portable Apple computers 2006-06-25 10:00:59 -07:00
mca
md
media Fixes some sync issues between V4L/DVB development and GIT 2006-06-25 02:05:24 -03:00
message
mfd
misc
mmc
mtd
net [PATCH] m68knommu: 532x FEC eth struct map 2006-06-25 17:43:33 -07:00
nubus
oprofile [PATCH] oprofile: convert from semaphores to mutexes 2006-06-25 10:01:04 -07:00
parisc
parport [PATCH] parport: add to kernel-doc 2006-06-25 10:01:25 -07:00
pci
pcmcia
pnp [PATCH] pnp: card_probe(): fix memory leak 2006-06-25 10:01:01 -07:00
rapidio
rtc [PATCH] RTC: add rtc-ds1742 driver 2006-06-25 10:01:14 -07:00
s390 [PATCH] kernel/sys.c: cleanups 2006-06-25 10:01:06 -07:00
sbus [PATCH] mm: remove VM_LOCKED before remap_pfn_range and drop VM_SHM 2006-06-25 10:00:55 -07:00
scsi [SCSI] fc transport: resolve scan vs delete deadlocks 2006-06-27 10:52:49 -05:00
serial [PATCH] m68knommu: 532x UART support 2006-06-25 17:43:33 -07:00
sh
sn
spi
tc
telephony
usb Merge branch 'master' of /home/trondmy/kernel/linux-2.6/ 2006-06-25 06:44:44 -04:00
video Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb 2006-06-25 10:09:31 -07:00
w1
zorro
Kconfig
Makefile