linux/drivers/block/drbd
Lars Ellenberg 33d32fa712 drbd: fix potential deadlock when trying to detach during handshake
When requesting a detach, we first suspend IO, and also inhibit meta-data IO
by means of drbd_md_get_buffer(), because we don't want to "fail" the disk
while there is IO in-flight: the transition into D_FAILED for detach purposes
may get misinterpreted as actual IO error in a confused endio function.

We wrap it all into wait_event(), to retry in case the drbd_req_state()
returns SS_IN_TRANSIENT_STATE, as it does for example during an ongoing
connection handshake.

In that example, the receiver thread may need to grab drbd_md_get_buffer()
during the handshake to make progress.  To avoid potential deadlock with
detach, detach needs to grab and release the meta data buffer inside of
that wait_event retry loop. To avoid lock inversion between
mutex_lock(&device->state_mutex) and drbd_md_get_buffer(device),
introduce a new enum chg_state_flag CS_INHIBIT_MD_IO, and move the
call to drbd_md_get_buffer() inside the state_mutex grabbed in
drbd_req_state().

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2017-08-29 15:34:45 -06:00
..
drbd_actlog.c block: replace bi_bdev with a gendisk pointer and partitions index 2017-08-23 12:49:55 -06:00
drbd_bitmap.c block: replace bi_bdev with a gendisk pointer and partitions index 2017-08-23 12:49:55 -06:00
drbd_debugfs.c drbd: make intelligent use of blkdev_issue_zeroout 2017-04-08 11:25:38 -06:00
drbd_debugfs.h drbd: debugfs: add basic hierarchy 2014-07-10 18:35:16 +02:00
drbd_int.h drbd: introduce drbd_recv_header_maybe_unplug 2017-08-29 15:34:43 -06:00
drbd_interval.c drbd: use RB_DECLARE_CALLBACKS() to define augment callbacks 2014-09-18 09:00:17 -06:00
drbd_interval.h drbd: code cleanups without semantic changes 2016-06-13 21:43:07 -06:00
drbd_main.c drbd: fix rmmod cleanup, remove _all_ debugfs entries 2017-08-29 15:34:45 -06:00
drbd_nl.c drbd: fix potential deadlock when trying to detach during handshake 2017-08-29 15:34:45 -06:00
drbd_nla.c netlink: pass extended ACK struct to parsing functions 2017-04-13 13:58:22 -04:00
drbd_nla.h
drbd_proc.c drbd: A single dot should be put into a sequence. 2017-08-29 15:34:45 -06:00
drbd_protocol.h drbd: introduce WRITE_SAME support 2016-06-13 21:43:07 -06:00
drbd_receiver.c drbd: mark symbols static where possible 2017-08-29 15:34:44 -06:00
drbd_req.c drbd: add explicit plugging when submitting batches 2017-08-29 15:34:44 -06:00
drbd_req.h drbd: introduce drbd_recv_header_maybe_unplug 2017-08-29 15:34:43 -06:00
drbd_state_change.h drbd: Backport the "events2" command 2015-11-25 09:22:00 -07:00
drbd_state.c drbd: fix potential deadlock when trying to detach during handshake 2017-08-29 15:34:45 -06:00
drbd_state.h drbd: fix potential deadlock when trying to detach during handshake 2017-08-29 15:34:45 -06:00
drbd_strings.c drbd: code cleanups without semantic changes 2016-06-13 21:43:07 -06:00
drbd_strings.h
drbd_vli.h
drbd_worker.c drbd: fix potential get_ldev/put_ldev refcount imbalance during attach 2017-08-29 15:34:45 -06:00
Kconfig
Makefile drbd: debugfs: add basic hierarchy 2014-07-10 18:35:16 +02:00