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>
This commit is contained in:
Ilya Dryomov 2014-06-20 14:14:41 +04:00
parent bbf37ec3a6
commit 0215e44bb3
2 changed files with 24 additions and 21 deletions

View file

@ -285,19 +285,9 @@ extern void ceph_msg_data_add_bio(struct ceph_msg *msg, struct bio *bio,
extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags, extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags,
bool can_fail); bool can_fail);
extern void ceph_msg_kfree(struct ceph_msg *m);
extern struct ceph_msg *ceph_msg_get(struct ceph_msg *msg);
static inline struct ceph_msg *ceph_msg_get(struct ceph_msg *msg) extern void ceph_msg_put(struct ceph_msg *msg);
{
kref_get(&msg->kref);
return msg;
}
extern void ceph_msg_last_put(struct kref *kref);
static inline void ceph_msg_put(struct ceph_msg *msg)
{
kref_put(&msg->kref, ceph_msg_last_put);
}
extern void ceph_msg_dump(struct ceph_msg *msg); extern void ceph_msg_dump(struct ceph_msg *msg);

View file

@ -3269,24 +3269,21 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip)
/* /*
* Free a generically kmalloc'd message. * Free a generically kmalloc'd message.
*/ */
void ceph_msg_kfree(struct ceph_msg *m) static void ceph_msg_free(struct ceph_msg *m)
{ {
dout("msg_kfree %p\n", m); dout("%s %p\n", __func__, m);
ceph_kvfree(m->front.iov_base); ceph_kvfree(m->front.iov_base);
kmem_cache_free(ceph_msg_cache, m); kmem_cache_free(ceph_msg_cache, m);
} }
/* static void ceph_msg_release(struct kref *kref)
* Drop a msg ref. Destroy as needed.
*/
void ceph_msg_last_put(struct kref *kref)
{ {
struct ceph_msg *m = container_of(kref, struct ceph_msg, kref); struct ceph_msg *m = container_of(kref, struct ceph_msg, kref);
LIST_HEAD(data); LIST_HEAD(data);
struct list_head *links; struct list_head *links;
struct list_head *next; struct list_head *next;
dout("ceph_msg_put last one on %p\n", m); dout("%s %p\n", __func__, m);
WARN_ON(!list_empty(&m->list_head)); WARN_ON(!list_empty(&m->list_head));
/* drop middle, data, if any */ /* drop middle, data, if any */
@ -3308,9 +3305,25 @@ void ceph_msg_last_put(struct kref *kref)
if (m->pool) if (m->pool)
ceph_msgpool_put(m->pool, m); ceph_msgpool_put(m->pool, m);
else else
ceph_msg_kfree(m); ceph_msg_free(m);
} }
EXPORT_SYMBOL(ceph_msg_last_put);
struct ceph_msg *ceph_msg_get(struct ceph_msg *msg)
{
dout("%s %p (was %d)\n", __func__, msg,
atomic_read(&msg->kref.refcount));
kref_get(&msg->kref);
return msg;
}
EXPORT_SYMBOL(ceph_msg_get);
void ceph_msg_put(struct ceph_msg *msg)
{
dout("%s %p (was %d)\n", __func__, msg,
atomic_read(&msg->kref.refcount));
kref_put(&msg->kref, ceph_msg_release);
}
EXPORT_SYMBOL(ceph_msg_put);
void ceph_msg_dump(struct ceph_msg *msg) void ceph_msg_dump(struct ceph_msg *msg)
{ {