aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2010-04-01 19:07:23 -0400
committerSage Weil <sage@newdream.net>2010-05-17 18:25:19 -0400
commitbb257664f748bcfc80715f85f70f0f560caec3b4 (patch)
tree0f03c628328082e660c6a60f6094cde478dadec9 /fs/ceph
parenta79832f26be370ee26ea81eecdfd42d10e49d66a (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')
-rw-r--r--fs/ceph/caps.c2
-rw-r--r--fs/ceph/mds_client.c11
-rw-r--r--fs/ceph/messenger.c20
-rw-r--r--fs/ceph/messenger.h4
-rw-r--r--fs/ceph/mon_client.c16
-rw-r--r--fs/ceph/msgpool.c4
-rw-r--r--fs/ceph/osd_client.c8
7 files changed, 29 insertions, 36 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 8755e2d83d4c..74c74842c860 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -938,7 +938,7 @@ static int send_cap_msg(struct ceph_mds_session *session,
938 seq, issue_seq, mseq, follows, size, max_size, 938 seq, issue_seq, mseq, follows, size, max_size,
939 xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0); 939 xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0);
940 940
941 msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc), 0, 0, NULL); 941 msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc));
942 if (!msg) 942 if (!msg)
943 return -ENOMEM; 943 return -ENOMEM;
944 944
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 7e89c185d38d..35dbdad07b1c 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -665,7 +665,7 @@ static struct ceph_msg *create_session_msg(u32 op, u64 seq)
665 struct ceph_msg *msg; 665 struct ceph_msg *msg;
666 struct ceph_mds_session_head *h; 666 struct ceph_mds_session_head *h;
667 667
668 msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h), 0, 0, NULL); 668 msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h));
669 if (!msg) { 669 if (!msg) {
670 pr_err("create_session_msg ENOMEM creating msg\n"); 670 pr_err("create_session_msg ENOMEM creating msg\n");
671 return NULL; 671 return NULL;
@@ -1051,8 +1051,7 @@ static int add_cap_releases(struct ceph_mds_client *mdsc,
1051 1051
1052 while (session->s_num_cap_releases < session->s_nr_caps + extra) { 1052 while (session->s_num_cap_releases < session->s_nr_caps + extra) {
1053 spin_unlock(&session->s_cap_lock); 1053 spin_unlock(&session->s_cap_lock);
1054 msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE, 1054 msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE);
1055 0, 0, NULL);
1056 if (!msg) 1055 if (!msg)
1057 goto out_unlocked; 1056 goto out_unlocked;
1058 dout("add_cap_releases %p msg %p now %d\n", session, msg, 1057 dout("add_cap_releases %p msg %p now %d\n", session, msg,
@@ -1418,7 +1417,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
1418 if (req->r_old_dentry_drop) 1417 if (req->r_old_dentry_drop)
1419 len += req->r_old_dentry->d_name.len; 1418 len += req->r_old_dentry->d_name.len;
1420 1419
1421 msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len, 0, 0, NULL); 1420 msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len);
1422 if (!msg) { 1421 if (!msg) {
1423 msg = ERR_PTR(-ENOMEM); 1422 msg = ERR_PTR(-ENOMEM);
1424 goto out_free2; 1423 goto out_free2;
@@ -2154,7 +2153,7 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc, int mds)
2154 ceph_pagelist_init(pagelist); 2153 ceph_pagelist_init(pagelist);
2155 2154
2156 err = -ENOMEM; 2155 err = -ENOMEM;
2157 reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0, 0, 0, NULL); 2156 reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0);
2158 if (!reply) 2157 if (!reply)
2159 goto fail_nomsg; 2158 goto fail_nomsg;
2160 2159
@@ -2462,7 +2461,7 @@ void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,
2462 dnamelen = dentry->d_name.len; 2461 dnamelen = dentry->d_name.len;
2463 len += dnamelen; 2462 len += dnamelen;
2464 2463
2465 msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len, 0, 0, NULL); 2464 msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len);
2466 if (!msg) 2465 if (!msg)
2467 return; 2466 return;
2468 lease = msg->front.iov_base; 2467 lease = msg->front.iov_base;
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 */
2084struct ceph_msg *ceph_msg_new(int type, int front_len, 2084struct 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
2144out2: 2142out2:
2145 ceph_msg_put(m); 2143 ceph_msg_put(m);
2146out: 2144out:
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);
diff --git a/fs/ceph/messenger.h b/fs/ceph/messenger.h
index a5caf91cc971..27fb69585f63 100644
--- a/fs/ceph/messenger.h
+++ b/fs/ceph/messenger.h
@@ -234,9 +234,7 @@ extern void ceph_con_keepalive(struct ceph_connection *con);
234extern struct ceph_connection *ceph_con_get(struct ceph_connection *con); 234extern struct ceph_connection *ceph_con_get(struct ceph_connection *con);
235extern void ceph_con_put(struct ceph_connection *con); 235extern void ceph_con_put(struct ceph_connection *con);
236 236
237extern struct ceph_msg *ceph_msg_new(int type, int front_len, 237extern struct ceph_msg *ceph_msg_new(int type, int front_len);
238 int page_len, int page_off,
239 struct page **pages);
240extern void ceph_msg_kfree(struct ceph_msg *m); 238extern void ceph_msg_kfree(struct ceph_msg *m);
241 239
242 240
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c
index 35f593e7e364..9900706fee75 100644
--- a/fs/ceph/mon_client.c
+++ b/fs/ceph/mon_client.c
@@ -191,7 +191,7 @@ static void __send_subscribe(struct ceph_mon_client *monc)
191 struct ceph_mon_subscribe_item *i; 191 struct ceph_mon_subscribe_item *i;
192 void *p, *end; 192 void *p, *end;
193 193
194 msg = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96, 0, 0, NULL); 194 msg = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96);
195 if (!msg) 195 if (!msg)
196 return; 196 return;
197 197
@@ -491,10 +491,10 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
491 init_completion(&req->completion); 491 init_completion(&req->completion);
492 492
493 err = -ENOMEM; 493 err = -ENOMEM;
494 req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h), 0, 0, NULL); 494 req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h));
495 if (!req->request) 495 if (!req->request)
496 goto out; 496 goto out;
497 req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 1024, 0, 0, NULL); 497 req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 1024);
498 if (!req->reply) 498 if (!req->reply)
499 goto out; 499 goto out;
500 500
@@ -633,17 +633,15 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
633 /* msg pools */ 633 /* msg pools */
634 err = -ENOMEM; 634 err = -ENOMEM;
635 monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK, 635 monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK,
636 sizeof(struct ceph_mon_subscribe_ack), 636 sizeof(struct ceph_mon_subscribe_ack));
637 0, 0, NULL);
638 if (!monc->m_subscribe_ack) 637 if (!monc->m_subscribe_ack)
639 goto out_monmap; 638 goto out_monmap;
640 639
641 monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096, 0, 0, 640 monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096);
642 NULL);
643 if (!monc->m_auth_reply) 641 if (!monc->m_auth_reply)
644 goto out_subscribe_ack; 642 goto out_subscribe_ack;
645 643
646 monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, 0, 0, NULL); 644 monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096);
647 monc->pending_auth = 0; 645 monc->pending_auth = 0;
648 if (!monc->m_auth) 646 if (!monc->m_auth)
649 goto out_auth_reply; 647 goto out_auth_reply;
@@ -818,7 +816,7 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
818 case CEPH_MSG_MON_MAP: 816 case CEPH_MSG_MON_MAP:
819 case CEPH_MSG_MDS_MAP: 817 case CEPH_MSG_MDS_MAP:
820 case CEPH_MSG_OSD_MAP: 818 case CEPH_MSG_OSD_MAP:
821 m = ceph_msg_new(type, front_len, 0, 0, NULL); 819 m = ceph_msg_new(type, front_len);
822 break; 820 break;
823 } 821 }
824 822
diff --git a/fs/ceph/msgpool.c b/fs/ceph/msgpool.c
index 04fea84890da..10d3632cc403 100644
--- a/fs/ceph/msgpool.c
+++ b/fs/ceph/msgpool.c
@@ -11,7 +11,7 @@ static void *alloc_fn(gfp_t gfp_mask, void *arg)
11{ 11{
12 struct ceph_msgpool *pool = arg; 12 struct ceph_msgpool *pool = arg;
13 13
14 return ceph_msg_new(0, pool->front_len, 0, 0, NULL); 14 return ceph_msg_new(0, pool->front_len);
15} 15}
16 16
17static void free_fn(void *element, void *arg) 17static void free_fn(void *element, void *arg)
@@ -43,7 +43,7 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool,
43 WARN_ON(1); 43 WARN_ON(1);
44 44
45 /* try to alloc a fresh message */ 45 /* try to alloc a fresh message */
46 return ceph_msg_new(0, front_len, 0, 0, NULL); 46 return ceph_msg_new(0, front_len);
47 } 47 }
48 48
49 return mempool_alloc(pool->pool, GFP_NOFS); 49 return mempool_alloc(pool->pool, GFP_NOFS);
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c
index a51d0df2af30..a44b3b6374ee 100644
--- a/fs/ceph/osd_client.c
+++ b/fs/ceph/osd_client.c
@@ -164,7 +164,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
164 msg = ceph_msgpool_get(&osdc->msgpool_op_reply, 0); 164 msg = ceph_msgpool_get(&osdc->msgpool_op_reply, 0);
165 else 165 else
166 msg = ceph_msg_new(CEPH_MSG_OSD_OPREPLY, 166 msg = ceph_msg_new(CEPH_MSG_OSD_OPREPLY,
167 OSD_OPREPLY_FRONT_LEN, 0, 0, NULL); 167 OSD_OPREPLY_FRONT_LEN);
168 if (!msg) { 168 if (!msg) {
169 ceph_osdc_put_request(req); 169 ceph_osdc_put_request(req);
170 return NULL; 170 return NULL;
@@ -178,7 +178,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
178 if (use_mempool) 178 if (use_mempool)
179 msg = ceph_msgpool_get(&osdc->msgpool_op, 0); 179 msg = ceph_msgpool_get(&osdc->msgpool_op, 0);
180 else 180 else
181 msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size, 0, 0, NULL); 181 msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size);
182 if (!msg) { 182 if (!msg) {
183 ceph_osdc_put_request(req); 183 ceph_osdc_put_request(req);
184 return NULL; 184 return NULL;
@@ -1392,7 +1392,7 @@ static struct ceph_msg *get_reply(struct ceph_connection *con,
1392 if (front > req->r_reply->front.iov_len) { 1392 if (front > req->r_reply->front.iov_len) {
1393 pr_warning("get_reply front %d > preallocated %d\n", 1393 pr_warning("get_reply front %d > preallocated %d\n",
1394 front, (int)req->r_reply->front.iov_len); 1394 front, (int)req->r_reply->front.iov_len);
1395 m = ceph_msg_new(CEPH_MSG_OSD_OPREPLY, front, 0, 0, NULL); 1395 m = ceph_msg_new(CEPH_MSG_OSD_OPREPLY, front);
1396 if (!m) 1396 if (!m)
1397 goto out; 1397 goto out;
1398 ceph_msg_put(req->r_reply); 1398 ceph_msg_put(req->r_reply);
@@ -1435,7 +1435,7 @@ static struct ceph_msg *alloc_msg(struct ceph_connection *con,
1435 1435
1436 switch (type) { 1436 switch (type) {
1437 case CEPH_MSG_OSD_MAP: 1437 case CEPH_MSG_OSD_MAP:
1438 return ceph_msg_new(type, front, 0, 0, NULL); 1438 return ceph_msg_new(type, front);
1439 case CEPH_MSG_OSD_OPREPLY: 1439 case CEPH_MSG_OSD_OPREPLY:
1440 return get_reply(con, hdr, skip); 1440 return get_reply(con, hdr, skip);
1441 default: 1441 default: