diff options
author | Sage Weil <sage@newdream.net> | 2009-12-07 13:37:03 -0800 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-12-07 13:37:03 -0800 |
commit | 415e49a9c4faf1a1480b1497da2037608e5aa2c5 (patch) | |
tree | 6c376396878b506f46e6cc57e108524916554842 /fs/ceph/osd_client.c | |
parent | 153c8e6bf7ffee561e046e60b26ef6486c6fc9f2 (diff) | |
download | blackbird-obmc-linux-415e49a9c4faf1a1480b1497da2037608e5aa2c5.tar.gz blackbird-obmc-linux-415e49a9c4faf1a1480b1497da2037608e5aa2c5.zip |
ceph: use kref for ceph_osd_request
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/osd_client.c')
-rw-r--r-- | fs/ceph/osd_client.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c index d639c74e749f..67ef8ab06af4 100644 --- a/fs/ceph/osd_client.c +++ b/fs/ceph/osd_client.c @@ -77,25 +77,24 @@ static void calc_layout(struct ceph_osd_client *osdc, /* * requests */ -void ceph_osdc_put_request(struct ceph_osd_request *req) +void ceph_osdc_release_request(struct kref *kref) { - dout("osdc put_request %p %d -> %d\n", req, atomic_read(&req->r_ref), - atomic_read(&req->r_ref)-1); - BUG_ON(atomic_read(&req->r_ref) <= 0); - if (atomic_dec_and_test(&req->r_ref)) { - if (req->r_request) - ceph_msg_put(req->r_request); - if (req->r_reply) - ceph_msg_put(req->r_reply); - if (req->r_own_pages) - ceph_release_page_vector(req->r_pages, - req->r_num_pages); - ceph_put_snap_context(req->r_snapc); - if (req->r_mempool) - mempool_free(req, req->r_osdc->req_mempool); - else - kfree(req); - } + struct ceph_osd_request *req = container_of(kref, + struct ceph_osd_request, + r_kref); + + if (req->r_request) + ceph_msg_put(req->r_request); + if (req->r_reply) + ceph_msg_put(req->r_reply); + if (req->r_own_pages) + ceph_release_page_vector(req->r_pages, + req->r_num_pages); + ceph_put_snap_context(req->r_snapc); + if (req->r_mempool) + mempool_free(req, req->r_osdc->req_mempool); + else + kfree(req); } /* @@ -149,7 +148,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, req->r_osdc = osdc; req->r_mempool = use_mempool; - atomic_set(&req->r_ref, 1); + kref_init(&req->r_kref); init_completion(&req->r_completion); init_completion(&req->r_safe_completion); INIT_LIST_HEAD(&req->r_unsafe_item); |