diff options
author | Sage Weil <sage@newdream.net> | 2009-12-07 16:37:03 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-12-07 16:37:03 -0500 |
commit | 415e49a9c4faf1a1480b1497da2037608e5aa2c5 (patch) | |
tree | 6c376396878b506f46e6cc57e108524916554842 /fs/ceph | |
parent | 153c8e6bf7ffee561e046e60b26ef6486c6fc9f2 (diff) |
ceph: use kref for ceph_osd_request
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/osd_client.c | 37 | ||||
-rw-r--r-- | fs/ceph/osd_client.h | 11 |
2 files changed, 26 insertions, 22 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 | */ |
80 | void ceph_osdc_put_request(struct ceph_osd_request *req) | 80 | void 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); |
diff --git a/fs/ceph/osd_client.h b/fs/ceph/osd_client.h index 3d4ae6595aaa..20ee61847416 100644 --- a/fs/ceph/osd_client.h +++ b/fs/ceph/osd_client.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define _FS_CEPH_OSD_CLIENT_H | 2 | #define _FS_CEPH_OSD_CLIENT_H |
3 | 3 | ||
4 | #include <linux/completion.h> | 4 | #include <linux/completion.h> |
5 | #include <linux/kref.h> | ||
5 | #include <linux/mempool.h> | 6 | #include <linux/mempool.h> |
6 | #include <linux/rbtree.h> | 7 | #include <linux/rbtree.h> |
7 | 8 | ||
@@ -49,7 +50,7 @@ struct ceph_osd_request { | |||
49 | int r_prepared_pages, r_got_reply; | 50 | int r_prepared_pages, r_got_reply; |
50 | 51 | ||
51 | struct ceph_osd_client *r_osdc; | 52 | struct ceph_osd_client *r_osdc; |
52 | atomic_t r_ref; | 53 | struct kref r_kref; |
53 | bool r_mempool; | 54 | bool r_mempool; |
54 | struct completion r_completion, r_safe_completion; | 55 | struct completion r_completion, r_safe_completion; |
55 | ceph_osdc_callback_t r_callback, r_safe_callback; | 56 | ceph_osdc_callback_t r_callback, r_safe_callback; |
@@ -118,9 +119,13 @@ extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *, | |||
118 | 119 | ||
119 | static inline void ceph_osdc_get_request(struct ceph_osd_request *req) | 120 | static inline void ceph_osdc_get_request(struct ceph_osd_request *req) |
120 | { | 121 | { |
121 | atomic_inc(&req->r_ref); | 122 | kref_get(&req->r_kref); |
123 | } | ||
124 | extern void ceph_osdc_release_request(struct kref *kref); | ||
125 | static inline void ceph_osdc_put_request(struct ceph_osd_request *req) | ||
126 | { | ||
127 | kref_put(&req->r_kref, ceph_osdc_release_request); | ||
122 | } | 128 | } |
123 | extern void ceph_osdc_put_request(struct ceph_osd_request *req); | ||
124 | 129 | ||
125 | extern int ceph_osdc_start_request(struct ceph_osd_client *osdc, | 130 | extern int ceph_osdc_start_request(struct ceph_osd_client *osdc, |
126 | struct ceph_osd_request *req, | 131 | struct ceph_osd_request *req, |