Commit 153c8e6b authored by Sage Weil's avatar Sage Weil

ceph: use kref for struct ceph_mds_request

Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent b6c1d5b8
...@@ -400,11 +400,11 @@ static void put_request_session(struct ceph_mds_request *req) ...@@ -400,11 +400,11 @@ static void put_request_session(struct ceph_mds_request *req)
} }
} }
void ceph_mdsc_put_request(struct ceph_mds_request *req) void ceph_mdsc_release_request(struct kref *kref)
{ {
dout("mdsc put_request %p %d -> %d\n", req, struct ceph_mds_request *req = container_of(kref,
atomic_read(&req->r_ref), atomic_read(&req->r_ref)-1); struct ceph_mds_request,
if (atomic_dec_and_test(&req->r_ref)) { r_kref);
if (req->r_request) if (req->r_request)
ceph_msg_put(req->r_request); ceph_msg_put(req->r_request);
if (req->r_reply) { if (req->r_reply) {
...@@ -434,7 +434,6 @@ void ceph_mdsc_put_request(struct ceph_mds_request *req) ...@@ -434,7 +434,6 @@ void ceph_mdsc_put_request(struct ceph_mds_request *req)
put_request_session(req); put_request_session(req);
ceph_unreserve_caps(&req->r_caps_reservation); ceph_unreserve_caps(&req->r_caps_reservation);
kfree(req); kfree(req);
}
} }
/* /*
...@@ -1097,7 +1096,7 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode) ...@@ -1097,7 +1096,7 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode)
req->r_resend_mds = -1; req->r_resend_mds = -1;
INIT_LIST_HEAD(&req->r_unsafe_dir_item); INIT_LIST_HEAD(&req->r_unsafe_dir_item);
req->r_fmode = -1; req->r_fmode = -1;
atomic_set(&req->r_ref, 1); /* one for request_tree, one for caller */ kref_init(&req->r_kref);
INIT_LIST_HEAD(&req->r_wait); INIT_LIST_HEAD(&req->r_wait);
init_completion(&req->r_completion); init_completion(&req->r_completion);
init_completion(&req->r_safe_completion); init_completion(&req->r_safe_completion);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define _FS_CEPH_MDS_CLIENT_H #define _FS_CEPH_MDS_CLIENT_H
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/kref.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/radix-tree.h> #include <linux/radix-tree.h>
...@@ -203,7 +204,7 @@ struct ceph_mds_request { ...@@ -203,7 +204,7 @@ struct ceph_mds_request {
int r_num_stale; int r_num_stale;
int r_resend_mds; /* mds to resend to next, if any*/ int r_resend_mds; /* mds to resend to next, if any*/
atomic_t r_ref; struct kref r_kref;
struct list_head r_wait; struct list_head r_wait;
struct completion r_completion; struct completion r_completion;
struct completion r_safe_completion; struct completion r_safe_completion;
...@@ -306,9 +307,13 @@ extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, ...@@ -306,9 +307,13 @@ extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
struct ceph_mds_request *req); struct ceph_mds_request *req);
static inline void ceph_mdsc_get_request(struct ceph_mds_request *req) static inline void ceph_mdsc_get_request(struct ceph_mds_request *req)
{ {
atomic_inc(&req->r_ref); kref_get(&req->r_kref);
}
extern void ceph_mdsc_release_request(struct kref *kref);
static inline void ceph_mdsc_put_request(struct ceph_mds_request *req)
{
kref_put(&req->r_kref, ceph_mdsc_release_request);
} }
extern void ceph_mdsc_put_request(struct ceph_mds_request *req);
extern void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc); extern void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment