diff options
author | Sage Weil <sage@newdream.net> | 2009-12-14 17:04:30 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-12-21 19:39:38 -0500 |
commit | c86a2930ccbd90d77c54d04b5c2bbec95b989e40 (patch) | |
tree | 604861d3945623a505c68ca96a1a637e6a7a320f /fs | |
parent | d4a780ce8821a37dd135f15b6150a5bfc5604f29 (diff) |
ceph: carry explicit msg reference for currently sending message
Carry a ceph_msg reference for connection->out_msg. This will allow us to
make out_sent optional.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ceph/messenger.c | 22 | ||||
-rw-r--r-- | fs/ceph/messenger.h | 1 |
2 files changed, 19 insertions, 4 deletions
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c index b0571b01b19f..96fd556a7804 100644 --- a/fs/ceph/messenger.c +++ b/fs/ceph/messenger.c | |||
@@ -322,7 +322,10 @@ static void reset_connection(struct ceph_connection *con) | |||
322 | 322 | ||
323 | con->connect_seq = 0; | 323 | con->connect_seq = 0; |
324 | con->out_seq = 0; | 324 | con->out_seq = 0; |
325 | con->out_msg = NULL; | 325 | if (con->out_msg) { |
326 | ceph_msg_put(con->out_msg); | ||
327 | con->out_msg = NULL; | ||
328 | } | ||
326 | con->in_seq = 0; | 329 | con->in_seq = 0; |
327 | mutex_unlock(&con->out_mutex); | 330 | mutex_unlock(&con->out_mutex); |
328 | } | 331 | } |
@@ -423,7 +426,7 @@ static void prepare_write_message_footer(struct ceph_connection *con, int v) | |||
423 | con->out_kvec_bytes += sizeof(m->footer); | 426 | con->out_kvec_bytes += sizeof(m->footer); |
424 | con->out_kvec_left++; | 427 | con->out_kvec_left++; |
425 | con->out_more = m->more_to_follow; | 428 | con->out_more = m->more_to_follow; |
426 | con->out_msg = NULL; /* we're done with this one */ | 429 | con->out_msg_done = true; |
427 | } | 430 | } |
428 | 431 | ||
429 | /* | 432 | /* |
@@ -436,6 +439,7 @@ static void prepare_write_message(struct ceph_connection *con) | |||
436 | 439 | ||
437 | con->out_kvec_bytes = 0; | 440 | con->out_kvec_bytes = 0; |
438 | con->out_kvec_is_msg = true; | 441 | con->out_kvec_is_msg = true; |
442 | con->out_msg_done = false; | ||
439 | 443 | ||
440 | /* Sneak an ack in there first? If we can get it into the same | 444 | /* Sneak an ack in there first? If we can get it into the same |
441 | * TCP packet that's a good thing. */ | 445 | * TCP packet that's a good thing. */ |
@@ -452,8 +456,9 @@ static void prepare_write_message(struct ceph_connection *con) | |||
452 | /* move message to sending/sent list */ | 456 | /* move message to sending/sent list */ |
453 | m = list_first_entry(&con->out_queue, | 457 | m = list_first_entry(&con->out_queue, |
454 | struct ceph_msg, list_head); | 458 | struct ceph_msg, list_head); |
459 | con->out_msg = m; | ||
460 | ceph_msg_get(m); | ||
455 | list_move_tail(&m->list_head, &con->out_sent); | 461 | list_move_tail(&m->list_head, &con->out_sent); |
456 | con->out_msg = m; /* we don't bother taking a reference here. */ | ||
457 | 462 | ||
458 | m->hdr.seq = cpu_to_le64(++con->out_seq); | 463 | m->hdr.seq = cpu_to_le64(++con->out_seq); |
459 | 464 | ||
@@ -1521,6 +1526,12 @@ more_kvec: | |||
1521 | 1526 | ||
1522 | /* msg pages? */ | 1527 | /* msg pages? */ |
1523 | if (con->out_msg) { | 1528 | if (con->out_msg) { |
1529 | if (con->out_msg_done) { | ||
1530 | ceph_msg_put(con->out_msg); | ||
1531 | con->out_msg = NULL; /* we're done with this one */ | ||
1532 | goto do_next; | ||
1533 | } | ||
1534 | |||
1524 | ret = write_partial_msg_pages(con); | 1535 | ret = write_partial_msg_pages(con); |
1525 | if (ret == 1) | 1536 | if (ret == 1) |
1526 | goto more_kvec; /* we need to send the footer, too! */ | 1537 | goto more_kvec; /* we need to send the footer, too! */ |
@@ -1533,6 +1544,7 @@ more_kvec: | |||
1533 | } | 1544 | } |
1534 | } | 1545 | } |
1535 | 1546 | ||
1547 | do_next: | ||
1536 | if (!test_bit(CONNECTING, &con->state)) { | 1548 | if (!test_bit(CONNECTING, &con->state)) { |
1537 | /* is anything else pending? */ | 1549 | /* is anything else pending? */ |
1538 | if (!list_empty(&con->out_queue)) { | 1550 | if (!list_empty(&con->out_queue)) { |
@@ -1923,8 +1935,10 @@ void ceph_con_revoke(struct ceph_connection *con, struct ceph_msg *msg) | |||
1923 | list_del_init(&msg->list_head); | 1935 | list_del_init(&msg->list_head); |
1924 | ceph_msg_put(msg); | 1936 | ceph_msg_put(msg); |
1925 | msg->hdr.seq = 0; | 1937 | msg->hdr.seq = 0; |
1926 | if (con->out_msg == msg) | 1938 | if (con->out_msg == msg) { |
1939 | ceph_msg_put(con->out_msg); | ||
1927 | con->out_msg = NULL; | 1940 | con->out_msg = NULL; |
1941 | } | ||
1928 | if (con->out_kvec_is_msg) { | 1942 | if (con->out_kvec_is_msg) { |
1929 | con->out_skip = con->out_kvec_bytes; | 1943 | con->out_skip = con->out_kvec_bytes; |
1930 | con->out_kvec_is_msg = false; | 1944 | con->out_kvec_is_msg = false; |
diff --git a/fs/ceph/messenger.h b/fs/ceph/messenger.h index 981b7c08ad82..eff5cb5197fc 100644 --- a/fs/ceph/messenger.h +++ b/fs/ceph/messenger.h | |||
@@ -182,6 +182,7 @@ struct ceph_connection { | |||
182 | /* message out temps */ | 182 | /* message out temps */ |
183 | struct ceph_msg *out_msg; /* sending message (== tail of | 183 | struct ceph_msg *out_msg; /* sending message (== tail of |
184 | out_sent) */ | 184 | out_sent) */ |
185 | bool out_msg_done; | ||
185 | struct ceph_msg_pos out_msg_pos; | 186 | struct ceph_msg_pos out_msg_pos; |
186 | 187 | ||
187 | struct kvec out_kvec[8], /* sending header/footer data */ | 188 | struct kvec out_kvec[8], /* sending header/footer data */ |