Skip to content

Commit 0215e44

Browse files
committed
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>
1 parent bbf37ec commit 0215e44

2 files changed

Lines changed: 24 additions & 21 deletions

File tree

‎include/linux/ceph/messenger.h‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,19 +285,9 @@ extern void ceph_msg_data_add_bio(struct ceph_msg *msg, struct bio *bio,
285285

286286
extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags,
287287
bool can_fail);
288-
extern void ceph_msg_kfree(struct ceph_msg *m);
289288

290-
291-
static inline struct ceph_msg *ceph_msg_get(struct ceph_msg *msg)
292-
{
293-
kref_get(&msg->kref);
294-
return msg;
295-
}
296-
extern void ceph_msg_last_put(struct kref *kref);
297-
static inline void ceph_msg_put(struct ceph_msg *msg)
298-
{
299-
kref_put(&msg->kref, ceph_msg_last_put);
300-
}
289+
extern struct ceph_msg *ceph_msg_get(struct ceph_msg *msg);
290+
extern void ceph_msg_put(struct ceph_msg *msg);
301291

302292
extern void ceph_msg_dump(struct ceph_msg *msg);
303293

‎net/ceph/messenger.c‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,24 +3269,21 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip)
32693269
/*
32703270
* Free a generically kmalloc'd message.
32713271
*/
3272-
void ceph_msg_kfree(struct ceph_msg *m)
3272+
static void ceph_msg_free(struct ceph_msg *m)
32733273
{
3274-
dout("msg_kfree %p\n", m);
3274+
dout("%s %p\n", __func__, m);
32753275
ceph_kvfree(m->front.iov_base);
32763276
kmem_cache_free(ceph_msg_cache, m);
32773277
}
32783278

3279-
/*
3280-
* Drop a msg ref. Destroy as needed.
3281-
*/
3282-
void ceph_msg_last_put(struct kref *kref)
3279+
static void ceph_msg_release(struct kref *kref)
32833280
{
32843281
struct ceph_msg *m = container_of(kref, struct ceph_msg, kref);
32853282
LIST_HEAD(data);
32863283
struct list_head *links;
32873284
struct list_head *next;
32883285

3289-
dout("ceph_msg_put last one on %p\n", m);
3286+
dout("%s %p\n", __func__, m);
32903287
WARN_ON(!list_empty(&m->list_head));
32913288

32923289
/* drop middle, data, if any */
@@ -3308,9 +3305,25 @@ void ceph_msg_last_put(struct kref *kref)
33083305
if (m->pool)
33093306
ceph_msgpool_put(m->pool, m);
33103307
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);
33123325
}
3313-
EXPORT_SYMBOL(ceph_msg_last_put);
3326+
EXPORT_SYMBOL(ceph_msg_put);
33143327

33153328
void ceph_msg_dump(struct ceph_msg *msg)
33163329
{

0 commit comments

Comments
 (0)