Re: warning because of race between userspace and add_disk()?

From: Jens Axboe
Date: Wed Jul 06 2011 - 10:57:05 EST


On 2011-07-06 02:14, Roland Dreier wrote:
> Hi Jens!
>
> I'm seeing the warning below (with 3.0-rc5) when I hot-add a disk.
> The system has a JBOD with 4 SAS paths, so we get 4 /dev/sdXX for the
> disk (I don't think this is strictly required to trigger this, but I
> think it makes the race bigger).
>
> What I _think_ is happening is that add_disk() exposes the /dev/sdXX
> device to userspace before it does disk_add_events(), and the
> multipath daemon immediately tries to open the device. This means
> that blkdev_get() (called from blkdev_open()) races with
> disk_add_events() and so the first call to disk_block_events() returns
> immediately because of
>
> struct disk_events *ev = disk->ev;
> if (!ev)
> return;
>
> but then on the way out, disk_unblock_events() finds that disk->ev has
> been set and so hits the warning.
>
> I guess the fix would be to be more careful about the order we expose
> things when registering disks?

It certainly looks like it, we need to order disk_add_events() before
register_disk() or handle this more gracefully. I'll cook up a patch.

--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/