diff options
author | Sage Weil <sage@newdream.net> | 2009-10-14 20:36:07 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-10-15 21:14:43 -0400 |
commit | 8f3bc053c610826a657714649ea596f07875db2e (patch) | |
tree | 97823cb2a202439bb9f9839e2d326ac95d728dd0 /fs/ceph/msgpool.c | |
parent | 07bd10fb9853a41a7f0bb271721cca97d15eccae (diff) |
ceph: warn on allocation from msgpool with larger front_len
Pass the front_len we need when pulling a message off a msgpool,
and WARN if it is greater than the pool's size. Then try to
allocate a new message (to continue without failing).
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/msgpool.c')
-rw-r--r-- | fs/ceph/msgpool.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/fs/ceph/msgpool.c b/fs/ceph/msgpool.c index 39d4d7ed82ce..7599b3382076 100644 --- a/fs/ceph/msgpool.c +++ b/fs/ceph/msgpool.c | |||
@@ -101,14 +101,28 @@ int ceph_msgpool_resv(struct ceph_msgpool *pool, int delta) | |||
101 | return ret; | 101 | return ret; |
102 | } | 102 | } |
103 | 103 | ||
104 | struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool) | 104 | struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, int front_len) |
105 | { | 105 | { |
106 | wait_queue_t wait; | 106 | wait_queue_t wait; |
107 | struct ceph_msg *msg; | 107 | struct ceph_msg *msg; |
108 | 108 | ||
109 | if (front_len && front_len > pool->front_len) { | ||
110 | pr_err("msgpool_get pool %p need front %d, pool size is %d\n", | ||
111 | pool, front_len, pool->front_len); | ||
112 | WARN_ON(1); | ||
113 | |||
114 | /* try to alloc a fresh message */ | ||
115 | msg = ceph_msg_new(0, front_len, 0, 0, NULL); | ||
116 | if (!IS_ERR(msg)) | ||
117 | return msg; | ||
118 | } | ||
119 | |||
120 | if (!front_len) | ||
121 | front_len = pool->front_len; | ||
122 | |||
109 | if (pool->blocking) { | 123 | if (pool->blocking) { |
110 | /* mempool_t behavior; first try to alloc */ | 124 | /* mempool_t behavior; first try to alloc */ |
111 | msg = ceph_msg_new(0, pool->front_len, 0, 0, NULL); | 125 | msg = ceph_msg_new(0, front_len, 0, 0, NULL); |
112 | if (!IS_ERR(msg)) | 126 | if (!IS_ERR(msg)) |
113 | return msg; | 127 | return msg; |
114 | } | 128 | } |
@@ -133,7 +147,7 @@ struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool) | |||
133 | WARN_ON(1); | 147 | WARN_ON(1); |
134 | 148 | ||
135 | /* maybe we can allocate it now? */ | 149 | /* maybe we can allocate it now? */ |
136 | msg = ceph_msg_new(0, pool->front_len, 0, 0, NULL); | 150 | msg = ceph_msg_new(0, front_len, 0, 0, NULL); |
137 | if (!IS_ERR(msg)) | 151 | if (!IS_ERR(msg)) |
138 | return msg; | 152 | return msg; |
139 | 153 | ||