all: differentiate traffic types

This commit is contained in:
Thomas Schoebel-Theuer 2018-05-10 11:16:34 +02:00 committed by Thomas Schoebel-Theuer
parent 1bb56365c3
commit d5dc1ea8af
7 changed files with 79 additions and 29 deletions

View File

@ -145,9 +145,19 @@ int _setup_channel(struct client_bundle *bundle, int ch_nr)
goto done;
}
if (!bundle->params) {
struct sockaddr_in *_sockaddr = (void*)&sockaddr;
int offset = (int)ntohs(_sockaddr->sin_port) - mars_net_default_port;
if (offset < 0 || offset >= MARS_TRAFFIC_MAX)
offset = 0;
bundle->params = &mars_tcp_params[offset];
}
status = mars_create_socket(&ch->socket,
&sockaddr,
&default_tcp_params,
bundle->params,
false);
if (unlikely(status < 0)) {
MARS_DBG("no socket, status = %d\n", status);

View File

@ -81,6 +81,7 @@ struct client_channel {
struct client_bundle {
char *host;
char *path;
struct mars_tcp_params *params;
int thread_count;
int old_channel;
wait_queue_head_t sender_event;

View File

@ -74,16 +74,35 @@ module_param_named(mars_port, mars_net_default_port, int, 0);
* TODO: add compression / encryption.
*/
struct mars_tcp_params default_tcp_params = {
.ip_tos = IPTOS_LOWDELAY,
.tcp_window_size = 8 * 1024 * 1024, // for long distance replications
.tcp_nodelay = 0,
.tcp_timeout = 2,
.tcp_keepcnt = 3,
.tcp_keepintvl = 3, // keepalive ping time
.tcp_keepidle = 4,
struct mars_tcp_params mars_tcp_params[MARS_TRAFFIC_MAX] = {
[MARS_TRAFFIC_META] = {
.ip_tos = IPTOS_LOWDELAY,
.tcp_window_size = 8 * 1024 * 1024,
.tcp_nodelay = 0,
.tcp_timeout = 2,
.tcp_keepcnt = 3,
.tcp_keepintvl = 3,
.tcp_keepidle = 4,
},
[MARS_TRAFFIC_REPLICATION] = {
.ip_tos = IPTOS_RELIABILITY,
.tcp_window_size = 8 * 1024 * 1024,
.tcp_nodelay = 0,
.tcp_timeout = 2,
.tcp_keepcnt = 3,
.tcp_keepintvl = 3,
.tcp_keepidle = 4,
},
[MARS_TRAFFIC_SYNC] = {
.ip_tos = IPTOS_MINCOST,
.tcp_window_size = 8 * 1024 * 1024,
.tcp_nodelay = 0,
.tcp_timeout = 2,
.tcp_keepcnt = 3,
.tcp_keepintvl = 3,
.tcp_keepidle = 4,
},
};
EXPORT_SYMBOL(default_tcp_params);
static
void __setsockopt(struct socket *sock, int level, int optname, char *optval, int optsize)

View File

@ -86,8 +86,6 @@ struct mars_tcp_params {
int tcp_keepidle;
};
extern struct mars_tcp_params default_tcp_params;
enum mars_traffic_types {
MARS_TRAFFIC_META,
MARS_TRAFFIC_REPLICATION,
@ -95,6 +93,8 @@ enum mars_traffic_types {
MARS_TRAFFIC_MAX /* this must come last */
};
extern struct mars_tcp_params mars_tcp_params[MARS_TRAFFIC_MAX];
enum {
CMD_NOP,
CMD_NOTIFY,

View File

@ -49,13 +49,13 @@ struct server_cookie {
static struct server_cookie server_cookie[MARS_TRAFFIC_MAX] = {
[MARS_TRAFFIC_META] = {
.server_params = &default_tcp_params,
.server_params = &mars_tcp_params[MARS_TRAFFIC_META],
},
[MARS_TRAFFIC_REPLICATION] = {
.server_params = &default_tcp_params,
.server_params = &mars_tcp_params[MARS_TRAFFIC_REPLICATION],
},
[MARS_TRAFFIC_SYNC] = {
.server_params = &default_tcp_params,
.server_params = &mars_tcp_params[MARS_TRAFFIC_SYNC],
},
};

View File

@ -2276,7 +2276,7 @@ int peer_thread(void *data)
status = mars_create_socket(&peer->socket,
&sockaddr,
&default_tcp_params,
&mars_tcp_params[MARS_TRAFFIC_META],
false);
if (unlikely(status < 0)) {
MARS_INF("no connection to mars module on '%s' (%s) status = %d\n", peer->peer, real_peer, status);

View File

@ -285,17 +285,25 @@ struct ctl_table io_tuning_table[] = {
{}
};
static
struct ctl_table tcp_tuning_table[] = {
INT_ENTRY("ip_tos", default_tcp_params.ip_tos, 0600),
INT_ENTRY("tcp_window_size", default_tcp_params.tcp_window_size, 0600),
INT_ENTRY("tcp_nodelay", default_tcp_params.tcp_nodelay, 0600),
INT_ENTRY("tcp_timeout", default_tcp_params.tcp_timeout, 0600),
INT_ENTRY("tcp_keepcnt", default_tcp_params.tcp_keepcnt, 0600),
INT_ENTRY("tcp_keepintvl", default_tcp_params.tcp_keepintvl, 0600),
INT_ENTRY("tcp_keepidle", default_tcp_params.tcp_keepidle, 0600),
{}
};
#define TCP_ENTRY(NAME,TRAFFIC_TYPE) \
INT_ENTRY(#NAME, mars_tcp_params[TRAFFIC_TYPE].NAME, 0600)
#define make_tcp_tuning_table(TRAFFIC_TYPE) \
static \
struct ctl_table tcp_tuning_table_##TRAFFIC_TYPE[] = { \
TCP_ENTRY(ip_tos, TRAFFIC_TYPE), \
TCP_ENTRY(tcp_window_size, TRAFFIC_TYPE), \
TCP_ENTRY(tcp_nodelay, TRAFFIC_TYPE), \
TCP_ENTRY(tcp_timeout, TRAFFIC_TYPE), \
TCP_ENTRY(tcp_keepcnt, TRAFFIC_TYPE), \
TCP_ENTRY(tcp_keepintvl, TRAFFIC_TYPE), \
TCP_ENTRY(tcp_keepidle, TRAFFIC_TYPE), \
{} \
}
make_tcp_tuning_table(MARS_TRAFFIC_META);
make_tcp_tuning_table(MARS_TRAFFIC_REPLICATION);
make_tcp_tuning_table(MARS_TRAFFIC_SYNC);
static
struct ctl_table mars_table[] = {
@ -416,9 +424,21 @@ struct ctl_table mars_table[] = {
},
{
_CTL_NAME
.procname = "tcp_tuning",
.procname = "tcp_tuning_0_meta_traffic",
.mode = 0500,
.child = tcp_tuning_table,
.child = tcp_tuning_table_MARS_TRAFFIC_META,
},
{
_CTL_NAME
.procname = "tcp_tuning_1_replication_traffic",
.mode = 0500,
.child = tcp_tuning_table_MARS_TRAFFIC_REPLICATION,
},
{
_CTL_NAME
.procname = "tcp_tuning_2_sync_traffic",
.mode = 0500,
.child = tcp_tuning_table_MARS_TRAFFIC_SYNC,
},
{}
};