diff options
| -rw-r--r-- | include/linux/ceph/libceph.h | 3 | ||||
| -rw-r--r-- | include/linux/ceph/messenger.h | 4 | ||||
| -rw-r--r-- | net/ceph/ceph_common.c | 16 | ||||
| -rw-r--r-- | net/ceph/messenger.c | 14 |
4 files changed, 33 insertions, 4 deletions
diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h index 8b11a79ca1cb..16fff9608848 100644 --- a/include/linux/ceph/libceph.h +++ b/include/linux/ceph/libceph.h | |||
| @@ -30,8 +30,9 @@ | |||
| 30 | #define CEPH_OPT_MYIP (1<<2) /* specified my ip */ | 30 | #define CEPH_OPT_MYIP (1<<2) /* specified my ip */ |
| 31 | #define CEPH_OPT_NOCRC (1<<3) /* no data crc on writes */ | 31 | #define CEPH_OPT_NOCRC (1<<3) /* no data crc on writes */ |
| 32 | #define CEPH_OPT_NOMSGAUTH (1<<4) /* not require cephx message signature */ | 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 | #define ceph_set_opt(client, opt) \ | 37 | #define ceph_set_opt(client, opt) \ |
| 37 | (client)->options->flags |= CEPH_OPT_##opt; | 38 | (client)->options->flags |= CEPH_OPT_##opt; |
diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h index d9d396c16503..e15499422fdc 100644 --- a/include/linux/ceph/messenger.h +++ b/include/linux/ceph/messenger.h | |||
| @@ -57,6 +57,7 @@ struct ceph_messenger { | |||
| 57 | 57 | ||
| 58 | atomic_t stopping; | 58 | atomic_t stopping; |
| 59 | bool nocrc; | 59 | bool nocrc; |
| 60 | bool tcp_nodelay; | ||
| 60 | 61 | ||
| 61 | /* | 62 | /* |
| 62 | * the global_seq counts connections i (attempt to) initiate | 63 | * the global_seq counts connections i (attempt to) initiate |
| @@ -264,7 +265,8 @@ extern void ceph_messenger_init(struct ceph_messenger *msgr, | |||
| 264 | struct ceph_entity_addr *myaddr, | 265 | struct ceph_entity_addr *myaddr, |
| 265 | u64 supported_features, | 266 | u64 supported_features, |
| 266 | u64 required_features, | 267 | u64 required_features, |
| 267 | bool nocrc); | 268 | bool nocrc, |
| 269 | bool tcp_nodelay); | ||
| 268 | 270 | ||
| 269 | extern void ceph_con_init(struct ceph_connection *con, void *private, | 271 | extern void ceph_con_init(struct ceph_connection *con, void *private, |
| 270 | const struct ceph_connection_operations *ops, | 272 | const struct ceph_connection_operations *ops, |
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 | ||
| 244 | static match_table_t opt_tokens = { | 246 | static 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 | ||
