drbd: fix race on meta-data update, addendum
authorLars Ellenberg <lars.ellenberg@linbit.com>
Fri, 3 Sep 2010 08:00:09 +0000 (10:00 +0200)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Thu, 14 Oct 2010 16:38:30 +0000 (18:38 +0200)
commitee15b038164fcf19b798021762dee3cf5cbc6433
tree8d2cca781af96296a591a14928ece247fc682ef3
parent63106d3c6c769b6219bd04edde513b12abae3f61
drbd: fix race on meta-data update, addendum

addendum to baa33ae4eaa4477b60af7c434c0ddd1d182c1ae7

The race:
    drbd_md_sync()
if (!test_and_clear_bit(MD_DIRTY, &mdev->flags))
return;
    ==> RACE with drbd_md_mark_dirty() rearming the timer.
del_timer(&mdev->md_sync_timer);

    Fixed by moving the del_timer before the test_and_clear_bit.

Additionally only rearm the timer in drbd_md_mark_dirty, if MD_DIRTY was
not already set, reduce the grace period from five to one second, and
add an ifdef'ed debuging aid to find code paths missing an explicit
drbd_md_sync, if any, as those are the only relevant ones for this race.

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