aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorChaitanya Huilgol <chaitanya.huilgol@gmail.com>2015-01-23 06:11:25 -0500
committerIlya Dryomov <idryomov@gmail.com>2015-02-19 05:31:40 -0500
commitba988f87f532cd2b8c4740aa8ec49056521ae833 (patch)
tree14d535124a9146d02fa0a7e2f76d8778b0bce662 /net
parentcf32bd9c86b6917d8446c00ea0081dde6e716a82 (diff)
libceph: tcp_nodelay support
TCP_NODELAY socket option set on connection sockets, disables Nagle’s algorithm and improves latency characteristics. tcp_nodelay(default)/notcp_nodelay option flags provided to enable/disable setting the socket option. Signed-off-by: Chaitanya Huilgol <chaitanya.huilgol@sandisk.com> [idryomov@redhat.com: NO_TCP_NODELAY -> TCP_NODELAY, minor adjustments] Signed-off-by: Ilya Dryomov <idryomov@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/ceph_common.c16
-rw-r--r--net/ceph/messenger.c14
2 files changed, 28 insertions, 2 deletions
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
index 5d5ab67f516d..ec565508e904 100644
--- a/net/ceph/ceph_common.c
+++ b/net/ceph/ceph_common.c
@@ -239,6 +239,8 @@ enum {
239 Opt_nocrc, 239 Opt_nocrc,
240 Opt_cephx_require_signatures, 240 Opt_cephx_require_signatures,
241 Opt_nocephx_require_signatures, 241 Opt_nocephx_require_signatures,
242 Opt_tcp_nodelay,
243 Opt_notcp_nodelay,
242}; 244};
243 245
244static match_table_t opt_tokens = { 246static match_table_t opt_tokens = {
@@ -259,6 +261,8 @@ static match_table_t opt_tokens = {
259 {Opt_nocrc, "nocrc"}, 261 {Opt_nocrc, "nocrc"},
260 {Opt_cephx_require_signatures, "cephx_require_signatures"}, 262 {Opt_cephx_require_signatures, "cephx_require_signatures"},
261 {Opt_nocephx_require_signatures, "nocephx_require_signatures"}, 263 {Opt_nocephx_require_signatures, "nocephx_require_signatures"},
264 {Opt_tcp_nodelay, "tcp_nodelay"},
265 {Opt_notcp_nodelay, "notcp_nodelay"},
262 {-1, NULL} 266 {-1, NULL}
263}; 267};
264 268
@@ -457,6 +461,7 @@ ceph_parse_options(char *options, const char *dev_name,
457 case Opt_nocrc: 461 case Opt_nocrc:
458 opt->flags |= CEPH_OPT_NOCRC; 462 opt->flags |= CEPH_OPT_NOCRC;
459 break; 463 break;
464
460 case Opt_cephx_require_signatures: 465 case Opt_cephx_require_signatures:
461 opt->flags &= ~CEPH_OPT_NOMSGAUTH; 466 opt->flags &= ~CEPH_OPT_NOMSGAUTH;
462 break; 467 break;
@@ -464,6 +469,13 @@ ceph_parse_options(char *options, const char *dev_name,
464 opt->flags |= CEPH_OPT_NOMSGAUTH; 469 opt->flags |= CEPH_OPT_NOMSGAUTH;
465 break; 470 break;
466 471
472 case Opt_tcp_nodelay:
473 opt->flags |= CEPH_OPT_TCP_NODELAY;
474 break;
475 case Opt_notcp_nodelay:
476 opt->flags &= ~CEPH_OPT_TCP_NODELAY;
477 break;
478
467 default: 479 default:
468 BUG_ON(token); 480 BUG_ON(token);
469 } 481 }
@@ -518,10 +530,12 @@ struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private,
518 /* msgr */ 530 /* msgr */
519 if (ceph_test_opt(client, MYIP)) 531 if (ceph_test_opt(client, MYIP))
520 myaddr = &client->options->my_addr; 532 myaddr = &client->options->my_addr;
533
521 ceph_messenger_init(&client->msgr, myaddr, 534 ceph_messenger_init(&client->msgr, myaddr,
522 client->supported_features, 535 client->supported_features,
523 client->required_features, 536 client->required_features,
524 ceph_test_opt(client, NOCRC)); 537 ceph_test_opt(client, NOCRC),
538 ceph_test_opt(client, TCP_NODELAY));
525 539
526 /* subsystems */ 540 /* subsystems */
527 err = ceph_monc_init(&client->monc, client); 541 err = ceph_monc_init(&client->monc, client);
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 33a2f201e460..6b3f54ed65ba 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -510,6 +510,16 @@ static int ceph_tcp_connect(struct ceph_connection *con)
510 return ret; 510 return ret;
511 } 511 }
512 512
513 if (con->msgr->tcp_nodelay) {
514 int optval = 1;
515
516 ret = kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY,
517 (char *)&optval, sizeof(optval));
518 if (ret)
519 pr_err("kernel_setsockopt(TCP_NODELAY) failed: %d",
520 ret);
521 }
522
513 sk_set_memalloc(sock->sk); 523 sk_set_memalloc(sock->sk);
514 524
515 con->sock = sock; 525 con->sock = sock;
@@ -2922,7 +2932,8 @@ void ceph_messenger_init(struct ceph_messenger *msgr,
2922 struct ceph_entity_addr *myaddr, 2932 struct ceph_entity_addr *myaddr,
2923 u64 supported_features, 2933 u64 supported_features,
2924 u64 required_features, 2934 u64 required_features,
2925 bool nocrc) 2935 bool nocrc,
2936 bool tcp_nodelay)
2926{ 2937{
2927 msgr->supported_features = supported_features; 2938 msgr->supported_features = supported_features;
2928 msgr->required_features = required_features; 2939 msgr->required_features = required_features;
@@ -2937,6 +2948,7 @@ void ceph_messenger_init(struct ceph_messenger *msgr,
2937 get_random_bytes(&msgr->inst.addr.nonce, sizeof(msgr->inst.addr.nonce)); 2948 get_random_bytes(&msgr->inst.addr.nonce, sizeof(msgr->inst.addr.nonce));
2938 encode_my_addr(msgr); 2949 encode_my_addr(msgr);
2939 msgr->nocrc = nocrc; 2950 msgr->nocrc = nocrc;
2951 msgr->tcp_nodelay = tcp_nodelay;
2940 2952
2941 atomic_set(&msgr->stopping, 0); 2953 atomic_set(&msgr->stopping, 0);
2942 2954