diff options
author | Jeff Layton <jlayton@kernel.org> | 2019-04-02 09:24:36 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2019-05-07 13:22:37 -0400 |
commit | 86bda539fa90184ca404afb38cd015416bf81d15 (patch) | |
tree | dca133d40dbb83dd021cee98ca56ee2c24ea2166 | |
parent | 111c708104506d53bb1845c782cfd98157471e32 (diff) |
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>
-rw-r--r-- | fs/ceph/mds_client.c | 40 | ||||
-rw-r--r-- | fs/ceph/mds_client.h | 5 |
2 files changed, 22 insertions, 23 deletions
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index b451ec761290..ffbb98fdc478 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -2626,14 +2626,27 @@ static void kick_requests(struct ceph_mds_client *mdsc, int mds) | |||
2626 | } | 2626 | } |
2627 | } | 2627 | } |
2628 | 2628 | ||
2629 | void ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, | 2629 | int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, |
2630 | struct ceph_mds_request *req) | 2630 | struct ceph_mds_request *req) |
2631 | { | 2631 | { |
2632 | dout("submit_request on %p\n", req); | 2632 | int err; |
2633 | |||
2634 | /* take CAP_PIN refs for r_inode, r_parent, r_old_dentry */ | ||
2635 | if (req->r_inode) | ||
2636 | ceph_get_cap_refs(ceph_inode(req->r_inode), CEPH_CAP_PIN); | ||
2637 | if (req->r_parent) | ||
2638 | ceph_get_cap_refs(ceph_inode(req->r_parent), CEPH_CAP_PIN); | ||
2639 | if (req->r_old_dentry_dir) | ||
2640 | ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir), | ||
2641 | CEPH_CAP_PIN); | ||
2642 | |||
2643 | dout("submit_request on %p for inode %p\n", req, dir); | ||
2633 | mutex_lock(&mdsc->mutex); | 2644 | mutex_lock(&mdsc->mutex); |
2634 | __register_request(mdsc, req, NULL); | 2645 | __register_request(mdsc, req, dir); |
2635 | __do_request(mdsc, req); | 2646 | __do_request(mdsc, req); |
2647 | err = req->r_err; | ||
2636 | mutex_unlock(&mdsc->mutex); | 2648 | mutex_unlock(&mdsc->mutex); |
2649 | return err; | ||
2637 | } | 2650 | } |
2638 | 2651 | ||
2639 | /* | 2652 | /* |
@@ -2648,27 +2661,12 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, | |||
2648 | 2661 | ||
2649 | dout("do_request on %p\n", req); | 2662 | dout("do_request on %p\n", req); |
2650 | 2663 | ||
2651 | /* take CAP_PIN refs for r_inode, r_parent, r_old_dentry */ | ||
2652 | if (req->r_inode) | ||
2653 | ceph_get_cap_refs(ceph_inode(req->r_inode), CEPH_CAP_PIN); | ||
2654 | if (req->r_parent) | ||
2655 | ceph_get_cap_refs(ceph_inode(req->r_parent), CEPH_CAP_PIN); | ||
2656 | if (req->r_old_dentry_dir) | ||
2657 | ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir), | ||
2658 | CEPH_CAP_PIN); | ||
2659 | |||
2660 | /* issue */ | 2664 | /* issue */ |
2661 | mutex_lock(&mdsc->mutex); | 2665 | err = ceph_mdsc_submit_request(mdsc, dir, req); |
2662 | __register_request(mdsc, req, dir); | 2666 | if (err) |
2663 | __do_request(mdsc, req); | ||
2664 | |||
2665 | if (req->r_err) { | ||
2666 | err = req->r_err; | ||
2667 | goto out; | 2667 | goto out; |
2668 | } | ||
2669 | 2668 | ||
2670 | /* wait */ | 2669 | /* wait */ |
2671 | mutex_unlock(&mdsc->mutex); | ||
2672 | dout("do_request waiting\n"); | 2670 | dout("do_request waiting\n"); |
2673 | if (!req->r_timeout && req->r_wait_for_completion) { | 2671 | if (!req->r_timeout && req->r_wait_for_completion) { |
2674 | err = req->r_wait_for_completion(mdsc, req); | 2672 | err = req->r_wait_for_completion(mdsc, req); |
@@ -2709,8 +2707,8 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, | |||
2709 | err = req->r_err; | 2707 | err = req->r_err; |
2710 | } | 2708 | } |
2711 | 2709 | ||
2712 | out: | ||
2713 | mutex_unlock(&mdsc->mutex); | 2710 | mutex_unlock(&mdsc->mutex); |
2711 | out: | ||
2714 | dout("do_request %p done, result %d\n", req, err); | 2712 | dout("do_request %p done, result %d\n", req, err); |
2715 | return err; | 2713 | return err; |
2716 | } | 2714 | } |
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index ebcad5afc87b..a83f28bc2387 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h | |||
@@ -465,8 +465,9 @@ extern int ceph_alloc_readdir_reply_buffer(struct ceph_mds_request *req, | |||
465 | struct inode *dir); | 465 | struct inode *dir); |
466 | extern struct ceph_mds_request * | 466 | extern struct ceph_mds_request * |
467 | ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode); | 467 | ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode); |
468 | extern void ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, | 468 | extern int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, |
469 | struct ceph_mds_request *req); | 469 | struct inode *dir, |
470 | struct ceph_mds_request *req); | ||
470 | extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, | 471 | extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, |
471 | struct inode *dir, | 472 | struct inode *dir, |
472 | struct ceph_mds_request *req); | 473 | struct ceph_mds_request *req); |