linux/drivers/block
Ed Cashin e52a293264 aoe: avoid races between device destruction and discovery
This change avoids a race that could result in a NULL pointer derference
following a WARNing from kobject_add_internal, "don't try to register
things with the same name in the same directory."

The problem was found with a test that forgets and discovers an
aoe device in a loop:

  while test ! -r /tmp/stop; do
	aoe-flush -a
	aoe-discover
  done

The race was between aoedev_flush taking aoedevs out of the devlist,
allowing a new discovery of the same AoE target to take place before the
driver gets around to calling sysfs_remove_group.  Fixing that one
revealed another race between do_open and add_disk, and this patch avoids
that, too.

The fix required some care, because for flushing (forgetting) an aoedev,
some of the steps must be performed under lock and some must be able to
sleep.  Also, for discovering a new aoedev, some steps might sleep.

The check for a bad aoedev pointer remains from a time when about half of
this patch was done, and it was possible for the
bdev->bd_disk->private_data to become corrupted.  The check should be
removed eventually, but it is not expected to add significant overhead,
occurring in the aoeblk_open routine.

Signed-off-by: Ed Cashin <ecashin@coraid.com>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-12-17 17:15:25 -08:00
..
aoe aoe: avoid races between device destruction and discovery 2012-12-17 17:15:25 -08:00
drbd block: Generalized bio pool freeing 2012-09-09 10:35:38 +02:00
mtip32xx mtip32xx: Fix padding issue 2012-11-23 14:32:55 +01:00
paride paride/pcd: fix bool verbose module parameter. 2012-01-13 09:32:26 +10:30
xen-blkback xen/blkback: Change xen_vbd's flush_support and discard_secure to have type unsigned int, rather than bool 2012-10-30 08:37:20 +01:00
amiflop.c fs: move code out of buffer.c 2012-01-03 22:54:07 -05:00
ataflop.c block: unexport DISK_EVENT_MEDIA_CHANGE for legacy/fringe drivers 2011-04-21 21:33:05 +02:00
brd.c block: remove the second argument of k[un]map_atomic() 2012-03-20 21:48:16 +08:00
cciss_cmd.h cciss: use new doorbell-bit-5 reset method 2011-05-06 08:23:55 -06:00
cciss_scsi.c cciss: fix handling of protocol error 2012-09-18 11:57:08 +02:00
cciss_scsi.h cciss: add cciss_tape_cmds module paramter 2011-05-06 08:23:59 -06:00
cciss.c cciss: remove unneeded memset() 2012-10-30 08:36:58 +01:00
cciss.h cciss: Adds simple mode functionality 2011-08-08 11:40:15 +02:00
cpqarray.c drivers/block/cpqarray.c: use pci_dev->revision 2011-09-21 10:02:13 +02:00
cpqarray.h
cryptoloop.c
DAC960.c dac960: Remove unused variables from DAC960_CreateProcEntries() 2012-05-11 16:42:14 +02:00
DAC960.h
floppy.c floppy: destroy floppy workqueue before cleaning up the queue 2012-11-23 14:32:54 +01:00
hd.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
ida_cmd.h
ida_ioctl.h
Kconfig cciss: select CONFIG_CHECK_SIGNATURE 2012-10-30 08:37:00 +01:00
loop.c loop: Make explicit loop device destruction lazy 2012-10-30 08:37:31 +01:00
Makefile block: remove the deprecated ub driver 2012-09-05 17:18:53 -07:00
mg_disk.c mg_disk: Use struct dev_pm_ops for power management 2012-07-06 19:07:00 +02:00
nbd.c nbd: handle discard requests 2012-10-06 03:05:24 +09:00
nvme.c PCI changes for the 3.7 merge window: 2012-10-01 12:05:36 -07:00
osdblk.c block: Add bio_clone_bioset(), bio_clone_kmalloc() 2012-09-09 10:35:39 +02:00
pktcdvd.c pktcdvd: Switch to bio_kmalloc() 2012-09-09 10:35:39 +02:00
ps3disk.c block: Fix files that are modules and hence need module.h 2011-10-31 19:31:13 -04:00
ps3vram.c Merge branch 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux 2011-11-06 19:44:47 -08:00
rbd_types.h rbd: define some new format constants 2012-10-01 14:30:53 -05:00
rbd.c rbd: BUG on invalid layout 2012-10-01 17:20:00 -05:00
smart1,2.h
sunvdc.c powerpc+sparc/vio: Modernize driver registration 2012-03-28 11:33:24 +11:00
swim_asm.S
swim.c m68k/mac: cleanup forward declarations 2011-12-10 19:52:46 +01:00
swim3.c block/swim3: Locking fixes 2011-12-12 12:42:12 +01:00
sx8.c block, sx8: fix pointer math issue getting fw version 2012-03-03 19:44:39 +01:00
umem.c blk: pass from_schedule to non-request unplug functions. 2012-07-31 09:08:15 +02:00
umem.h
virtio_blk.c virtio-blk: Disable callback in virtblk_done() 2012-09-28 15:05:16 +09:30
xd.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
xd.h
xen-blkfront.c workqueue: deprecate flush[_delayed]_work_sync() 2012-08-20 14:51:24 -07:00
xsysace.c block: xsysace: Don't use NO_IRQ 2012-01-05 08:34:29 +01:00
z2ram.c