aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-06-01 15:56:43 -0400
committerAlex Elder <elder@dreamhost.com>2012-06-06 10:23:55 -0400
commit8921d114f5574c6da2cdd00749d185633ecf88f3 (patch)
treefcbb7ffc4061c9ea0260f5b8643abf3096d7267e /net
parent6740a845b2543cc46e1902ba21bac743fbadd0dc (diff)
libceph: make ceph_con_revoke_message() a msg op
ceph_con_revoke_message() is passed both a message and a ceph connection. A ceph_msg allocated for incoming messages on a connection always has a pointer to that connection, so there's no need to provide the connection when revoking such a message. Note that the existing logic does not preclude the message supplied being a null/bogus message pointer. The only user of this interface is the OSD client, and the only value an osd client passes is a request's r_reply field. That is always non-null (except briefly in an error path in ceph_osdc_alloc_request(), and that drops the only reference so the request won't ever have a reply to revoke). So we can safely assume the passed-in message is non-null, but add a BUG_ON() to make it very obvious we are imposing this restriction. Rename the function ceph_msg_revoke_incoming() to reflect that it is really an operation on an incoming message. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/messenger.c22
-rw-r--r--net/ceph/osd_client.c9
2 files changed, 20 insertions, 11 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index d636903ad4b..3857f815c03 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2456,17 +2456,27 @@ void ceph_msg_revoke(struct ceph_msg *msg)
2456/* 2456/*
2457 * Revoke a message that we may be reading data into 2457 * Revoke a message that we may be reading data into
2458 */ 2458 */
2459void ceph_con_revoke_message(struct ceph_connection *con, struct ceph_msg *msg) 2459void ceph_msg_revoke_incoming(struct ceph_msg *msg)
2460{ 2460{
2461 struct ceph_connection *con;
2462
2463 BUG_ON(msg == NULL);
2464 if (!msg->con) {
2465 dout("%s msg %p null con\n", __func__, msg);
2466
2467 return; /* Message not in our possession */
2468 }
2469
2470 con = msg->con;
2461 mutex_lock(&con->mutex); 2471 mutex_lock(&con->mutex);
2462 if (con->in_msg && con->in_msg == msg) { 2472 if (con->in_msg == msg) {
2463 unsigned front_len = le32_to_cpu(con->in_hdr.front_len); 2473 unsigned front_len = le32_to_cpu(con->in_hdr.front_len);
2464 unsigned middle_len = le32_to_cpu(con->in_hdr.middle_len); 2474 unsigned middle_len = le32_to_cpu(con->in_hdr.middle_len);
2465 unsigned data_len = le32_to_cpu(con->in_hdr.data_len); 2475 unsigned data_len = le32_to_cpu(con->in_hdr.data_len);
2466 2476
2467 /* skip rest of message */ 2477 /* skip rest of message */
2468 dout("con_revoke_pages %p msg %p revoked\n", con, msg); 2478 dout("%s %p msg %p revoked\n", __func__, con, msg);
2469 con->in_base_pos = con->in_base_pos - 2479 con->in_base_pos = con->in_base_pos -
2470 sizeof(struct ceph_msg_header) - 2480 sizeof(struct ceph_msg_header) -
2471 front_len - 2481 front_len -
2472 middle_len - 2482 middle_len -
@@ -2477,8 +2487,8 @@ void ceph_con_revoke_message(struct ceph_connection *con, struct ceph_msg *msg)
2477 con->in_tag = CEPH_MSGR_TAG_READY; 2487 con->in_tag = CEPH_MSGR_TAG_READY;
2478 con->in_seq++; 2488 con->in_seq++;
2479 } else { 2489 } else {
2480 dout("con_revoke_pages %p msg %p pages %p no-op\n", 2490 dout("%s %p in_msg %p msg %p no-op\n",
2481 con, con->in_msg, msg); 2491 __func__, con, con->in_msg, msg);
2482 } 2492 }
2483 mutex_unlock(&con->mutex); 2493 mutex_unlock(&con->mutex);
2484} 2494}
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index ad78705a4af..c178c770acb 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -140,10 +140,9 @@ void ceph_osdc_release_request(struct kref *kref)
140 if (req->r_request) 140 if (req->r_request)
141 ceph_msg_put(req->r_request); 141 ceph_msg_put(req->r_request);
142 if (req->r_con_filling_msg) { 142 if (req->r_con_filling_msg) {
143 dout("release_request revoking pages %p from con %p\n", 143 dout("%s revoking pages %p from con %p\n", __func__,
144 req->r_pages, req->r_con_filling_msg); 144 req->r_pages, req->r_con_filling_msg);
145 ceph_con_revoke_message(req->r_con_filling_msg, 145 ceph_msg_revoke_incoming(req->r_reply);
146 req->r_reply);
147 req->r_con_filling_msg->ops->put(req->r_con_filling_msg); 146 req->r_con_filling_msg->ops->put(req->r_con_filling_msg);
148 } 147 }
149 if (req->r_reply) 148 if (req->r_reply)
@@ -2022,9 +2021,9 @@ static struct ceph_msg *get_reply(struct ceph_connection *con,
2022 } 2021 }
2023 2022
2024 if (req->r_con_filling_msg) { 2023 if (req->r_con_filling_msg) {
2025 dout("get_reply revoking msg %p from old con %p\n", 2024 dout("%s revoking msg %p from old con %p\n", __func__,
2026 req->r_reply, req->r_con_filling_msg); 2025 req->r_reply, req->r_con_filling_msg);
2027 ceph_con_revoke_message(req->r_con_filling_msg, req->r_reply); 2026 ceph_msg_revoke_incoming(req->r_reply);
2028 req->r_con_filling_msg->ops->put(req->r_con_filling_msg); 2027 req->r_con_filling_msg->ops->put(req->r_con_filling_msg);
2029 req->r_con_filling_msg = NULL; 2028 req->r_con_filling_msg = NULL;
2030 } 2029 }