]> git.karo-electronics.de Git - mv-sheeva.git/commit
drbd: fix potential deadlock on detach
authorLars Ellenberg <lars.ellenberg@linbit.com>
Sat, 16 Oct 2010 10:13:47 +0000 (12:13 +0200)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Fri, 22 Oct 2010 13:46:11 +0000 (15:46 +0200)
commit82f59cc6353889b426cf13b6596d5a3d100fa09e
tree6d5a678516334f0a37a56a509b84322a0352719b
parent3beec1d446fba335f07787636920892dd3b2c658
drbd: fix potential deadlock on detach

If we have contention in drbd_al_begin_iod (heavy randon IO),
an administrative request to detach the disk may deadlock
for similar reasons as the recently fixed deadlock if detaching
because of IO-error.

The approach taken here is to either go through the intermediate
cleanup state D_FAILED, or first lock out application io,
don't just go directly to D_DISKLESS.

We need an additional state bit (WAS_IO_ERROR) to distinguish
the -> D_FAILED because of IO-error from other failures.

Sanitize D_ATTACHING -> D_FAILED to D_ATTACHING -> D_DISKLESS.
If only attaching, ldev may be missing still, but would be referenced
from within the after_state_ch for -> D_FAILED, potentially
dereferencing a NULL pointer.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_main.c
drivers/block/drbd/drbd_nl.c
drivers/block/drbd/drbd_receiver.c