linux/drivers/block/aoe
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.h aoe: avoid races between device destruction and discovery 2012-12-17 17:15:25 -08:00
aoeblk.c aoe: avoid races between device destruction and discovery 2012-12-17 17:15:25 -08:00
aoechr.c aoe: whitespace cleanup 2012-12-17 17:15:24 -08:00
aoecmd.c aoe: improve handling of misbehaving network paths 2012-12-17 17:15:25 -08:00
aoedev.c aoe: avoid races between device destruction and discovery 2012-12-17 17:15:25 -08:00
aoemain.c aoe: whitespace cleanup 2012-12-17 17:15:24 -08:00
aoenet.c aoe: whitespace cleanup 2012-12-17 17:15:24 -08:00
Makefile drivers/block/aoe/Makefile: replace the use of <module>-objs with <module>-y 2011-01-19 08:25:02 -07:00