ceph: add non-blocking parameter to ceph_try_get_caps()
authorLuis Henriques <lhenriques@suse.com>
Mon, 15 Oct 2018 15:45:57 +0000 (16:45 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 22 Oct 2018 08:28:23 +0000 (10:28 +0200)
ceph_try_get_caps currently calls try_get_cap_refs with the nonblock
parameter always set to 'true'.  This change adds a new parameter that
allows to set it's value.  This will be useful for a follow-up patch that
will need to get two sets of capabilities for two different inodes without
risking a deadlock.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/addr.c
fs/ceph/caps.c
fs/ceph/super.h

index 9c332a6f66678a04cfe4b6cf05a33253c85f30f5..8eade7a993c1f5f120908849a38a0c80537cf505 100644 (file)
@@ -322,7 +322,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,
                /* caller of readpages does not hold buffer and read caps
                 * (fadvise, madvise and readahead cases) */
                int want = CEPH_CAP_FILE_CACHE;
-               ret = ceph_try_get_caps(ci, CEPH_CAP_FILE_RD, want, &got);
+               ret = ceph_try_get_caps(ci, CEPH_CAP_FILE_RD, want, true, &got);
                if (ret < 0) {
                        dout("start_read %p, error getting cap\n", inode);
                } else if (!(got & want)) {
index f36946fdfb0073771e7c5d7d9c6d36a9816f2f59..f3496db4bb3e80d24adec6413168b20299321439 100644 (file)
@@ -2673,17 +2673,18 @@ static void check_max_size(struct inode *inode, loff_t endoff)
                ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL);
 }
 
-int ceph_try_get_caps(struct ceph_inode_info *ci, int need, int want, int *got)
+int ceph_try_get_caps(struct ceph_inode_info *ci, int need, int want,
+                     bool nonblock, int *got)
 {
        int ret, err = 0;
 
        BUG_ON(need & ~CEPH_CAP_FILE_RD);
-       BUG_ON(want & ~(CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO));
+       BUG_ON(want & ~(CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO|CEPH_CAP_FILE_SHARED));
        ret = ceph_pool_perm_check(ci, need);
        if (ret < 0)
                return ret;
 
-       ret = try_get_cap_refs(ci, need, want, 0, true, got, &err);
+       ret = try_get_cap_refs(ci, need, want, 0, nonblock, got, &err);
        if (ret) {
                if (err == -EAGAIN) {
                        ret = 0;
index 582e28fd1b7bf1c6bda93b4796eb92cc4883fdd2..91b13400badd42c8d7d650bed17fc0dbc5884138 100644 (file)
@@ -1008,7 +1008,7 @@ extern int ceph_encode_dentry_release(void **p, struct dentry *dn,
 extern int ceph_get_caps(struct ceph_inode_info *ci, int need, int want,
                         loff_t endoff, int *got, struct page **pinned_page);
 extern int ceph_try_get_caps(struct ceph_inode_info *ci,
-                            int need, int want, int *got);
+                            int need, int want, bool nonblock, int *got);
 
 /* for counting open files by mode */
 extern void __ceph_get_fmode(struct ceph_inode_info *ci, int mode);