mirror of https://github.com/schoebel/mars
all: differentiate traffic types
This commit is contained in:
parent
1bb56365c3
commit
d5dc1ea8af
|
@ -145,9 +145,19 @@ int _setup_channel(struct client_bundle *bundle, int ch_nr)
|
||||||
goto done;
|
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,
|
status = mars_create_socket(&ch->socket,
|
||||||
&sockaddr,
|
&sockaddr,
|
||||||
&default_tcp_params,
|
bundle->params,
|
||||||
false);
|
false);
|
||||||
if (unlikely(status < 0)) {
|
if (unlikely(status < 0)) {
|
||||||
MARS_DBG("no socket, status = %d\n", status);
|
MARS_DBG("no socket, status = %d\n", status);
|
||||||
|
|
|
@ -81,6 +81,7 @@ struct client_channel {
|
||||||
struct client_bundle {
|
struct client_bundle {
|
||||||
char *host;
|
char *host;
|
||||||
char *path;
|
char *path;
|
||||||
|
struct mars_tcp_params *params;
|
||||||
int thread_count;
|
int thread_count;
|
||||||
int old_channel;
|
int old_channel;
|
||||||
wait_queue_head_t sender_event;
|
wait_queue_head_t sender_event;
|
||||||
|
|
|
@ -74,16 +74,35 @@ module_param_named(mars_port, mars_net_default_port, int, 0);
|
||||||
* TODO: add compression / encryption.
|
* TODO: add compression / encryption.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct mars_tcp_params default_tcp_params = {
|
struct mars_tcp_params mars_tcp_params[MARS_TRAFFIC_MAX] = {
|
||||||
.ip_tos = IPTOS_LOWDELAY,
|
[MARS_TRAFFIC_META] = {
|
||||||
.tcp_window_size = 8 * 1024 * 1024, // for long distance replications
|
.ip_tos = IPTOS_LOWDELAY,
|
||||||
.tcp_nodelay = 0,
|
.tcp_window_size = 8 * 1024 * 1024,
|
||||||
.tcp_timeout = 2,
|
.tcp_nodelay = 0,
|
||||||
.tcp_keepcnt = 3,
|
.tcp_timeout = 2,
|
||||||
.tcp_keepintvl = 3, // keepalive ping time
|
.tcp_keepcnt = 3,
|
||||||
.tcp_keepidle = 4,
|
.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
|
static
|
||||||
void __setsockopt(struct socket *sock, int level, int optname, char *optval, int optsize)
|
void __setsockopt(struct socket *sock, int level, int optname, char *optval, int optsize)
|
||||||
|
|
|
@ -86,8 +86,6 @@ struct mars_tcp_params {
|
||||||
int tcp_keepidle;
|
int tcp_keepidle;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct mars_tcp_params default_tcp_params;
|
|
||||||
|
|
||||||
enum mars_traffic_types {
|
enum mars_traffic_types {
|
||||||
MARS_TRAFFIC_META,
|
MARS_TRAFFIC_META,
|
||||||
MARS_TRAFFIC_REPLICATION,
|
MARS_TRAFFIC_REPLICATION,
|
||||||
|
@ -95,6 +93,8 @@ enum mars_traffic_types {
|
||||||
MARS_TRAFFIC_MAX /* this must come last */
|
MARS_TRAFFIC_MAX /* this must come last */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern struct mars_tcp_params mars_tcp_params[MARS_TRAFFIC_MAX];
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CMD_NOP,
|
CMD_NOP,
|
||||||
CMD_NOTIFY,
|
CMD_NOTIFY,
|
||||||
|
|
|
@ -49,13 +49,13 @@ struct server_cookie {
|
||||||
|
|
||||||
static struct server_cookie server_cookie[MARS_TRAFFIC_MAX] = {
|
static struct server_cookie server_cookie[MARS_TRAFFIC_MAX] = {
|
||||||
[MARS_TRAFFIC_META] = {
|
[MARS_TRAFFIC_META] = {
|
||||||
.server_params = &default_tcp_params,
|
.server_params = &mars_tcp_params[MARS_TRAFFIC_META],
|
||||||
},
|
},
|
||||||
[MARS_TRAFFIC_REPLICATION] = {
|
[MARS_TRAFFIC_REPLICATION] = {
|
||||||
.server_params = &default_tcp_params,
|
.server_params = &mars_tcp_params[MARS_TRAFFIC_REPLICATION],
|
||||||
},
|
},
|
||||||
[MARS_TRAFFIC_SYNC] = {
|
[MARS_TRAFFIC_SYNC] = {
|
||||||
.server_params = &default_tcp_params,
|
.server_params = &mars_tcp_params[MARS_TRAFFIC_SYNC],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2276,7 +2276,7 @@ int peer_thread(void *data)
|
||||||
|
|
||||||
status = mars_create_socket(&peer->socket,
|
status = mars_create_socket(&peer->socket,
|
||||||
&sockaddr,
|
&sockaddr,
|
||||||
&default_tcp_params,
|
&mars_tcp_params[MARS_TRAFFIC_META],
|
||||||
false);
|
false);
|
||||||
if (unlikely(status < 0)) {
|
if (unlikely(status < 0)) {
|
||||||
MARS_INF("no connection to mars module on '%s' (%s) status = %d\n", peer->peer, real_peer, status);
|
MARS_INF("no connection to mars module on '%s' (%s) status = %d\n", peer->peer, real_peer, status);
|
||||||
|
|
|
@ -285,17 +285,25 @@ struct ctl_table io_tuning_table[] = {
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
static
|
#define TCP_ENTRY(NAME,TRAFFIC_TYPE) \
|
||||||
struct ctl_table tcp_tuning_table[] = {
|
INT_ENTRY(#NAME, mars_tcp_params[TRAFFIC_TYPE].NAME, 0600)
|
||||||
INT_ENTRY("ip_tos", default_tcp_params.ip_tos, 0600),
|
|
||||||
INT_ENTRY("tcp_window_size", default_tcp_params.tcp_window_size, 0600),
|
#define make_tcp_tuning_table(TRAFFIC_TYPE) \
|
||||||
INT_ENTRY("tcp_nodelay", default_tcp_params.tcp_nodelay, 0600),
|
static \
|
||||||
INT_ENTRY("tcp_timeout", default_tcp_params.tcp_timeout, 0600),
|
struct ctl_table tcp_tuning_table_##TRAFFIC_TYPE[] = { \
|
||||||
INT_ENTRY("tcp_keepcnt", default_tcp_params.tcp_keepcnt, 0600),
|
TCP_ENTRY(ip_tos, TRAFFIC_TYPE), \
|
||||||
INT_ENTRY("tcp_keepintvl", default_tcp_params.tcp_keepintvl, 0600),
|
TCP_ENTRY(tcp_window_size, TRAFFIC_TYPE), \
|
||||||
INT_ENTRY("tcp_keepidle", default_tcp_params.tcp_keepidle, 0600),
|
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
|
static
|
||||||
struct ctl_table mars_table[] = {
|
struct ctl_table mars_table[] = {
|
||||||
|
@ -416,9 +424,21 @@ struct ctl_table mars_table[] = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
_CTL_NAME
|
_CTL_NAME
|
||||||
.procname = "tcp_tuning",
|
.procname = "tcp_tuning_0_meta_traffic",
|
||||||
.mode = 0500,
|
.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,
|
||||||
},
|
},
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue