diff options
author | Sage Weil <sage@newdream.net> | 2009-12-07 15:31:09 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-12-07 15:31:09 -0500 |
commit | 153c8e6bf7ffee561e046e60b26ef6486c6fc9f2 (patch) | |
tree | 7af83c22a7599e011b7802e732fcc6a090fed65e | |
parent | b6c1d5b81ea0841ae9d3ce2cda319ab986b081cf (diff) |
ceph: use kref for struct ceph_mds_request
Signed-off-by: Sage Weil <sage@newdream.net>
-rw-r--r-- | fs/ceph/mds_client.c | 69 | ||||
-rw-r--r-- | fs/ceph/mds_client.h | 11 |
2 files changed, 42 insertions, 38 deletions
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 7da836909abb..739093f281d0 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -400,41 +400,40 @@ static void put_request_session(struct ceph_mds_request *req) | |||
400 | } | 400 | } |
401 | } | 401 | } |
402 | 402 | ||
403 | void ceph_mdsc_put_request(struct ceph_mds_request *req) | 403 | void ceph_mdsc_release_request(struct kref *kref) |
404 | { | 404 | { |
405 | dout("mdsc put_request %p %d -> %d\n", req, | 405 | struct ceph_mds_request *req = container_of(kref, |
406 | atomic_read(&req->r_ref), atomic_read(&req->r_ref)-1); | 406 | struct ceph_mds_request, |
407 | if (atomic_dec_and_test(&req->r_ref)) { | 407 | r_kref); |
408 | if (req->r_request) | 408 | if (req->r_request) |
409 | ceph_msg_put(req->r_request); | 409 | ceph_msg_put(req->r_request); |
410 | if (req->r_reply) { | 410 | if (req->r_reply) { |
411 | ceph_msg_put(req->r_reply); | 411 | ceph_msg_put(req->r_reply); |
412 | destroy_reply_info(&req->r_reply_info); | 412 | destroy_reply_info(&req->r_reply_info); |
413 | } | 413 | } |
414 | if (req->r_inode) { | 414 | if (req->r_inode) { |
415 | ceph_put_cap_refs(ceph_inode(req->r_inode), | 415 | ceph_put_cap_refs(ceph_inode(req->r_inode), |
416 | CEPH_CAP_PIN); | 416 | CEPH_CAP_PIN); |
417 | iput(req->r_inode); | 417 | iput(req->r_inode); |
418 | } | 418 | } |
419 | if (req->r_locked_dir) | 419 | if (req->r_locked_dir) |
420 | ceph_put_cap_refs(ceph_inode(req->r_locked_dir), | 420 | ceph_put_cap_refs(ceph_inode(req->r_locked_dir), |
421 | CEPH_CAP_PIN); | 421 | CEPH_CAP_PIN); |
422 | if (req->r_target_inode) | 422 | if (req->r_target_inode) |
423 | iput(req->r_target_inode); | 423 | iput(req->r_target_inode); |
424 | if (req->r_dentry) | 424 | if (req->r_dentry) |
425 | dput(req->r_dentry); | 425 | dput(req->r_dentry); |
426 | if (req->r_old_dentry) { | 426 | if (req->r_old_dentry) { |
427 | ceph_put_cap_refs( | 427 | ceph_put_cap_refs( |
428 | ceph_inode(req->r_old_dentry->d_parent->d_inode), | 428 | ceph_inode(req->r_old_dentry->d_parent->d_inode), |
429 | CEPH_CAP_PIN); | 429 | CEPH_CAP_PIN); |
430 | dput(req->r_old_dentry); | 430 | dput(req->r_old_dentry); |
431 | } | ||
432 | kfree(req->r_path1); | ||
433 | kfree(req->r_path2); | ||
434 | put_request_session(req); | ||
435 | ceph_unreserve_caps(&req->r_caps_reservation); | ||
436 | kfree(req); | ||
437 | } | 431 | } |
432 | kfree(req->r_path1); | ||
433 | kfree(req->r_path2); | ||
434 | put_request_session(req); | ||
435 | ceph_unreserve_caps(&req->r_caps_reservation); | ||
436 | kfree(req); | ||
438 | } | 437 | } |
439 | 438 | ||
440 | /* | 439 | /* |
@@ -1097,7 +1096,7 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode) | |||
1097 | req->r_resend_mds = -1; | 1096 | req->r_resend_mds = -1; |
1098 | INIT_LIST_HEAD(&req->r_unsafe_dir_item); | 1097 | INIT_LIST_HEAD(&req->r_unsafe_dir_item); |
1099 | req->r_fmode = -1; | 1098 | req->r_fmode = -1; |
1100 | atomic_set(&req->r_ref, 1); /* one for request_tree, one for caller */ | 1099 | kref_init(&req->r_kref); |
1101 | INIT_LIST_HEAD(&req->r_wait); | 1100 | INIT_LIST_HEAD(&req->r_wait); |
1102 | init_completion(&req->r_completion); | 1101 | init_completion(&req->r_completion); |
1103 | init_completion(&req->r_safe_completion); | 1102 | init_completion(&req->r_safe_completion); |
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index 9faa1b2f79a7..41af5ca316e6 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define _FS_CEPH_MDS_CLIENT_H | 2 | #define _FS_CEPH_MDS_CLIENT_H |
3 | 3 | ||
4 | #include <linux/completion.h> | 4 | #include <linux/completion.h> |
5 | #include <linux/kref.h> | ||
5 | #include <linux/list.h> | 6 | #include <linux/list.h> |
6 | #include <linux/mutex.h> | 7 | #include <linux/mutex.h> |
7 | #include <linux/radix-tree.h> | 8 | #include <linux/radix-tree.h> |
@@ -203,7 +204,7 @@ struct ceph_mds_request { | |||
203 | int r_num_stale; | 204 | int r_num_stale; |
204 | int r_resend_mds; /* mds to resend to next, if any*/ | 205 | int r_resend_mds; /* mds to resend to next, if any*/ |
205 | 206 | ||
206 | atomic_t r_ref; | 207 | struct kref r_kref; |
207 | struct list_head r_wait; | 208 | struct list_head r_wait; |
208 | struct completion r_completion; | 209 | struct completion r_completion; |
209 | struct completion r_safe_completion; | 210 | struct completion r_safe_completion; |
@@ -306,9 +307,13 @@ extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, | |||
306 | struct ceph_mds_request *req); | 307 | struct ceph_mds_request *req); |
307 | static inline void ceph_mdsc_get_request(struct ceph_mds_request *req) | 308 | static inline void ceph_mdsc_get_request(struct ceph_mds_request *req) |
308 | { | 309 | { |
309 | atomic_inc(&req->r_ref); | 310 | kref_get(&req->r_kref); |
311 | } | ||
312 | extern void ceph_mdsc_release_request(struct kref *kref); | ||
313 | static inline void ceph_mdsc_put_request(struct ceph_mds_request *req) | ||
314 | { | ||
315 | kref_put(&req->r_kref, ceph_mdsc_release_request); | ||
310 | } | 316 | } |
311 | extern void ceph_mdsc_put_request(struct ceph_mds_request *req); | ||
312 | 317 | ||
313 | extern void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc); | 318 | extern void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc); |
314 | 319 | ||