ceph: have ceph_mdsc_do_request call ceph_mdsc_submit_request
Nothing calls ceph_mdsc_submit_request today, but in later patches we'll need to be able to call this separately. Have the helper return an int so we can check the r_err under the mutex, and have the caller just check the error code from the submit. Also move the acquisition of CEPH_CAP_PIN references into the same function. Signed-off-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
111c708104
commit
86bda539fa
|
@ -2626,14 +2626,27 @@ static void kick_requests(struct ceph_mds_client *mdsc, int mds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ceph_mdsc_submit_request(struct ceph_mds_client *mdsc,
|
int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir,
|
||||||
struct ceph_mds_request *req)
|
struct ceph_mds_request *req)
|
||||||
{
|
{
|
||||||
dout("submit_request on %p\n", req);
|
int err;
|
||||||
|
|
||||||
|
/* take CAP_PIN refs for r_inode, r_parent, r_old_dentry */
|
||||||
|
if (req->r_inode)
|
||||||
|
ceph_get_cap_refs(ceph_inode(req->r_inode), CEPH_CAP_PIN);
|
||||||
|
if (req->r_parent)
|
||||||
|
ceph_get_cap_refs(ceph_inode(req->r_parent), CEPH_CAP_PIN);
|
||||||
|
if (req->r_old_dentry_dir)
|
||||||
|
ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
|
||||||
|
CEPH_CAP_PIN);
|
||||||
|
|
||||||
|
dout("submit_request on %p for inode %p\n", req, dir);
|
||||||
mutex_lock(&mdsc->mutex);
|
mutex_lock(&mdsc->mutex);
|
||||||
__register_request(mdsc, req, NULL);
|
__register_request(mdsc, req, dir);
|
||||||
__do_request(mdsc, req);
|
__do_request(mdsc, req);
|
||||||
|
err = req->r_err;
|
||||||
mutex_unlock(&mdsc->mutex);
|
mutex_unlock(&mdsc->mutex);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2648,27 +2661,12 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
|
||||||
|
|
||||||
dout("do_request on %p\n", req);
|
dout("do_request on %p\n", req);
|
||||||
|
|
||||||
/* take CAP_PIN refs for r_inode, r_parent, r_old_dentry */
|
|
||||||
if (req->r_inode)
|
|
||||||
ceph_get_cap_refs(ceph_inode(req->r_inode), CEPH_CAP_PIN);
|
|
||||||
if (req->r_parent)
|
|
||||||
ceph_get_cap_refs(ceph_inode(req->r_parent), CEPH_CAP_PIN);
|
|
||||||
if (req->r_old_dentry_dir)
|
|
||||||
ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
|
|
||||||
CEPH_CAP_PIN);
|
|
||||||
|
|
||||||
/* issue */
|
/* issue */
|
||||||
mutex_lock(&mdsc->mutex);
|
err = ceph_mdsc_submit_request(mdsc, dir, req);
|
||||||
__register_request(mdsc, req, dir);
|
if (err)
|
||||||
__do_request(mdsc, req);
|
|
||||||
|
|
||||||
if (req->r_err) {
|
|
||||||
err = req->r_err;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
/* wait */
|
/* wait */
|
||||||
mutex_unlock(&mdsc->mutex);
|
|
||||||
dout("do_request waiting\n");
|
dout("do_request waiting\n");
|
||||||
if (!req->r_timeout && req->r_wait_for_completion) {
|
if (!req->r_timeout && req->r_wait_for_completion) {
|
||||||
err = req->r_wait_for_completion(mdsc, req);
|
err = req->r_wait_for_completion(mdsc, req);
|
||||||
|
@ -2709,8 +2707,8 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
|
||||||
err = req->r_err;
|
err = req->r_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
mutex_unlock(&mdsc->mutex);
|
mutex_unlock(&mdsc->mutex);
|
||||||
|
out:
|
||||||
dout("do_request %p done, result %d\n", req, err);
|
dout("do_request %p done, result %d\n", req, err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -465,8 +465,9 @@ extern int ceph_alloc_readdir_reply_buffer(struct ceph_mds_request *req,
|
||||||
struct inode *dir);
|
struct inode *dir);
|
||||||
extern struct ceph_mds_request *
|
extern struct ceph_mds_request *
|
||||||
ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode);
|
ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode);
|
||||||
extern void ceph_mdsc_submit_request(struct ceph_mds_client *mdsc,
|
extern int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc,
|
||||||
struct ceph_mds_request *req);
|
struct inode *dir,
|
||||||
|
struct ceph_mds_request *req);
|
||||||
extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
|
extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
|
||||||
struct inode *dir,
|
struct inode *dir,
|
||||||
struct ceph_mds_request *req);
|
struct ceph_mds_request *req);
|
||||||
|
|
Loading…
Reference in New Issue