Skip to content

Commit 5dbfe7a

Browse files
lgePhilipp-Reisner
authored andcommitted
drbd: add race-breaker to drbd_go_diskless
This adds a necessary race breaker to these commits: drbd: fix for possible deadlock on IO error during resync drbd: drop wrong debug asserts, fix recently introduced race What we do is get a refcount, check the state, then depending on the state and the requested minimum disk state, either hold it (success), or give it back immediately (failed "try lock"). Some code paths (flushing of drbd metadata) may still grab and hold a refcount even if we are D_FAILED (application IO won't). So even if we hit local_cnt == 0 once after being D_FAILED, we still need to wait for that again after we changed to D_DISKLESS. Once local_cnt reaches 0 while we are D_DISKLESS, we can be sure that no one will look at the protected members anymore, so only then is it safe to free them. We cannot easily convert to standard locking primitives here, as we want to be able to use it in atomic context (we always do a "try lock"), as well as hold references for a "long time" (from IO submission to completion callback). Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
1 parent ac72412 commit 5dbfe7a

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎drivers/block/drbd/drbd_main.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3763,6 +3763,9 @@ static int w_go_diskless(struct drbd_conf *mdev, struct drbd_work *w, int unused
37633763
* the protected members anymore, though, so in the after_state_ch work
37643764
* it will be safe to free them. */
37653765
drbd_force_state(mdev, NS(disk, D_DISKLESS));
3766+
/* We need to wait for return of references checked out while we still
3767+
* have been D_FAILED, though (drbd_md_sync, bitmap io). */
3768+
wait_event(mdev->misc_wait, !atomic_read(&mdev->local_cnt));
37663769

37673770
clear_bit(GO_DISKLESS, &mdev->flags);
37683771
return 1;

‎include/linux/drbd.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454

5555
extern const char *drbd_buildtag(void);
56-
#define REL_VERSION "8.3.9rc1"
56+
#define REL_VERSION "8.3.9rc2"
5757
#define API_VERSION 88
5858
#define PRO_VERSION_MIN 86
5959
#define PRO_VERSION_MAX 95

0 commit comments

Comments
 (0)