aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2011-08-09 18:03:46 -0400
committerSage Weil <sage@newdream.net>2011-10-25 19:10:15 -0400
commitb61c27636fffbaf1980e675282777b9467254a40 (patch)
treebd78cfefda4beb7e3de5fe97dd36fed3dbfa91c1
parentf6a2f5be07463ef532b9f4e3cb9e42ab9df85832 (diff)
libceph: don't complain on msgpool alloc failures
The pool allocation failures are masked by the pool; there is no need to spam the console about them. (That's the whole point of having the pool in the first place.) Mark msg allocations whose failure is safely handled as such. Signed-off-by: Sage Weil <sage@newdream.net>
-rw-r--r--fs/ceph/caps.c2
-rw-r--r--fs/ceph/mds_client.c11
-rw-r--r--include/linux/ceph/messenger.h3
-rw-r--r--net/ceph/messenger.c15
-rw-r--r--net/ceph/mon_client.c24
-rw-r--r--net/ceph/msgpool.c4
-rw-r--r--net/ceph/osd_client.c8
7 files changed, 41 insertions, 26 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 8d74ad7ba556..b8731bf3ef1f 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -945,7 +945,7 @@ static int send_cap_msg(struct ceph_mds_session *session,
945 seq, issue_seq, mseq, follows, size, max_size, 945 seq, issue_seq, mseq, follows, size, max_size,
946 xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0); 946 xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0);
947 947
948 msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc), GFP_NOFS); 948 msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc), GFP_NOFS, false);
949 if (!msg) 949 if (!msg)
950 return -ENOMEM; 950 return -ENOMEM;
951 951
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 86c59e16ba74..1d72f15fe9f4 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -764,7 +764,8 @@ static struct ceph_msg *create_session_msg(u32 op, u64 seq)
764 struct ceph_msg *msg; 764 struct ceph_msg *msg;
765 struct ceph_mds_session_head *h; 765 struct ceph_mds_session_head *h;
766 766
767 msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h), GFP_NOFS); 767 msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h), GFP_NOFS,
768 false);
768 if (!msg) { 769 if (!msg) {
769 pr_err("create_session_msg ENOMEM creating msg\n"); 770 pr_err("create_session_msg ENOMEM creating msg\n");
770 return NULL; 771 return NULL;
@@ -1240,7 +1241,7 @@ int ceph_add_cap_releases(struct ceph_mds_client *mdsc,
1240 while (session->s_num_cap_releases < session->s_nr_caps + extra) { 1241 while (session->s_num_cap_releases < session->s_nr_caps + extra) {
1241 spin_unlock(&session->s_cap_lock); 1242 spin_unlock(&session->s_cap_lock);
1242 msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE, 1243 msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE,
1243 GFP_NOFS); 1244 GFP_NOFS, false);
1244 if (!msg) 1245 if (!msg)
1245 goto out_unlocked; 1246 goto out_unlocked;
1246 dout("add_cap_releases %p msg %p now %d\n", session, msg, 1247 dout("add_cap_releases %p msg %p now %d\n", session, msg,
@@ -1652,7 +1653,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
1652 if (req->r_old_dentry_drop) 1653 if (req->r_old_dentry_drop)
1653 len += req->r_old_dentry->d_name.len; 1654 len += req->r_old_dentry->d_name.len;
1654 1655
1655 msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len, GFP_NOFS); 1656 msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len, GFP_NOFS, false);
1656 if (!msg) { 1657 if (!msg) {
1657 msg = ERR_PTR(-ENOMEM); 1658 msg = ERR_PTR(-ENOMEM);
1658 goto out_free2; 1659 goto out_free2;
@@ -2518,7 +2519,7 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
2518 goto fail_nopagelist; 2519 goto fail_nopagelist;
2519 ceph_pagelist_init(pagelist); 2520 ceph_pagelist_init(pagelist);
2520 2521
2521 reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0, GFP_NOFS); 2522 reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0, GFP_NOFS, false);
2522 if (!reply) 2523 if (!reply)
2523 goto fail_nomsg; 2524 goto fail_nomsg;
2524 2525
@@ -2831,7 +2832,7 @@ void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,
2831 dnamelen = dentry->d_name.len; 2832 dnamelen = dentry->d_name.len;
2832 len += dnamelen; 2833 len += dnamelen;
2833 2834
2834 msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len, GFP_NOFS); 2835 msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len, GFP_NOFS, false);
2835 if (!msg) 2836 if (!msg)
2836 return; 2837 return;
2837 lease = msg->front.iov_base; 2838 lease = msg->front.iov_base;
diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h
index d7adf151d335..bbd4a4bb2c6b 100644
--- a/include/linux/ceph/messenger.h
+++ b/include/linux/ceph/messenger.h
@@ -238,7 +238,8 @@ extern void ceph_con_keepalive(struct ceph_connection *con);
238extern struct ceph_connection *ceph_con_get(struct ceph_connection *con); 238extern struct ceph_connection *ceph_con_get(struct ceph_connection *con);
239extern void ceph_con_put(struct ceph_connection *con); 239extern void ceph_con_put(struct ceph_connection *con);
240 240
241extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags); 241extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags,
242 bool can_fail);
242extern void ceph_msg_kfree(struct ceph_msg *m); 243extern void ceph_msg_kfree(struct ceph_msg *m);
243 244
244 245
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 9918e9eb276e..2de711a0c037 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2281,7 +2281,8 @@ EXPORT_SYMBOL(ceph_con_keepalive);
2281 * construct a new message with given type, size 2281 * construct a new message with given type, size
2282 * the new msg has a ref count of 1. 2282 * the new msg has a ref count of 1.
2283 */ 2283 */
2284struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags) 2284struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags,
2285 bool can_fail)
2285{ 2286{
2286 struct ceph_msg *m; 2287 struct ceph_msg *m;
2287 2288
@@ -2333,7 +2334,7 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags)
2333 m->front.iov_base = kmalloc(front_len, flags); 2334 m->front.iov_base = kmalloc(front_len, flags);
2334 } 2335 }
2335 if (m->front.iov_base == NULL) { 2336 if (m->front.iov_base == NULL) {
2336 pr_err("msg_new can't allocate %d bytes\n", 2337 dout("ceph_msg_new can't allocate %d bytes\n",
2337 front_len); 2338 front_len);
2338 goto out2; 2339 goto out2;
2339 } 2340 }
@@ -2348,7 +2349,13 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags)
2348out2: 2349out2:
2349 ceph_msg_put(m); 2350 ceph_msg_put(m);
2350out: 2351out:
2351 pr_err("msg_new can't create type %d front %d\n", type, front_len); 2352 if (!can_fail) {
2353 pr_err("msg_new can't create type %d front %d\n", type,
2354 front_len);
2355 } else {
2356 dout("msg_new can't create type %d front %d\n", type,
2357 front_len);
2358 }
2352 return NULL; 2359 return NULL;
2353} 2360}
2354EXPORT_SYMBOL(ceph_msg_new); 2361EXPORT_SYMBOL(ceph_msg_new);
@@ -2398,7 +2405,7 @@ static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con,
2398 } 2405 }
2399 if (!msg) { 2406 if (!msg) {
2400 *skip = 0; 2407 *skip = 0;
2401 msg = ceph_msg_new(type, front_len, GFP_NOFS); 2408 msg = ceph_msg_new(type, front_len, GFP_NOFS, false);
2402 if (!msg) { 2409 if (!msg) {
2403 pr_err("unable to allocate msg type %d len %d\n", 2410 pr_err("unable to allocate msg type %d len %d\n",
2404 type, front_len); 2411 type, front_len);
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c
index 556721665335..af2ef3082499 100644
--- a/net/ceph/mon_client.c
+++ b/net/ceph/mon_client.c
@@ -517,10 +517,12 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
517 init_completion(&req->completion); 517 init_completion(&req->completion);
518 518
519 err = -ENOMEM; 519 err = -ENOMEM;
520 req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h), GFP_NOFS); 520 req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h), GFP_NOFS,
521 true);
521 if (!req->request) 522 if (!req->request)
522 goto out; 523 goto out;
523 req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 1024, GFP_NOFS); 524 req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 1024, GFP_NOFS,
525 true);
524 if (!req->reply) 526 if (!req->reply)
525 goto out; 527 goto out;
526 528
@@ -615,10 +617,12 @@ int ceph_monc_do_poolop(struct ceph_mon_client *monc, u32 op,
615 init_completion(&req->completion); 617 init_completion(&req->completion);
616 618
617 err = -ENOMEM; 619 err = -ENOMEM;
618 req->request = ceph_msg_new(CEPH_MSG_POOLOP, sizeof(*h), GFP_NOFS); 620 req->request = ceph_msg_new(CEPH_MSG_POOLOP, sizeof(*h), GFP_NOFS,
621 true);
619 if (!req->request) 622 if (!req->request)
620 goto out; 623 goto out;
621 req->reply = ceph_msg_new(CEPH_MSG_POOLOP_REPLY, 1024, GFP_NOFS); 624 req->reply = ceph_msg_new(CEPH_MSG_POOLOP_REPLY, 1024, GFP_NOFS,
625 true);
622 if (!req->reply) 626 if (!req->reply)
623 goto out; 627 goto out;
624 628
@@ -765,19 +769,21 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
765 err = -ENOMEM; 769 err = -ENOMEM;
766 monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK, 770 monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK,
767 sizeof(struct ceph_mon_subscribe_ack), 771 sizeof(struct ceph_mon_subscribe_ack),
768 GFP_NOFS); 772 GFP_NOFS, true);
769 if (!monc->m_subscribe_ack) 773 if (!monc->m_subscribe_ack)
770 goto out_con; 774 goto out_con;
771 775
772 monc->m_subscribe = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96, GFP_NOFS); 776 monc->m_subscribe = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96, GFP_NOFS,
777 true);
773 if (!monc->m_subscribe) 778 if (!monc->m_subscribe)
774 goto out_subscribe_ack; 779 goto out_subscribe_ack;
775 780
776 monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096, GFP_NOFS); 781 monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096, GFP_NOFS,
782 true);
777 if (!monc->m_auth_reply) 783 if (!monc->m_auth_reply)
778 goto out_subscribe; 784 goto out_subscribe;
779 785
780 monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, GFP_NOFS); 786 monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, GFP_NOFS, true);
781 monc->pending_auth = 0; 787 monc->pending_auth = 0;
782 if (!monc->m_auth) 788 if (!monc->m_auth)
783 goto out_auth_reply; 789 goto out_auth_reply;
@@ -970,7 +976,7 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
970 case CEPH_MSG_MON_MAP: 976 case CEPH_MSG_MON_MAP:
971 case CEPH_MSG_MDS_MAP: 977 case CEPH_MSG_MDS_MAP:
972 case CEPH_MSG_OSD_MAP: 978 case CEPH_MSG_OSD_MAP:
973 m = ceph_msg_new(type, front_len, GFP_NOFS); 979 m = ceph_msg_new(type, front_len, GFP_NOFS, false);
974 break; 980 break;
975 } 981 }
976 982
diff --git a/net/ceph/msgpool.c b/net/ceph/msgpool.c
index 1f4cb30a42c5..11d5f4196a73 100644
--- a/net/ceph/msgpool.c
+++ b/net/ceph/msgpool.c
@@ -12,7 +12,7 @@ static void *msgpool_alloc(gfp_t gfp_mask, void *arg)
12 struct ceph_msgpool *pool = arg; 12 struct ceph_msgpool *pool = arg;
13 struct ceph_msg *msg; 13 struct ceph_msg *msg;
14 14
15 msg = ceph_msg_new(0, pool->front_len, gfp_mask); 15 msg = ceph_msg_new(0, pool->front_len, gfp_mask, true);
16 if (!msg) { 16 if (!msg) {
17 dout("msgpool_alloc %s failed\n", pool->name); 17 dout("msgpool_alloc %s failed\n", pool->name);
18 } else { 18 } else {
@@ -61,7 +61,7 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool,
61 WARN_ON(1); 61 WARN_ON(1);
62 62
63 /* try to alloc a fresh message */ 63 /* try to alloc a fresh message */
64 return ceph_msg_new(0, front_len, GFP_NOFS); 64 return ceph_msg_new(0, front_len, GFP_NOFS, false);
65 } 65 }
66 66
67 msg = mempool_alloc(pool->pool, GFP_NOFS); 67 msg = mempool_alloc(pool->pool, GFP_NOFS);
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 88ad8a2501b5..01ceb59a8b4a 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -227,7 +227,7 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
227 msg = ceph_msgpool_get(&osdc->msgpool_op_reply, 0); 227 msg = ceph_msgpool_get(&osdc->msgpool_op_reply, 0);
228 else 228 else
229 msg = ceph_msg_new(CEPH_MSG_OSD_OPREPLY, 229 msg = ceph_msg_new(CEPH_MSG_OSD_OPREPLY,
230 OSD_OPREPLY_FRONT_LEN, gfp_flags); 230 OSD_OPREPLY_FRONT_LEN, gfp_flags, true);
231 if (!msg) { 231 if (!msg) {
232 ceph_osdc_put_request(req); 232 ceph_osdc_put_request(req);
233 return NULL; 233 return NULL;
@@ -250,7 +250,7 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
250 if (use_mempool) 250 if (use_mempool)
251 msg = ceph_msgpool_get(&osdc->msgpool_op, 0); 251 msg = ceph_msgpool_get(&osdc->msgpool_op, 0);
252 else 252 else
253 msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size, gfp_flags); 253 msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size, gfp_flags, true);
254 if (!msg) { 254 if (!msg) {
255 ceph_osdc_put_request(req); 255 ceph_osdc_put_request(req);
256 return NULL; 256 return NULL;
@@ -2032,7 +2032,7 @@ static struct ceph_msg *get_reply(struct ceph_connection *con,
2032 if (front > req->r_reply->front.iov_len) { 2032 if (front > req->r_reply->front.iov_len) {
2033 pr_warning("get_reply front %d > preallocated %d\n", 2033 pr_warning("get_reply front %d > preallocated %d\n",
2034 front, (int)req->r_reply->front.iov_len); 2034 front, (int)req->r_reply->front.iov_len);
2035 m = ceph_msg_new(CEPH_MSG_OSD_OPREPLY, front, GFP_NOFS); 2035 m = ceph_msg_new(CEPH_MSG_OSD_OPREPLY, front, GFP_NOFS, false);
2036 if (!m) 2036 if (!m)
2037 goto out; 2037 goto out;
2038 ceph_msg_put(req->r_reply); 2038 ceph_msg_put(req->r_reply);
@@ -2080,7 +2080,7 @@ static struct ceph_msg *alloc_msg(struct ceph_connection *con,
2080 switch (type) { 2080 switch (type) {
2081 case CEPH_MSG_OSD_MAP: 2081 case CEPH_MSG_OSD_MAP:
2082 case CEPH_MSG_WATCH_NOTIFY: 2082 case CEPH_MSG_WATCH_NOTIFY:
2083 return ceph_msg_new(type, front, GFP_NOFS); 2083 return ceph_msg_new(type, front, GFP_NOFS, false);
2084 case CEPH_MSG_OSD_OPREPLY: 2084 case CEPH_MSG_OSD_OPREPLY:
2085 return get_reply(con, hdr, skip); 2085 return get_reply(con, hdr, skip);
2086 default: 2086 default: