Commit 859bff51 authored by Ilya Dryomov's avatar Ilya Dryomov

libceph: stop duplicating client fields in messenger

supported_features and required_features serve no purpose at all, while
nocrc and tcp_nodelay belong to ceph_options::flags.
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 4199b8ee
...@@ -137,6 +137,7 @@ struct ceph_client { ...@@ -137,6 +137,7 @@ struct ceph_client {
#endif #endif
}; };
#define from_msgr(ms) container_of(ms, struct ceph_client, msgr)
/* /*
......
...@@ -57,8 +57,6 @@ struct ceph_messenger { ...@@ -57,8 +57,6 @@ struct ceph_messenger {
atomic_t stopping; atomic_t stopping;
possible_net_t net; possible_net_t net;
bool nocrc;
bool tcp_nodelay;
/* /*
* the global_seq counts connections i (attempt to) initiate * the global_seq counts connections i (attempt to) initiate
...@@ -66,9 +64,6 @@ struct ceph_messenger { ...@@ -66,9 +64,6 @@ struct ceph_messenger {
*/ */
u32 global_seq; u32 global_seq;
spinlock_t global_seq_lock; spinlock_t global_seq_lock;
u64 supported_features;
u64 required_features;
}; };
enum ceph_msg_data_type { enum ceph_msg_data_type {
...@@ -267,11 +262,7 @@ extern void ceph_msgr_exit(void); ...@@ -267,11 +262,7 @@ extern void ceph_msgr_exit(void);
extern void ceph_msgr_flush(void); extern void ceph_msgr_flush(void);
extern void ceph_messenger_init(struct ceph_messenger *msgr, extern void ceph_messenger_init(struct ceph_messenger *msgr,
struct ceph_entity_addr *myaddr, struct ceph_entity_addr *myaddr);
u64 supported_features,
u64 required_features,
bool nocrc,
bool tcp_nodelay);
extern void ceph_messenger_fini(struct ceph_messenger *msgr); extern void ceph_messenger_fini(struct ceph_messenger *msgr);
extern void ceph_con_init(struct ceph_connection *con, void *private, extern void ceph_con_init(struct ceph_connection *con, void *private,
......
...@@ -596,11 +596,7 @@ struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private, ...@@ -596,11 +596,7 @@ struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private,
if (ceph_test_opt(client, MYIP)) if (ceph_test_opt(client, MYIP))
myaddr = &client->options->my_addr; myaddr = &client->options->my_addr;
ceph_messenger_init(&client->msgr, myaddr, ceph_messenger_init(&client->msgr, myaddr);
client->supported_features,
client->required_features,
ceph_test_opt(client, NOCRC),
ceph_test_opt(client, TCP_NODELAY));
/* subsystems */ /* subsystems */
err = ceph_monc_init(&client->monc, client); err = ceph_monc_init(&client->monc, client);
......
...@@ -509,7 +509,7 @@ static int ceph_tcp_connect(struct ceph_connection *con) ...@@ -509,7 +509,7 @@ static int ceph_tcp_connect(struct ceph_connection *con)
return ret; return ret;
} }
if (con->msgr->tcp_nodelay) { if (ceph_test_opt(from_msgr(con->msgr), TCP_NODELAY)) {
int optval = 1; int optval = 1;
ret = kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY, ret = kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY,
...@@ -1432,7 +1432,8 @@ static int prepare_write_connect(struct ceph_connection *con) ...@@ -1432,7 +1432,8 @@ static int prepare_write_connect(struct ceph_connection *con)
dout("prepare_write_connect %p cseq=%d gseq=%d proto=%d\n", con, dout("prepare_write_connect %p cseq=%d gseq=%d proto=%d\n", con,
con->connect_seq, global_seq, proto); con->connect_seq, global_seq, proto);
con->out_connect.features = cpu_to_le64(con->msgr->supported_features); con->out_connect.features =
cpu_to_le64(from_msgr(con->msgr)->supported_features);
con->out_connect.host_type = cpu_to_le32(CEPH_ENTITY_TYPE_CLIENT); con->out_connect.host_type = cpu_to_le32(CEPH_ENTITY_TYPE_CLIENT);
con->out_connect.connect_seq = cpu_to_le32(con->connect_seq); con->out_connect.connect_seq = cpu_to_le32(con->connect_seq);
con->out_connect.global_seq = cpu_to_le32(global_seq); con->out_connect.global_seq = cpu_to_le32(global_seq);
...@@ -1527,7 +1528,7 @@ static int write_partial_message_data(struct ceph_connection *con) ...@@ -1527,7 +1528,7 @@ static int write_partial_message_data(struct ceph_connection *con)
{ {
struct ceph_msg *msg = con->out_msg; struct ceph_msg *msg = con->out_msg;
struct ceph_msg_data_cursor *cursor = &msg->cursor; struct ceph_msg_data_cursor *cursor = &msg->cursor;
bool do_datacrc = !con->msgr->nocrc; bool do_datacrc = !ceph_test_opt(from_msgr(con->msgr), NOCRC);
u32 crc; u32 crc;
dout("%s %p msg %p\n", __func__, con, msg); dout("%s %p msg %p\n", __func__, con, msg);
...@@ -2005,8 +2006,8 @@ static int process_banner(struct ceph_connection *con) ...@@ -2005,8 +2006,8 @@ static int process_banner(struct ceph_connection *con)
static int process_connect(struct ceph_connection *con) static int process_connect(struct ceph_connection *con)
{ {
u64 sup_feat = con->msgr->supported_features; u64 sup_feat = from_msgr(con->msgr)->supported_features;
u64 req_feat = con->msgr->required_features; u64 req_feat = from_msgr(con->msgr)->required_features;
u64 server_feat = ceph_sanitize_features( u64 server_feat = ceph_sanitize_features(
le64_to_cpu(con->in_reply.features)); le64_to_cpu(con->in_reply.features));
int ret; int ret;
...@@ -2232,7 +2233,7 @@ static int read_partial_msg_data(struct ceph_connection *con) ...@@ -2232,7 +2233,7 @@ static int read_partial_msg_data(struct ceph_connection *con)
{ {
struct ceph_msg *msg = con->in_msg; struct ceph_msg *msg = con->in_msg;
struct ceph_msg_data_cursor *cursor = &msg->cursor; struct ceph_msg_data_cursor *cursor = &msg->cursor;
const bool do_datacrc = !con->msgr->nocrc; bool do_datacrc = !ceph_test_opt(from_msgr(con->msgr), NOCRC);
struct page *page; struct page *page;
size_t page_offset; size_t page_offset;
size_t length; size_t length;
...@@ -2277,7 +2278,7 @@ static int read_partial_message(struct ceph_connection *con) ...@@ -2277,7 +2278,7 @@ static int read_partial_message(struct ceph_connection *con)
int end; int end;
int ret; int ret;
unsigned int front_len, middle_len, data_len; unsigned int front_len, middle_len, data_len;
bool do_datacrc = !con->msgr->nocrc; bool do_datacrc = !ceph_test_opt(from_msgr(con->msgr), NOCRC);
bool need_sign = (con->peer_features & CEPH_FEATURE_MSG_AUTH); bool need_sign = (con->peer_features & CEPH_FEATURE_MSG_AUTH);
u64 seq; u64 seq;
u32 crc; u32 crc;
...@@ -2951,15 +2952,8 @@ static void con_fault(struct ceph_connection *con) ...@@ -2951,15 +2952,8 @@ static void con_fault(struct ceph_connection *con)
* initialize a new messenger instance * initialize a new messenger instance
*/ */
void ceph_messenger_init(struct ceph_messenger *msgr, void ceph_messenger_init(struct ceph_messenger *msgr,
struct ceph_entity_addr *myaddr, struct ceph_entity_addr *myaddr)
u64 supported_features,
u64 required_features,
bool nocrc,
bool tcp_nodelay)
{ {
msgr->supported_features = supported_features;
msgr->required_features = required_features;
spin_lock_init(&msgr->global_seq_lock); spin_lock_init(&msgr->global_seq_lock);
if (myaddr) if (myaddr)
...@@ -2969,8 +2963,6 @@ void ceph_messenger_init(struct ceph_messenger *msgr, ...@@ -2969,8 +2963,6 @@ void ceph_messenger_init(struct ceph_messenger *msgr,
msgr->inst.addr.type = 0; msgr->inst.addr.type = 0;
get_random_bytes(&msgr->inst.addr.nonce, sizeof(msgr->inst.addr.nonce)); get_random_bytes(&msgr->inst.addr.nonce, sizeof(msgr->inst.addr.nonce));
encode_my_addr(msgr); encode_my_addr(msgr);
msgr->nocrc = nocrc;
msgr->tcp_nodelay = tcp_nodelay;
atomic_set(&msgr->stopping, 0); atomic_set(&msgr->stopping, 0);
write_pnet(&msgr->net, get_net(current->nsproxy->net_ns)); write_pnet(&msgr->net, get_net(current->nsproxy->net_ns));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment