diff options
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 21 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 17 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_receiver.c | 11 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_state.c | 1 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_worker.c | 10 |
5 files changed, 36 insertions, 24 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index 8f9cc9d1bf93..e2b59f58a0aa 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -790,7 +790,6 @@ enum { | |||
790 | RESIZE_PENDING, /* Size change detected locally, waiting for the response from | 790 | RESIZE_PENDING, /* Size change detected locally, waiting for the response from |
791 | * the peer, if it changed there as well. */ | 791 | * the peer, if it changed there as well. */ |
792 | CONN_DRY_RUN, /* Expect disconnect after resync handshake. */ | 792 | CONN_DRY_RUN, /* Expect disconnect after resync handshake. */ |
793 | GOT_PING_ACK, /* set when we receive a ping_ack packet, misc wait gets woken */ | ||
794 | NEW_CUR_UUID, /* Create new current UUID when thawing IO */ | 793 | NEW_CUR_UUID, /* Create new current UUID when thawing IO */ |
795 | AL_SUSPENDED, /* Activity logging is currently suspended. */ | 794 | AL_SUSPENDED, /* Activity logging is currently suspended. */ |
796 | AHEAD_TO_SYNC_SOURCE, /* Ahead -> SyncSource queued */ | 795 | AHEAD_TO_SYNC_SOURCE, /* Ahead -> SyncSource queued */ |
@@ -913,6 +912,7 @@ enum { | |||
913 | DISCARD_CONCURRENT, /* Set on one node, cleared on the peer! */ | 912 | DISCARD_CONCURRENT, /* Set on one node, cleared on the peer! */ |
914 | SEND_PING, /* whether asender should send a ping asap */ | 913 | SEND_PING, /* whether asender should send a ping asap */ |
915 | SIGNAL_ASENDER, /* whether asender wants to be interrupted */ | 914 | SIGNAL_ASENDER, /* whether asender wants to be interrupted */ |
915 | GOT_PING_ACK, /* set when we receive a ping_ack packet, ping_wait gets woken */ | ||
916 | }; | 916 | }; |
917 | 917 | ||
918 | struct drbd_tconn { /* is a resource from the config file */ | 918 | struct drbd_tconn { /* is a resource from the config file */ |
@@ -925,6 +925,7 @@ struct drbd_tconn { /* is a resource from the config file */ | |||
925 | struct net_conf *net_conf; /* protected by get_net_conf() and put_net_conf() */ | 925 | struct net_conf *net_conf; /* protected by get_net_conf() and put_net_conf() */ |
926 | atomic_t net_cnt; /* Users of net_conf */ | 926 | atomic_t net_cnt; /* Users of net_conf */ |
927 | wait_queue_head_t net_cnt_wait; | 927 | wait_queue_head_t net_cnt_wait; |
928 | wait_queue_head_t ping_wait; /* Woken upon reception of a ping, and a state change */ | ||
928 | 929 | ||
929 | struct drbd_socket data; /* data/barrier/cstate/parameter packets */ | 930 | struct drbd_socket data; /* data/barrier/cstate/parameter packets */ |
930 | struct drbd_socket meta; /* ping/ack (metadata) packets */ | 931 | struct drbd_socket meta; /* ping/ack (metadata) packets */ |
@@ -1180,12 +1181,12 @@ extern int drbd_send_state(struct drbd_conf *mdev); | |||
1180 | extern int _conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct socket *sock, | 1181 | extern int _conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct socket *sock, |
1181 | enum drbd_packet cmd, struct p_header *h, size_t size, | 1182 | enum drbd_packet cmd, struct p_header *h, size_t size, |
1182 | unsigned msg_flags); | 1183 | unsigned msg_flags); |
1184 | extern int conn_send_cmd(struct drbd_tconn *tconn, int vnr, int use_data_socket, | ||
1185 | enum drbd_packet cmd, struct p_header *h, size_t size); | ||
1183 | extern int conn_send_cmd2(struct drbd_tconn *tconn, enum drbd_packet cmd, | 1186 | extern int conn_send_cmd2(struct drbd_tconn *tconn, enum drbd_packet cmd, |
1184 | char *data, size_t size); | 1187 | char *data, size_t size); |
1185 | #define USE_DATA_SOCKET 1 | 1188 | #define USE_DATA_SOCKET 1 |
1186 | #define USE_META_SOCKET 0 | 1189 | #define USE_META_SOCKET 0 |
1187 | extern int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket, | ||
1188 | enum drbd_packet cmd, struct p_header *h, size_t size); | ||
1189 | extern int drbd_send_sync_param(struct drbd_conf *mdev, struct syncer_conf *sc); | 1190 | extern int drbd_send_sync_param(struct drbd_conf *mdev, struct syncer_conf *sc); |
1190 | extern int drbd_send_b_ack(struct drbd_conf *mdev, u32 barrier_nr, | 1191 | extern int drbd_send_b_ack(struct drbd_conf *mdev, u32 barrier_nr, |
1191 | u32 set_size); | 1192 | u32 set_size); |
@@ -1886,6 +1887,12 @@ static inline int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock, | |||
1886 | return _conn_send_cmd(mdev->tconn, mdev->vnr, sock, cmd, h, size, msg_flags); | 1887 | return _conn_send_cmd(mdev->tconn, mdev->vnr, sock, cmd, h, size, msg_flags); |
1887 | } | 1888 | } |
1888 | 1889 | ||
1890 | static inline int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket, | ||
1891 | enum drbd_packet cmd, struct p_header *h, size_t size) | ||
1892 | { | ||
1893 | return conn_send_cmd(mdev->tconn, mdev->vnr, use_data_socket, cmd, h, size); | ||
1894 | } | ||
1895 | |||
1889 | static inline int drbd_send_short_cmd(struct drbd_conf *mdev, | 1896 | static inline int drbd_send_short_cmd(struct drbd_conf *mdev, |
1890 | enum drbd_packet cmd) | 1897 | enum drbd_packet cmd) |
1891 | { | 1898 | { |
@@ -1893,16 +1900,16 @@ static inline int drbd_send_short_cmd(struct drbd_conf *mdev, | |||
1893 | return drbd_send_cmd(mdev, USE_DATA_SOCKET, cmd, &h, sizeof(h)); | 1900 | return drbd_send_cmd(mdev, USE_DATA_SOCKET, cmd, &h, sizeof(h)); |
1894 | } | 1901 | } |
1895 | 1902 | ||
1896 | static inline int drbd_send_ping(struct drbd_conf *mdev) | 1903 | static inline int drbd_send_ping(struct drbd_tconn *tconn) |
1897 | { | 1904 | { |
1898 | struct p_header h; | 1905 | struct p_header h; |
1899 | return drbd_send_cmd(mdev, USE_META_SOCKET, P_PING, &h, sizeof(h)); | 1906 | return conn_send_cmd(tconn, 0, USE_META_SOCKET, P_PING, &h, sizeof(h)); |
1900 | } | 1907 | } |
1901 | 1908 | ||
1902 | static inline int drbd_send_ping_ack(struct drbd_conf *mdev) | 1909 | static inline int drbd_send_ping_ack(struct drbd_tconn *tconn) |
1903 | { | 1910 | { |
1904 | struct p_header h; | 1911 | struct p_header h; |
1905 | return drbd_send_cmd(mdev, USE_META_SOCKET, P_PING_ACK, &h, sizeof(h)); | 1912 | return conn_send_cmd(tconn, 0, USE_META_SOCKET, P_PING_ACK, &h, sizeof(h)); |
1906 | } | 1913 | } |
1907 | 1914 | ||
1908 | static inline void drbd_thread_stop(struct drbd_thread *thi) | 1915 | static inline void drbd_thread_stop(struct drbd_thread *thi) |
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index d418bca2bb14..b43ad87a536a 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -707,29 +707,29 @@ int _conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct socket *sock, | |||
707 | /* don't pass the socket. we may only look at it | 707 | /* don't pass the socket. we may only look at it |
708 | * when we hold the appropriate socket mutex. | 708 | * when we hold the appropriate socket mutex. |
709 | */ | 709 | */ |
710 | int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket, | 710 | int conn_send_cmd(struct drbd_tconn *tconn, int vnr, int use_data_socket, |
711 | enum drbd_packet cmd, struct p_header *h, size_t size) | 711 | enum drbd_packet cmd, struct p_header *h, size_t size) |
712 | { | 712 | { |
713 | int ok = 0; | 713 | int ok = 0; |
714 | struct socket *sock; | 714 | struct socket *sock; |
715 | 715 | ||
716 | if (use_data_socket) { | 716 | if (use_data_socket) { |
717 | mutex_lock(&mdev->tconn->data.mutex); | 717 | mutex_lock(&tconn->data.mutex); |
718 | sock = mdev->tconn->data.socket; | 718 | sock = tconn->data.socket; |
719 | } else { | 719 | } else { |
720 | mutex_lock(&mdev->tconn->meta.mutex); | 720 | mutex_lock(&tconn->meta.mutex); |
721 | sock = mdev->tconn->meta.socket; | 721 | sock = tconn->meta.socket; |
722 | } | 722 | } |
723 | 723 | ||
724 | /* drbd_disconnect() could have called drbd_free_sock() | 724 | /* drbd_disconnect() could have called drbd_free_sock() |
725 | * while we were waiting in down()... */ | 725 | * while we were waiting in down()... */ |
726 | if (likely(sock != NULL)) | 726 | if (likely(sock != NULL)) |
727 | ok = _drbd_send_cmd(mdev, sock, cmd, h, size, 0); | 727 | ok = _conn_send_cmd(tconn, vnr, sock, cmd, h, size, 0); |
728 | 728 | ||
729 | if (use_data_socket) | 729 | if (use_data_socket) |
730 | mutex_unlock(&mdev->tconn->data.mutex); | 730 | mutex_unlock(&tconn->data.mutex); |
731 | else | 731 | else |
732 | mutex_unlock(&mdev->tconn->meta.mutex); | 732 | mutex_unlock(&tconn->meta.mutex); |
733 | return ok; | 733 | return ok; |
734 | } | 734 | } |
735 | 735 | ||
@@ -2191,6 +2191,7 @@ struct drbd_tconn *drbd_new_tconn(char *name) | |||
2191 | spin_lock_init(&tconn->req_lock); | 2191 | spin_lock_init(&tconn->req_lock); |
2192 | atomic_set(&tconn->net_cnt, 0); | 2192 | atomic_set(&tconn->net_cnt, 0); |
2193 | init_waitqueue_head(&tconn->net_cnt_wait); | 2193 | init_waitqueue_head(&tconn->net_cnt_wait); |
2194 | init_waitqueue_head(&tconn->ping_wait); | ||
2194 | idr_init(&tconn->volumes); | 2195 | idr_init(&tconn->volumes); |
2195 | 2196 | ||
2196 | drbd_init_workqueue(&tconn->data.work); | 2197 | drbd_init_workqueue(&tconn->data.work); |
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 02fa1b25dce5..2b69a15a55dd 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
@@ -4279,16 +4279,17 @@ static int got_RqSReply(struct drbd_conf *mdev, enum drbd_packet cmd) | |||
4279 | 4279 | ||
4280 | static int got_Ping(struct drbd_conf *mdev, enum drbd_packet cmd) | 4280 | static int got_Ping(struct drbd_conf *mdev, enum drbd_packet cmd) |
4281 | { | 4281 | { |
4282 | return drbd_send_ping_ack(mdev); | 4282 | return drbd_send_ping_ack(mdev->tconn); |
4283 | 4283 | ||
4284 | } | 4284 | } |
4285 | 4285 | ||
4286 | static int got_PingAck(struct drbd_conf *mdev, enum drbd_packet cmd) | 4286 | static int got_PingAck(struct drbd_conf *mdev, enum drbd_packet cmd) |
4287 | { | 4287 | { |
4288 | struct drbd_tconn *tconn = mdev->tconn; | ||
4288 | /* restore idle timeout */ | 4289 | /* restore idle timeout */ |
4289 | mdev->tconn->meta.socket->sk->sk_rcvtimeo = mdev->tconn->net_conf->ping_int*HZ; | 4290 | tconn->meta.socket->sk->sk_rcvtimeo = tconn->net_conf->ping_int*HZ; |
4290 | if (!test_and_set_bit(GOT_PING_ACK, &mdev->flags)) | 4291 | if (!test_and_set_bit(GOT_PING_ACK, &tconn->flags)) |
4291 | wake_up(&mdev->misc_wait); | 4292 | wake_up(&tconn->ping_wait); |
4292 | 4293 | ||
4293 | return true; | 4294 | return true; |
4294 | } | 4295 | } |
@@ -4610,7 +4611,7 @@ int drbd_asender(struct drbd_thread *thi) | |||
4610 | while (get_t_state(thi) == RUNNING) { | 4611 | while (get_t_state(thi) == RUNNING) { |
4611 | drbd_thread_current_set_cpu(thi); | 4612 | drbd_thread_current_set_cpu(thi); |
4612 | if (test_and_clear_bit(SEND_PING, &tconn->flags)) { | 4613 | if (test_and_clear_bit(SEND_PING, &tconn->flags)) { |
4613 | if (!drbd_send_ping(tconn->volume0)) { | 4614 | if (!drbd_send_ping(tconn)) { |
4614 | conn_err(tconn, "drbd_send_ping has failed\n"); | 4615 | conn_err(tconn, "drbd_send_ping has failed\n"); |
4615 | goto reconnect; | 4616 | goto reconnect; |
4616 | } | 4617 | } |
diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c index 30a3a1de07cb..d5777159a2b1 100644 --- a/drivers/block/drbd/drbd_state.c +++ b/drivers/block/drbd/drbd_state.c | |||
@@ -737,6 +737,7 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, | |||
737 | 737 | ||
738 | wake_up(&mdev->misc_wait); | 738 | wake_up(&mdev->misc_wait); |
739 | wake_up(&mdev->state_wait); | 739 | wake_up(&mdev->state_wait); |
740 | wake_up(&mdev->tconn->ping_wait); | ||
740 | 741 | ||
741 | /* aborted verify run. log the last position */ | 742 | /* aborted verify run. log the last position */ |
742 | if ((os.conn == C_VERIFY_S || os.conn == C_VERIFY_T) && | 743 | if ((os.conn == C_VERIFY_S || os.conn == C_VERIFY_T) && |
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index 418f44ad9a86..8539df25bc22 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c | |||
@@ -730,10 +730,12 @@ static int w_resync_finished(struct drbd_work *w, int cancel) | |||
730 | 730 | ||
731 | static void ping_peer(struct drbd_conf *mdev) | 731 | static void ping_peer(struct drbd_conf *mdev) |
732 | { | 732 | { |
733 | clear_bit(GOT_PING_ACK, &mdev->flags); | 733 | struct drbd_tconn *tconn = mdev->tconn; |
734 | request_ping(mdev->tconn); | 734 | |
735 | wait_event(mdev->misc_wait, | 735 | clear_bit(GOT_PING_ACK, &tconn->flags); |
736 | test_bit(GOT_PING_ACK, &mdev->flags) || mdev->state.conn < C_CONNECTED); | 736 | request_ping(tconn); |
737 | wait_event(tconn->ping_wait, | ||
738 | test_bit(GOT_PING_ACK, &tconn->flags) || mdev->state.conn < C_CONNECTED); | ||
737 | } | 739 | } |
738 | 740 | ||
739 | int drbd_resync_finished(struct drbd_conf *mdev) | 741 | int drbd_resync_finished(struct drbd_conf *mdev) |