diff options
author | Sage Weil <sage@newdream.net> | 2010-03-01 18:25:00 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-03-01 18:25:00 -0500 |
commit | 3ca02ef96e119d36bc1752baeae7dd0c59c2f325 (patch) | |
tree | 5ef2a149d0f67b3f59fd5c4b168712046f7ce7f2 | |
parent | 70edb55bdfa8922c8ad40bc5a67abb6d9fee8d47 (diff) |
ceph: reset front len on return to msgpool; BUG on mismatched front iov
Reset msg front len when a message is returned to the pool: the caller
may have changed it.
BUG if we try to send a message with a hdr.front_len that doesn't match
the front iov.
Signed-off-by: Sage Weil <sage@newdream.net>
-rw-r--r-- | fs/ceph/messenger.c | 2 | ||||
-rw-r--r-- | fs/ceph/msgpool.c | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c index bf4590c77cf6..781656a49bf8 100644 --- a/fs/ceph/messenger.c +++ b/fs/ceph/messenger.c | |||
@@ -1954,6 +1954,8 @@ void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg) | |||
1954 | msg->hdr.src.addr = con->msgr->my_enc_addr; | 1954 | msg->hdr.src.addr = con->msgr->my_enc_addr; |
1955 | msg->hdr.orig_src = msg->hdr.src; | 1955 | msg->hdr.orig_src = msg->hdr.src; |
1956 | 1956 | ||
1957 | BUG_ON(msg->front.iov_len != le32_to_cpu(msg->hdr.front_len)); | ||
1958 | |||
1957 | /* queue */ | 1959 | /* queue */ |
1958 | mutex_lock(&con->mutex); | 1960 | mutex_lock(&con->mutex); |
1959 | BUG_ON(!list_empty(&msg->list_head)); | 1961 | BUG_ON(!list_empty(&msg->list_head)); |
diff --git a/fs/ceph/msgpool.c b/fs/ceph/msgpool.c index 2f04e0fc4666..ca3b44a89f2d 100644 --- a/fs/ceph/msgpool.c +++ b/fs/ceph/msgpool.c | |||
@@ -166,6 +166,10 @@ void ceph_msgpool_put(struct ceph_msgpool *pool, struct ceph_msg *msg) | |||
166 | { | 166 | { |
167 | spin_lock(&pool->lock); | 167 | spin_lock(&pool->lock); |
168 | if (pool->num < pool->min) { | 168 | if (pool->num < pool->min) { |
169 | /* reset msg front_len; user may have changed it */ | ||
170 | msg->front.iov_len = pool->front_len; | ||
171 | msg->hdr.front_len = cpu_to_le32(pool->front_len); | ||
172 | |||
169 | kref_set(&msg->kref, 1); /* retake a single ref */ | 173 | kref_set(&msg->kref, 1); /* retake a single ref */ |
170 | list_add(&msg->list_head, &pool->msgs); | 174 | list_add(&msg->list_head, &pool->msgs); |
171 | pool->num++; | 175 | pool->num++; |