Skip to content

Commit 7399212

Browse files
MaxKellermannidryomov
authored andcommitted
libceph: pass the message pointer instead of loading con->out_msg
This pointer is in a register anyway, so let's use that instead of reloading from memory everywhere. [ idryomov: formatting ] Signed-off-by: Max Kellermann <[email protected]> Reviewed-by: Viacheslav Dubeyko <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 59699a5 commit 7399212

File tree

4 files changed

+114
-107
lines changed

4 files changed

+114
-107
lines changed

include/linux/ceph/messenger.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ struct ceph_msg *ceph_con_get_out_msg(struct ceph_connection *con);
555555
/* messenger_v1.c */
556556
int ceph_con_v1_try_read(struct ceph_connection *con);
557557
int ceph_con_v1_try_write(struct ceph_connection *con);
558-
void ceph_con_v1_revoke(struct ceph_connection *con);
558+
void ceph_con_v1_revoke(struct ceph_connection *con, struct ceph_msg *msg);
559559
void ceph_con_v1_revoke_incoming(struct ceph_connection *con);
560560
bool ceph_con_v1_opened(struct ceph_connection *con);
561561
void ceph_con_v1_reset_session(struct ceph_connection *con);
@@ -564,7 +564,7 @@ void ceph_con_v1_reset_protocol(struct ceph_connection *con);
564564
/* messenger_v2.c */
565565
int ceph_con_v2_try_read(struct ceph_connection *con);
566566
int ceph_con_v2_try_write(struct ceph_connection *con);
567-
void ceph_con_v2_revoke(struct ceph_connection *con);
567+
void ceph_con_v2_revoke(struct ceph_connection *con, struct ceph_msg *msg);
568568
void ceph_con_v2_revoke_incoming(struct ceph_connection *con);
569569
bool ceph_con_v2_opened(struct ceph_connection *con);
570570
void ceph_con_v2_reset_session(struct ceph_connection *con);

net/ceph/messenger.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,9 +1793,9 @@ void ceph_msg_revoke(struct ceph_msg *msg)
17931793
WARN_ON(con->state != CEPH_CON_S_OPEN);
17941794
dout("%s con %p msg %p was sending\n", __func__, con, msg);
17951795
if (ceph_msgr2(from_msgr(con->msgr)))
1796-
ceph_con_v2_revoke(con);
1796+
ceph_con_v2_revoke(con, msg);
17971797
else
1798-
ceph_con_v1_revoke(con);
1798+
ceph_con_v1_revoke(con, msg);
17991799
ceph_msg_put(con->out_msg);
18001800
con->out_msg = NULL;
18011801
} else {

net/ceph/messenger_v1.c

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,9 @@ static void prepare_message_data(struct ceph_msg *msg, u32 data_len)
169169
* Prepare footer for currently outgoing message, and finish things
170170
* off. Assumes out_kvec* are already valid.. we just add on to the end.
171171
*/
172-
static void prepare_write_message_footer(struct ceph_connection *con)
172+
static void prepare_write_message_footer(struct ceph_connection *con,
173+
struct ceph_msg *m)
173174
{
174-
struct ceph_msg *m = con->out_msg;
175-
176175
m->footer.flags |= CEPH_MSG_FOOTER_COMPLETE;
177176

178177
dout("prepare_write_message_footer %p\n", con);
@@ -230,31 +229,31 @@ static void prepare_write_message(struct ceph_connection *con)
230229

231230
/* fill in hdr crc and finalize hdr */
232231
crc = crc32c(0, &m->hdr, offsetof(struct ceph_msg_header, crc));
233-
con->out_msg->hdr.crc = cpu_to_le32(crc);
234-
memcpy(&con->v1.out_hdr, &con->out_msg->hdr, sizeof(con->v1.out_hdr));
232+
m->hdr.crc = cpu_to_le32(crc);
233+
memcpy(&con->v1.out_hdr, &m->hdr, sizeof(con->v1.out_hdr));
235234

236235
/* fill in front and middle crc, footer */
237236
crc = crc32c(0, m->front.iov_base, m->front.iov_len);
238-
con->out_msg->footer.front_crc = cpu_to_le32(crc);
237+
m->footer.front_crc = cpu_to_le32(crc);
239238
if (m->middle) {
240239
crc = crc32c(0, m->middle->vec.iov_base,
241240
m->middle->vec.iov_len);
242-
con->out_msg->footer.middle_crc = cpu_to_le32(crc);
241+
m->footer.middle_crc = cpu_to_le32(crc);
243242
} else
244-
con->out_msg->footer.middle_crc = 0;
243+
m->footer.middle_crc = 0;
245244
dout("%s front_crc %u middle_crc %u\n", __func__,
246-
le32_to_cpu(con->out_msg->footer.front_crc),
247-
le32_to_cpu(con->out_msg->footer.middle_crc));
248-
con->out_msg->footer.flags = 0;
245+
le32_to_cpu(m->footer.front_crc),
246+
le32_to_cpu(m->footer.middle_crc));
247+
m->footer.flags = 0;
249248

250249
/* is there a data payload? */
251-
con->out_msg->footer.data_crc = 0;
250+
m->footer.data_crc = 0;
252251
if (m->data_length) {
253-
prepare_message_data(con->out_msg, m->data_length);
252+
prepare_message_data(m, m->data_length);
254253
con->v1.out_more = 1; /* data + footer will follow */
255254
} else {
256255
/* no, queue up footer too and be done */
257-
prepare_write_message_footer(con);
256+
prepare_write_message_footer(con, m);
258257
}
259258

260259
ceph_con_flag_set(con, CEPH_CON_F_WRITE_PENDING);
@@ -461,9 +460,9 @@ static int write_partial_kvec(struct ceph_connection *con)
461460
* 0 -> socket full, but more to do
462461
* <0 -> error
463462
*/
464-
static int write_partial_message_data(struct ceph_connection *con)
463+
static int write_partial_message_data(struct ceph_connection *con,
464+
struct ceph_msg *msg)
465465
{
466-
struct ceph_msg *msg = con->out_msg;
467466
struct ceph_msg_data_cursor *cursor = &msg->cursor;
468467
bool do_datacrc = !ceph_test_opt(from_msgr(con->msgr), NOCRC);
469468
u32 crc;
@@ -515,7 +514,7 @@ static int write_partial_message_data(struct ceph_connection *con)
515514
else
516515
msg->footer.flags |= CEPH_MSG_FOOTER_NOCRC;
517516
con_out_kvec_reset(con);
518-
prepare_write_message_footer(con);
517+
prepare_write_message_footer(con, msg);
519518

520519
return 1; /* must return > 0 to indicate success */
521520
}
@@ -1471,6 +1470,7 @@ int ceph_con_v1_try_read(struct ceph_connection *con)
14711470
*/
14721471
int ceph_con_v1_try_write(struct ceph_connection *con)
14731472
{
1473+
struct ceph_msg *msg;
14741474
int ret = 1;
14751475

14761476
dout("try_write start %p state %d\n", con, con->state);
@@ -1517,14 +1517,15 @@ int ceph_con_v1_try_write(struct ceph_connection *con)
15171517
}
15181518

15191519
/* msg pages? */
1520-
if (con->out_msg) {
1520+
msg = con->out_msg;
1521+
if (msg) {
15211522
if (con->v1.out_msg_done) {
1522-
ceph_msg_put(con->out_msg);
1523+
ceph_msg_put(msg);
15231524
con->out_msg = NULL; /* we're done with this one */
15241525
goto do_next;
15251526
}
15261527

1527-
ret = write_partial_message_data(con);
1528+
ret = write_partial_message_data(con, msg);
15281529
if (ret == 1)
15291530
goto more; /* we need to send the footer, too! */
15301531
if (ret == 0)
@@ -1563,10 +1564,8 @@ int ceph_con_v1_try_write(struct ceph_connection *con)
15631564
return ret;
15641565
}
15651566

1566-
void ceph_con_v1_revoke(struct ceph_connection *con)
1567+
void ceph_con_v1_revoke(struct ceph_connection *con, struct ceph_msg *msg)
15671568
{
1568-
struct ceph_msg *msg = con->out_msg;
1569-
15701569
WARN_ON(con->v1.out_skip);
15711570
/* footer */
15721571
if (con->v1.out_msg_done) {

0 commit comments

Comments
 (0)