From f09448f12ede6c86da35221af0eec483b9753fe8 Mon Sep 17 00:00:00 2001 From: Philipp Reisner Date: Tue, 2 Mar 2010 15:03:44 +0100 Subject: [PATCH 11/16] Reduce the time an empty resync takes usually This mitigates changes introduced with commit 4b6803a3276652da3737 --- drbd/drbd_int.h | 1 + drbd/drbd_receiver.c | 2 ++ drbd/drbd_worker.c | 12 +++++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h index c8b810d..0eaa36c 100644 --- a/drbd/drbd_int.h +++ b/drbd/drbd_int.h @@ -942,6 +942,7 @@ enum { * while this is set. */ RESIZE_PENDING, /* Size change detected locally, waiting for the response from * the peer, if it changed there as well. */ + GOT_PING_ACK, /* set when we receive a ping_ack packet, misc wait gets woken */ }; struct drbd_bitmap; /* opaque for drbd_conf */ diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c index 3b123a6..e5c749f 100644 --- a/drbd/drbd_receiver.c +++ b/drbd/drbd_receiver.c @@ -4129,6 +4129,8 @@ STATIC int got_PingAck(struct drbd_conf *mdev, struct p_header *h) { /* restore idle timeout */ mdev->meta.socket->sk->sk_rcvtimeo = mdev->net_conf->ping_int*HZ; + if (!test_and_set_bit(GOT_PING_ACK, &mdev->flags)) + wake_up(&mdev->misc_wait); return TRUE; } diff --git a/drbd/drbd_worker.c b/drbd/drbd_worker.c index d4c4954..d6deead 100644 --- a/drbd/drbd_worker.c +++ b/drbd/drbd_worker.c @@ -1320,6 +1320,14 @@ int drbd_alter_sa(struct drbd_conf *mdev, int na) return retcode; } +STATIC void ping_peer(struct drbd_conf *mdev) +{ + clear_bit(GOT_PING_ACK, &mdev->flags); + request_ping(mdev); + wait_event(mdev->misc_wait, + test_bit(GOT_PING_ACK, &mdev->flags) || mdev->state.conn < C_CONNECTED); +} + /** * drbd_start_resync() - Start the resync process * @mdev: DRBD device. @@ -1418,9 +1426,7 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side) if (mdev->rs_total == 0) { /* Peer still reachable? Beware of failing before-resync-target handlers! */ - request_ping(mdev); - __set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(mdev->net_conf->ping_timeo*HZ/9); /* 9 instead 10 */ + ping_peer(mdev); drbd_resync_finished(mdev); return; } -- 1.6.3.3