diff options
Diffstat (limited to 'drivers/block/drbd/drbd_main.c')
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 4da6f11cc82e..2190064d59bd 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -1387,6 +1387,17 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, | |||
1387 | spin_unlock_irq(&mdev->req_lock); | 1387 | spin_unlock_irq(&mdev->req_lock); |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | /* Became sync source. With protocol >= 96, we still need to send out | ||
1391 | * the sync uuid now. Need to do that before any drbd_send_state, or | ||
1392 | * the other side may go "paused sync" before receiving the sync uuids, | ||
1393 | * which is unexpected. */ | ||
1394 | if ((os.conn != C_SYNC_SOURCE && os.conn != C_PAUSED_SYNC_S) && | ||
1395 | (ns.conn == C_SYNC_SOURCE || ns.conn == C_PAUSED_SYNC_S) && | ||
1396 | mdev->agreed_pro_version >= 96 && get_ldev(mdev)) { | ||
1397 | drbd_gen_and_send_sync_uuid(mdev); | ||
1398 | put_ldev(mdev); | ||
1399 | } | ||
1400 | |||
1390 | /* Do not change the order of the if above and the two below... */ | 1401 | /* Do not change the order of the if above and the two below... */ |
1391 | if (os.pdsk == D_DISKLESS && ns.pdsk > D_DISKLESS) { /* attach on the peer */ | 1402 | if (os.pdsk == D_DISKLESS && ns.pdsk > D_DISKLESS) { /* attach on the peer */ |
1392 | drbd_send_uuids(mdev); | 1403 | drbd_send_uuids(mdev); |
@@ -1980,12 +1991,17 @@ int drbd_send_uuids_skip_initial_sync(struct drbd_conf *mdev) | |||
1980 | return _drbd_send_uuids(mdev, 8); | 1991 | return _drbd_send_uuids(mdev, 8); |
1981 | } | 1992 | } |
1982 | 1993 | ||
1983 | 1994 | int drbd_gen_and_send_sync_uuid(struct drbd_conf *mdev) | |
1984 | int drbd_send_sync_uuid(struct drbd_conf *mdev, u64 val) | ||
1985 | { | 1995 | { |
1986 | struct p_rs_uuid p; | 1996 | struct p_rs_uuid p; |
1997 | u64 uuid; | ||
1998 | |||
1999 | D_ASSERT(mdev->state.disk == D_UP_TO_DATE); | ||
1987 | 2000 | ||
1988 | p.uuid = cpu_to_be64(val); | 2001 | get_random_bytes(&uuid, sizeof(u64)); |
2002 | drbd_uuid_set(mdev, UI_BITMAP, uuid); | ||
2003 | drbd_md_sync(mdev); | ||
2004 | p.uuid = cpu_to_be64(uuid); | ||
1989 | 2005 | ||
1990 | return drbd_send_cmd(mdev, USE_DATA_SOCKET, P_SYNC_UUID, | 2006 | return drbd_send_cmd(mdev, USE_DATA_SOCKET, P_SYNC_UUID, |
1991 | (struct p_header80 *)&p, sizeof(p)); | 2007 | (struct p_header80 *)&p, sizeof(p)); |