aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/osd_client.c
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2009-12-07 16:37:03 -0500
committerSage Weil <sage@newdream.net>2009-12-07 16:37:03 -0500
commit415e49a9c4faf1a1480b1497da2037608e5aa2c5 (patch)
tree6c376396878b506f46e6cc57e108524916554842 /fs/ceph/osd_client.c
parent153c8e6bf7ffee561e046e60b26ef6486c6fc9f2 (diff)
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.c37
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,
77/* 77/*
78 * requests 78 * requests
79 */ 79 */
80void ceph_osdc_put_request(struct ceph_osd_request *req) 80void ceph_osdc_release_request(struct kref *kref)
81{ 81{
82 dout("osdc put_request %p %d -> %d\n", req, atomic_read(&req->r_ref), 82 struct ceph_osd_request *req = container_of(kref,
83 atomic_read(&req->r_ref)-1); 83 struct ceph_osd_request,
84 BUG_ON(atomic_read(&req->r_ref) <= 0); 84 r_kref);
85 if (atomic_dec_and_test(&req->r_ref)) { 85
86 if (req->r_request) 86 if (req->r_request)
87 ceph_msg_put(req->r_request); 87 ceph_msg_put(req->r_request);
88 if (req->r_reply) 88 if (req->r_reply)
89 ceph_msg_put(req->r_reply); 89 ceph_msg_put(req->r_reply);
90 if (req->r_own_pages) 90 if (req->r_own_pages)
91 ceph_release_page_vector(req->r_pages, 91 ceph_release_page_vector(req->r_pages,
92 req->r_num_pages); 92 req->r_num_pages);
93 ceph_put_snap_context(req->r_snapc); 93 ceph_put_snap_context(req->r_snapc);
94 if (req->r_mempool) 94 if (req->r_mempool)
95 mempool_free(req, req->r_osdc->req_mempool); 95 mempool_free(req, req->r_osdc->req_mempool);
96 else 96 else
97 kfree(req); 97 kfree(req);
98 }
99} 98}
100 99
101/* 100/*
@@ -149,7 +148,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
149 148
150 req->r_osdc = osdc; 149 req->r_osdc = osdc;
151 req->r_mempool = use_mempool; 150 req->r_mempool = use_mempool;
152 atomic_set(&req->r_ref, 1); 151 kref_init(&req->r_kref);
153 init_completion(&req->r_completion); 152 init_completion(&req->r_completion);
154 init_completion(&req->r_safe_completion); 153 init_completion(&req->r_safe_completion);
155 INIT_LIST_HEAD(&req->r_unsafe_item); 154 INIT_LIST_HEAD(&req->r_unsafe_item);