Skip to content

Commit

Permalink
libceph: initialize data fields on last msg put
Browse files Browse the repository at this point in the history
When the last reference to a ceph message is dropped,
ceph_msg_last_put() is called to clean things up.

For "normal" messages (allocated via ceph_msg_new() rather than
being allocated from a memory pool) it's sufficient to just release
resources.  But for a mempool-allocated message we actually have to
re-initialize the data fields in the message back to initial state
so they're ready to go in the event the message gets reused.

Some of this was already done; this fleshes it out so it's done
more completely.

This resolves:
    http://tracker.ceph.com/issues/4540

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
  • Loading branch information
Alex Elder authored and Sage Weil committed May 2, 2013
1 parent 7e2766a commit 888334f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -3331,12 +3331,17 @@ void ceph_msg_last_put(struct kref *kref)
if (ceph_msg_has_pages(m)) {
m->p.length = 0;
m->p.pages = NULL;
m->p.type = CEPH_OSD_DATA_TYPE_NONE;
}

if (ceph_msg_has_pagelist(m)) {
ceph_pagelist_release(m->l.pagelist);
kfree(m->l.pagelist);
m->l.pagelist = NULL;
m->l.type = CEPH_OSD_DATA_TYPE_NONE;
}
if (ceph_msg_has_bio(m)) {
m->b.bio = NULL;
m->b.type = CEPH_OSD_DATA_TYPE_NONE;
}

if (m->pool)
Expand Down

0 comments on commit 888334f

Please sign in to comment.