drbd: avoid potential deadlock during handshake
authorLars Ellenberg <lars.ellenberg@linbit.com>
Mon, 8 Jun 2015 13:18:45 +0000 (15:18 +0200)
committerJens Axboe <axboe@fb.com>
Wed, 25 Nov 2015 16:22:03 +0000 (09:22 -0700)
commit5f7c01249bea67c32a1a1551a8f2fe0b8b801ab4
tree369efade0df17d0170e1dcade7b9043e559f372a
parent603ee2c8c78b2fb5a9dc14fb8b2bb2650ebcab1f
drbd: avoid potential deadlock during handshake

During handshake communication, we also reconsider our device size,
using drbd_determine_dev_size(). Just in case we need to change the
offsets or layout of our on-disk metadata, we lock out application
and other meta data IO, and wait for the activity log to be "idle"
(no more referenced extents).

If this handshake happens just after a connection loss, with a fencing
policy of "resource-and-stonith", we have frozen IO.

If, additionally, the activity log was "starving" (too many incoming
random writes at that point in time), it won't become idle, ever,
because of the frozen IO, and this would be a lockup of the receiver
thread, and consquentially of DRBD.

Previous logic (re-)initialized with a special "empty" transaction
block, which required the activity log to fully drain first.

Instead, write out some standard activity log transactions.
Using lc_try_lock_for_transaction() instead of lc_try_lock() does not
care about pending activity log references, avoiding the potential
deadlock.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/block/drbd/drbd_actlog.c
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_nl.c