From: Philipp Reisner <philipp.reisner@linbit.com>
To: linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Cc: drbd-dev@lists.linbit.com
Subject: [PATCH 08/20] drbd: New net configuration option socket-check-timeout
Date: Tue, 1 Jul 2014 18:16:38 +0200 [thread overview]
Message-ID: <1404231410-29852-9-git-send-email-philipp.reisner@linbit.com> (raw)
In-Reply-To: <1404231410-29852-1-git-send-email-philipp.reisner@linbit.com>
In setups involving a DRBD-proxy and connections that experience a lot of
buffer-bloat it might be necessary to set ping-timeout to an
unusual high value. By default DRBD uses the same value to wait if a newly
established TCP-connection is stable. Since the DRBD-proxy is usually located
in the same data center such a long wait time may hinder DRBD's connect process.
In such setups socket-check-timeout should be set to
at least to the round trip time between DRBD and DRBD-proxy. I.e. in most
cases to 1.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
---
drivers/block/drbd/drbd_receiver.c | 46 +++++++++++++++++++++++++-------------
include/linux/drbd_genl.h | 1 +
include/linux/drbd_limits.h | 5 +++++
3 files changed, 36 insertions(+), 16 deletions(-)
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 7da83f3..b89e6fb 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -819,7 +819,7 @@ static int receive_first_packet(struct drbd_connection *connection, struct socke
* drbd_socket_okay() - Free the socket if its connection is not okay
* @sock: pointer to the pointer to the socket.
*/
-static int drbd_socket_okay(struct socket **sock)
+static bool drbd_socket_okay(struct socket **sock)
{
int rr;
char tb[4];
@@ -837,6 +837,30 @@ static int drbd_socket_okay(struct socket **sock)
return false;
}
}
+
+static bool connection_established(struct drbd_connection *connection,
+ struct socket **sock1,
+ struct socket **sock2)
+{
+ struct net_conf *nc;
+ int timeout;
+ bool ok;
+
+ if (!*sock1 || !*sock2)
+ return false;
+
+ rcu_read_lock();
+ nc = rcu_dereference(connection->net_conf);
+ timeout = (nc->sock_check_timeo ?: nc->ping_timeo) * HZ / 10;
+ rcu_read_unlock();
+ schedule_timeout_interruptible(timeout);
+
+ ok = drbd_socket_okay(sock1);
+ ok = drbd_socket_okay(sock2) && ok;
+
+ return ok;
+}
+
/* Gets called if a connection is established, or if a new minor gets created
in a connection */
int drbd_connected(struct drbd_peer_device *peer_device)
@@ -878,8 +902,8 @@ static int conn_connect(struct drbd_connection *connection)
struct drbd_socket sock, msock;
struct drbd_peer_device *peer_device;
struct net_conf *nc;
- int vnr, timeout, h, ok;
- bool discard_my_data;
+ int vnr, timeout, h;
+ bool discard_my_data, ok;
enum drbd_state_rv rv;
struct accept_wait_data ad = {
.connection = connection,
@@ -923,17 +947,8 @@ static int conn_connect(struct drbd_connection *connection)
}
}
- if (sock.socket && msock.socket) {
- rcu_read_lock();
- nc = rcu_dereference(connection->net_conf);
- timeout = nc->ping_timeo * HZ / 10;
- rcu_read_unlock();
- schedule_timeout_interruptible(timeout);
- ok = drbd_socket_okay(&sock.socket);
- ok = drbd_socket_okay(&msock.socket) && ok;
- if (ok)
- break;
- }
+ if (connection_established(connection, &sock.socket, &msock.socket))
+ break;
retry:
s = drbd_wait_for_connect(connection, &ad);
@@ -979,8 +994,7 @@ randomize:
goto out_release_sockets;
}
- ok = drbd_socket_okay(&sock.socket);
- ok = drbd_socket_okay(&msock.socket) && ok;
+ ok = connection_established(connection, &sock.socket, &msock.socket);
} while (!ok);
if (ad.s_listen)
diff --git a/include/linux/drbd_genl.h b/include/linux/drbd_genl.h
index 71fc924..7b131ed 100644
--- a/include/linux/drbd_genl.h
+++ b/include/linux/drbd_genl.h
@@ -174,6 +174,7 @@ GENL_struct(DRBD_NLA_NET_CONF, 5, net_conf,
/* 9: __str_field_def(31, DRBD_GENLA_F_MANDATORY, name, SHARED_SECRET_MAX) */
/* 9: __u32_field(32, DRBD_F_REQUIRED | DRBD_F_INVARIANT, peer_node_id) */
__flg_field_def(33, 0 /* OPTIONAL */, csums_after_crash_only, DRBD_CSUMS_AFTER_CRASH_ONLY_DEF)
+ __u32_field_def(34, 0 /* OPTIONAL */, sock_check_timeo, DRBD_SOCKET_CHECK_TIMEO_DEF)
)
GENL_struct(DRBD_NLA_SET_ROLE_PARMS, 6, set_role_parms,
diff --git a/include/linux/drbd_limits.h b/include/linux/drbd_limits.h
index 9d2df1d..8ac8c5d 100644
--- a/include/linux/drbd_limits.h
+++ b/include/linux/drbd_limits.h
@@ -225,4 +225,9 @@
#define DRBD_AL_STRIPE_SIZE_MAX 16777216
#define DRBD_AL_STRIPE_SIZE_DEF 32
#define DRBD_AL_STRIPE_SIZE_SCALE 'k' /* kilobytes */
+
+#define DRBD_SOCKET_CHECK_TIMEO_MIN 0
+#define DRBD_SOCKET_CHECK_TIMEO_MAX DRBD_PING_TIMEO_MAX
+#define DRBD_SOCKET_CHECK_TIMEO_DEF 0
+#define DRBD_SOCKET_CHECK_TIMEO_SCALE '1'
#endif
--
1.9.1
next prev parent reply other threads:[~2014-07-01 16:21 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-01 16:16 [PATCH 00/20] RFC DRBD fixes Philipp Reisner
2014-07-01 16:16 ` [PATCH 01/20] drbd: drop wrong debugging aid Philipp Reisner
2014-07-01 16:16 ` [PATCH 02/20] drbd: silence -Wmissing-prototypes warnings Philipp Reisner
2014-07-01 16:16 ` [PATCH 03/20] drbd: Remove unnecessary/unused code Philipp Reisner
2014-07-01 16:16 ` [PATCH 04/20] drbd: fix bogus resync stats in /proc/drbd Philipp Reisner
2014-07-01 16:16 ` [PATCH 05/20] drbd: don't implicitly resize Diskless node beyond end of device Philipp Reisner
2014-07-01 16:16 ` [PATCH 06/20] drbd: implement csums-after-crash-only Philipp Reisner
2014-07-01 16:16 ` [PATCH 07/20] drbd: Limit the time we are waiting for the first packet on an accepted socket Philipp Reisner
2014-07-01 16:16 ` Philipp Reisner [this message]
2014-07-01 16:16 ` [PATCH 09/20] drbd: application writes may set-in-sync in protocol != C Philipp Reisner
2014-07-01 16:16 ` [PATCH 10/20] drbd: short-circuit in maybe_pull_ahead Philipp Reisner
2014-07-01 16:16 ` [PATCH 11/20] drivers/block: Use RCU_INIT_POINTER(x, NULL) in drbd/drbd_state.c Philipp Reisner
2014-07-01 16:16 ` [PATCH 12/20] block: Convert last uses of __FUNCTION__ to __func__ Philipp Reisner
2014-07-01 16:16 ` [PATCH 13/20] drbd: improve resync request throttling due to sendbuf size Philipp Reisner
2014-07-01 16:16 ` [PATCH 14/20] drbd: clear CRASHED_PRIMARY only after successful resync Philipp Reisner
2014-07-01 16:16 ` [PATCH 15/20] drbd: cosmetic: change all printk(level, ...) to pr_<level>(...) Philipp Reisner
2014-07-01 16:30 ` Joe Perches
2014-07-02 9:58 ` [Drbd-dev] " Philipp Reisner
2014-07-01 16:16 ` [PATCH 16/20] drbd: drbd_rs_number_requests: fix unit mismatch in comparison Philipp Reisner
2014-07-01 16:16 ` [PATCH 17/20] drbd: add drbd_queue_work_if_unqueued helper Philipp Reisner
2014-07-01 16:16 ` [PATCH 18/20] drbd: drop drbd_md_flush Philipp Reisner
2014-07-01 16:16 ` [PATCH 19/20] drbd: consistently use list_add_tail for peer_request tracking Philipp Reisner
2014-07-01 16:16 ` [PATCH 20/20] drbd: also keep track of trim -> zero-out fallback peer_requests Philipp Reisner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1404231410-29852-9-git-send-email-philipp.reisner@linbit.com \
--to=philipp.reisner@linbit.com \
--cc=axboe@kernel.dk \
--cc=drbd-dev@lists.linbit.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®