Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Chaitanya Huilgol and committed by
Ilya Dryomov
ba988f87 cf32bd9c

+33 -4
+2 -1
include/linux/ceph/libceph.h
··· 30 30 #define CEPH_OPT_MYIP (1<<2) /* specified my ip */ 31 31 #define CEPH_OPT_NOCRC (1<<3) /* no data crc on writes */ 32 32 #define CEPH_OPT_NOMSGAUTH (1<<4) /* not require cephx message signature */ 33 + #define CEPH_OPT_TCP_NODELAY (1<<5) /* TCP_NODELAY on TCP sockets */ 33 34 34 - #define CEPH_OPT_DEFAULT (0) 35 + #define CEPH_OPT_DEFAULT (CEPH_OPT_TCP_NODELAY) 35 36 36 37 #define ceph_set_opt(client, opt) \ 37 38 (client)->options->flags |= CEPH_OPT_##opt;
+3 -1
include/linux/ceph/messenger.h
··· 57 57 58 58 atomic_t stopping; 59 59 bool nocrc; 60 + bool tcp_nodelay; 60 61 61 62 /* 62 63 * the global_seq counts connections i (attempt to) initiate ··· 265 264 struct ceph_entity_addr *myaddr, 266 265 u64 supported_features, 267 266 u64 required_features, 268 - bool nocrc); 267 + bool nocrc, 268 + bool tcp_nodelay); 269 269 270 270 extern void ceph_con_init(struct ceph_connection *con, void *private, 271 271 const struct ceph_connection_operations *ops,
+15 -1
net/ceph/ceph_common.c
··· 239 239 Opt_nocrc, 240 240 Opt_cephx_require_signatures, 241 241 Opt_nocephx_require_signatures, 242 + Opt_tcp_nodelay, 243 + Opt_notcp_nodelay, 242 244 }; 243 245 244 246 static match_table_t opt_tokens = { ··· 261 259 {Opt_nocrc, "nocrc"}, 262 260 {Opt_cephx_require_signatures, "cephx_require_signatures"}, 263 261 {Opt_nocephx_require_signatures, "nocephx_require_signatures"}, 262 + {Opt_tcp_nodelay, "tcp_nodelay"}, 263 + {Opt_notcp_nodelay, "notcp_nodelay"}, 264 264 {-1, NULL} 265 265 }; 266 266 ··· 461 457 case Opt_nocrc: 462 458 opt->flags |= CEPH_OPT_NOCRC; 463 459 break; 460 + 464 461 case Opt_cephx_require_signatures: 465 462 opt->flags &= ~CEPH_OPT_NOMSGAUTH; 466 463 break; 467 464 case Opt_nocephx_require_signatures: 468 465 opt->flags |= CEPH_OPT_NOMSGAUTH; 466 + break; 467 + 468 + case Opt_tcp_nodelay: 469 + opt->flags |= CEPH_OPT_TCP_NODELAY; 470 + break; 471 + case Opt_notcp_nodelay: 472 + opt->flags &= ~CEPH_OPT_TCP_NODELAY; 469 473 break; 470 474 471 475 default: ··· 530 518 /* msgr */ 531 519 if (ceph_test_opt(client, MYIP)) 532 520 myaddr = &client->options->my_addr; 521 + 533 522 ceph_messenger_init(&client->msgr, myaddr, 534 523 client->supported_features, 535 524 client->required_features, 536 - ceph_test_opt(client, NOCRC)); 525 + ceph_test_opt(client, NOCRC), 526 + ceph_test_opt(client, TCP_NODELAY)); 537 527 538 528 /* subsystems */ 539 529 err = ceph_monc_init(&client->monc, client);
+13 -1
net/ceph/messenger.c
··· 510 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 523 sk_set_memalloc(sock->sk); 514 524 515 525 con->sock = sock; ··· 2932 2922 struct ceph_entity_addr *myaddr, 2933 2923 u64 supported_features, 2934 2924 u64 required_features, 2935 - bool nocrc) 2925 + bool nocrc, 2926 + bool tcp_nodelay) 2936 2927 { 2937 2928 msgr->supported_features = supported_features; 2938 2929 msgr->required_features = required_features; ··· 2948 2937 get_random_bytes(&msgr->inst.addr.nonce, sizeof(msgr->inst.addr.nonce)); 2949 2938 encode_my_addr(msgr); 2950 2939 msgr->nocrc = nocrc; 2940 + msgr->tcp_nodelay = tcp_nodelay; 2951 2941 2952 2942 atomic_set(&msgr->stopping, 0); 2953 2943