diff options
author | Sage Weil <sage@newdream.net> | 2010-04-24 12:56:35 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-05-17 18:25:24 -0400 |
commit | 4f48280ee1d0654390cd50ad0c41ea93309e7c91 (patch) | |
tree | e0a9b6502ddcf09caa66c99b787685f4846ea7ef | |
parent | 8c6efb58a5bab880d45b2078cb55ec4320707daf (diff) |
ceph: name msgpools; useful error messages
Signed-off-by: Sage Weil <sage@newdream.net>
-rw-r--r-- | fs/ceph/msgpool.c | 13 | ||||
-rw-r--r-- | fs/ceph/msgpool.h | 4 | ||||
-rw-r--r-- | fs/ceph/osd_client.c | 6 |
3 files changed, 16 insertions, 7 deletions
diff --git a/fs/ceph/msgpool.c b/fs/ceph/msgpool.c index 10d3632cc403..50fe5cc5de76 100644 --- a/fs/ceph/msgpool.c +++ b/fs/ceph/msgpool.c | |||
@@ -10,8 +10,12 @@ | |||
10 | static void *alloc_fn(gfp_t gfp_mask, void *arg) | 10 | 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 | void *p; | ||
13 | 14 | ||
14 | return ceph_msg_new(0, pool->front_len); | 15 | p = ceph_msg_new(0, pool->front_len); |
16 | if (!p) | ||
17 | pr_err("msgpool %s alloc failed\n", pool->name); | ||
18 | return p; | ||
15 | } | 19 | } |
16 | 20 | ||
17 | static void free_fn(void *element, void *arg) | 21 | static void free_fn(void *element, void *arg) |
@@ -20,12 +24,13 @@ static void free_fn(void *element, void *arg) | |||
20 | } | 24 | } |
21 | 25 | ||
22 | int ceph_msgpool_init(struct ceph_msgpool *pool, | 26 | int ceph_msgpool_init(struct ceph_msgpool *pool, |
23 | int front_len, int size, bool blocking) | 27 | int front_len, int size, bool blocking, const char *name) |
24 | { | 28 | { |
25 | pool->front_len = front_len; | 29 | pool->front_len = front_len; |
26 | pool->pool = mempool_create(size, alloc_fn, free_fn, pool); | 30 | pool->pool = mempool_create(size, alloc_fn, free_fn, pool); |
27 | if (!pool->pool) | 31 | if (!pool->pool) |
28 | return -ENOMEM; | 32 | return -ENOMEM; |
33 | pool->name = name; | ||
29 | return 0; | 34 | return 0; |
30 | } | 35 | } |
31 | 36 | ||
@@ -38,8 +43,8 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, | |||
38 | int front_len) | 43 | int front_len) |
39 | { | 44 | { |
40 | if (front_len > pool->front_len) { | 45 | if (front_len > pool->front_len) { |
41 | pr_err("msgpool_get pool %p need front %d, pool size is %d\n", | 46 | pr_err("msgpool_get pool %s need front %d, pool size is %d\n", |
42 | pool, front_len, pool->front_len); | 47 | pool->name, front_len, pool->front_len); |
43 | WARN_ON(1); | 48 | WARN_ON(1); |
44 | 49 | ||
45 | /* try to alloc a fresh message */ | 50 | /* try to alloc a fresh message */ |
diff --git a/fs/ceph/msgpool.h b/fs/ceph/msgpool.h index 62a61c7fca08..a362605f9368 100644 --- a/fs/ceph/msgpool.h +++ b/fs/ceph/msgpool.h | |||
@@ -9,12 +9,14 @@ | |||
9 | * avoid unexpected OOM conditions. | 9 | * avoid unexpected OOM conditions. |
10 | */ | 10 | */ |
11 | struct ceph_msgpool { | 11 | struct ceph_msgpool { |
12 | const char *name; | ||
12 | mempool_t *pool; | 13 | mempool_t *pool; |
13 | int front_len; /* preallocated payload size */ | 14 | int front_len; /* preallocated payload size */ |
14 | }; | 15 | }; |
15 | 16 | ||
16 | extern int ceph_msgpool_init(struct ceph_msgpool *pool, | 17 | extern int ceph_msgpool_init(struct ceph_msgpool *pool, |
17 | int front_len, int size, bool blocking); | 18 | int front_len, int size, bool blocking, |
19 | const char *name); | ||
18 | extern void ceph_msgpool_destroy(struct ceph_msgpool *pool); | 20 | extern void ceph_msgpool_destroy(struct ceph_msgpool *pool); |
19 | extern struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *, | 21 | extern struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *, |
20 | int front_len); | 22 | int front_len); |
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c index 97a3a57fe8cd..c0aca732efd3 100644 --- a/fs/ceph/osd_client.c +++ b/fs/ceph/osd_client.c | |||
@@ -1214,11 +1214,13 @@ int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client) | |||
1214 | if (!osdc->req_mempool) | 1214 | if (!osdc->req_mempool) |
1215 | goto out; | 1215 | goto out; |
1216 | 1216 | ||
1217 | err = ceph_msgpool_init(&osdc->msgpool_op, OSD_OP_FRONT_LEN, 10, true); | 1217 | err = ceph_msgpool_init(&osdc->msgpool_op, OSD_OP_FRONT_LEN, 10, true, |
1218 | "osd_op"); | ||
1218 | if (err < 0) | 1219 | if (err < 0) |
1219 | goto out_mempool; | 1220 | goto out_mempool; |
1220 | err = ceph_msgpool_init(&osdc->msgpool_op_reply, | 1221 | err = ceph_msgpool_init(&osdc->msgpool_op_reply, |
1221 | OSD_OPREPLY_FRONT_LEN, 10, true); | 1222 | OSD_OPREPLY_FRONT_LEN, 10, true, |
1223 | "osd_op_reply"); | ||
1222 | if (err < 0) | 1224 | if (err < 0) |
1223 | goto out_msgpool; | 1225 | goto out_msgpool; |
1224 | return 0; | 1226 | return 0; |