diff options
author | Ilya Dryomov <ilya.dryomov@inktank.com> | 2014-06-20 06:14:41 -0400 |
---|---|---|
committer | Ilya Dryomov <ilya.dryomov@inktank.com> | 2014-07-08 07:08:43 -0400 |
commit | 0215e44bb390a968d01404aa2f35af56f9b55fc8 (patch) | |
tree | 2c9004d85bd441215659841838cc992043e7878c /net/ceph/messenger.c | |
parent | bbf37ec3a668a983f88b069ec2b7a1781c428eb5 (diff) |
libceph: move and add dout()s to ceph_msg_{get,put}()
Add dout()s to ceph_msg_{get,put}(). Also move them to .c and turn
kref release callback into a static function.
Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Diffstat (limited to 'net/ceph/messenger.c')
-rw-r--r-- | net/ceph/messenger.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 1948d592aa54..8bffa5b90fef 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -3269,24 +3269,21 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip) | |||
3269 | /* | 3269 | /* |
3270 | * Free a generically kmalloc'd message. | 3270 | * Free a generically kmalloc'd message. |
3271 | */ | 3271 | */ |
3272 | void ceph_msg_kfree(struct ceph_msg *m) | 3272 | static void ceph_msg_free(struct ceph_msg *m) |
3273 | { | 3273 | { |
3274 | dout("msg_kfree %p\n", m); | 3274 | dout("%s %p\n", __func__, m); |
3275 | ceph_kvfree(m->front.iov_base); | 3275 | ceph_kvfree(m->front.iov_base); |
3276 | kmem_cache_free(ceph_msg_cache, m); | 3276 | kmem_cache_free(ceph_msg_cache, m); |
3277 | } | 3277 | } |
3278 | 3278 | ||
3279 | /* | 3279 | static void ceph_msg_release(struct kref *kref) |
3280 | * Drop a msg ref. Destroy as needed. | ||
3281 | */ | ||
3282 | void ceph_msg_last_put(struct kref *kref) | ||
3283 | { | 3280 | { |
3284 | struct ceph_msg *m = container_of(kref, struct ceph_msg, kref); | 3281 | struct ceph_msg *m = container_of(kref, struct ceph_msg, kref); |
3285 | LIST_HEAD(data); | 3282 | LIST_HEAD(data); |
3286 | struct list_head *links; | 3283 | struct list_head *links; |
3287 | struct list_head *next; | 3284 | struct list_head *next; |
3288 | 3285 | ||
3289 | dout("ceph_msg_put last one on %p\n", m); | 3286 | dout("%s %p\n", __func__, m); |
3290 | WARN_ON(!list_empty(&m->list_head)); | 3287 | WARN_ON(!list_empty(&m->list_head)); |
3291 | 3288 | ||
3292 | /* drop middle, data, if any */ | 3289 | /* drop middle, data, if any */ |
@@ -3308,9 +3305,25 @@ void ceph_msg_last_put(struct kref *kref) | |||
3308 | if (m->pool) | 3305 | if (m->pool) |
3309 | ceph_msgpool_put(m->pool, m); | 3306 | ceph_msgpool_put(m->pool, m); |
3310 | else | 3307 | else |
3311 | ceph_msg_kfree(m); | 3308 | ceph_msg_free(m); |
3309 | } | ||
3310 | |||
3311 | struct ceph_msg *ceph_msg_get(struct ceph_msg *msg) | ||
3312 | { | ||
3313 | dout("%s %p (was %d)\n", __func__, msg, | ||
3314 | atomic_read(&msg->kref.refcount)); | ||
3315 | kref_get(&msg->kref); | ||
3316 | return msg; | ||
3317 | } | ||
3318 | EXPORT_SYMBOL(ceph_msg_get); | ||
3319 | |||
3320 | void ceph_msg_put(struct ceph_msg *msg) | ||
3321 | { | ||
3322 | dout("%s %p (was %d)\n", __func__, msg, | ||
3323 | atomic_read(&msg->kref.refcount)); | ||
3324 | kref_put(&msg->kref, ceph_msg_release); | ||
3312 | } | 3325 | } |
3313 | EXPORT_SYMBOL(ceph_msg_last_put); | 3326 | EXPORT_SYMBOL(ceph_msg_put); |
3314 | 3327 | ||
3315 | void ceph_msg_dump(struct ceph_msg *msg) | 3328 | void ceph_msg_dump(struct ceph_msg *msg) |
3316 | { | 3329 | { |