diff options
author | Sage Weil <sage@newdream.net> | 2010-04-01 19:07:23 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-05-17 18:25:19 -0400 |
commit | bb257664f748bcfc80715f85f70f0f560caec3b4 (patch) | |
tree | 0f03c628328082e660c6a60f6094cde478dadec9 /fs/ceph/messenger.c | |
parent | a79832f26be370ee26ea81eecdfd42d10e49d66a (diff) |
ceph: simplify ceph_msg_new
We only need to pass in front_len. Callers can attach any other payload
pieces (middle, data) as they see fit.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/messenger.c')
-rw-r--r-- | fs/ceph/messenger.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c index fe7d0c52ae3c..395ce326beda 100644 --- a/fs/ceph/messenger.c +++ b/fs/ceph/messenger.c | |||
@@ -2081,8 +2081,7 @@ void ceph_con_keepalive(struct ceph_connection *con) | |||
2081 | * construct a new message with given type, size | 2081 | * construct a new message with given type, size |
2082 | * the new msg has a ref count of 1. | 2082 | * the new msg has a ref count of 1. |
2083 | */ | 2083 | */ |
2084 | struct ceph_msg *ceph_msg_new(int type, int front_len, | 2084 | struct ceph_msg *ceph_msg_new(int type, int front_len) |
2085 | int page_len, int page_off, struct page **pages) | ||
2086 | { | 2085 | { |
2087 | struct ceph_msg *m; | 2086 | struct ceph_msg *m; |
2088 | 2087 | ||
@@ -2098,8 +2097,8 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, | |||
2098 | m->hdr.version = 0; | 2097 | m->hdr.version = 0; |
2099 | m->hdr.front_len = cpu_to_le32(front_len); | 2098 | m->hdr.front_len = cpu_to_le32(front_len); |
2100 | m->hdr.middle_len = 0; | 2099 | m->hdr.middle_len = 0; |
2101 | m->hdr.data_len = cpu_to_le32(page_len); | 2100 | m->hdr.data_len = 0; |
2102 | m->hdr.data_off = cpu_to_le16(page_off); | 2101 | m->hdr.data_off = 0; |
2103 | m->hdr.reserved = 0; | 2102 | m->hdr.reserved = 0; |
2104 | m->footer.front_crc = 0; | 2103 | m->footer.front_crc = 0; |
2105 | m->footer.middle_crc = 0; | 2104 | m->footer.middle_crc = 0; |
@@ -2133,18 +2132,17 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, | |||
2133 | m->middle = NULL; | 2132 | m->middle = NULL; |
2134 | 2133 | ||
2135 | /* data */ | 2134 | /* data */ |
2136 | m->nr_pages = calc_pages_for(page_off, page_len); | 2135 | m->nr_pages = 0; |
2137 | m->pages = pages; | 2136 | m->pages = NULL; |
2138 | m->pagelist = NULL; | 2137 | m->pagelist = NULL; |
2139 | 2138 | ||
2140 | dout("ceph_msg_new %p page %d~%d -> %d\n", m, page_off, page_len, | 2139 | dout("ceph_msg_new %p front %d\n", m, front_len); |
2141 | m->nr_pages); | ||
2142 | return m; | 2140 | return m; |
2143 | 2141 | ||
2144 | out2: | 2142 | out2: |
2145 | ceph_msg_put(m); | 2143 | ceph_msg_put(m); |
2146 | out: | 2144 | out: |
2147 | pr_err("msg_new can't create type %d len %d\n", type, front_len); | 2145 | pr_err("msg_new can't create type %d front %d\n", type, front_len); |
2148 | return NULL; | 2146 | return NULL; |
2149 | } | 2147 | } |
2150 | 2148 | ||
@@ -2193,7 +2191,7 @@ static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con, | |||
2193 | } | 2191 | } |
2194 | if (!msg) { | 2192 | if (!msg) { |
2195 | *skip = 0; | 2193 | *skip = 0; |
2196 | msg = ceph_msg_new(type, front_len, 0, 0, NULL); | 2194 | msg = ceph_msg_new(type, front_len); |
2197 | if (!msg) { | 2195 | if (!msg) { |
2198 | pr_err("unable to allocate msg type %d len %d\n", | 2196 | pr_err("unable to allocate msg type %d len %d\n", |
2199 | type, front_len); | 2197 | type, front_len); |
@@ -2202,7 +2200,7 @@ static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con, | |||
2202 | } | 2200 | } |
2203 | memcpy(&msg->hdr, &con->in_hdr, sizeof(con->in_hdr)); | 2201 | memcpy(&msg->hdr, &con->in_hdr, sizeof(con->in_hdr)); |
2204 | 2202 | ||
2205 | if (middle_len) { | 2203 | if (middle_len && !msg->middle) { |
2206 | ret = ceph_alloc_middle(con, msg); | 2204 | ret = ceph_alloc_middle(con, msg); |
2207 | if (ret < 0) { | 2205 | if (ret < 0) { |
2208 | ceph_msg_put(msg); | 2206 | ceph_msg_put(msg); |