ceph: add refcounting for Fx caps
authorJeff Layton <jlayton@kernel.org>
Tue, 2 Apr 2019 12:04:30 +0000 (08:04 -0400)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 30 Mar 2020 10:42:40 +0000 (12:42 +0200)
In future patches we'll be taking and relying on Fx caps. Add proper
refcounting for them.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/caps.c
fs/ceph/inode.c
fs/ceph/super.h

index 28ae0c1..1a17f19 100644 (file)
@@ -965,6 +965,8 @@ int __ceph_caps_used(struct ceph_inode_info *ci)
                used |= CEPH_CAP_FILE_WR;
        if (ci->i_wb_ref || ci->i_wrbuffer_ref)
                used |= CEPH_CAP_FILE_BUFFER;
+       if (ci->i_fx_ref)
+               used |= CEPH_CAP_FILE_EXCL;
        return used;
 }
 
@@ -2500,6 +2502,8 @@ static void __take_cap_refs(struct ceph_inode_info *ci, int got,
                ci->i_rd_ref++;
        if (got & CEPH_CAP_FILE_CACHE)
                ci->i_rdcache_ref++;
+       if (got & CEPH_CAP_FILE_EXCL)
+               ci->i_fx_ref++;
        if (got & CEPH_CAP_FILE_WR) {
                if (ci->i_wr_ref == 0 && !ci->i_head_snapc) {
                        BUG_ON(!snap_rwsem_locked);
@@ -2911,6 +2915,9 @@ void ceph_put_cap_refs(struct ceph_inode_info *ci, int had)
        if (had & CEPH_CAP_FILE_CACHE)
                if (--ci->i_rdcache_ref == 0)
                        last++;
+       if (had & CEPH_CAP_FILE_EXCL)
+               if (--ci->i_fx_ref == 0)
+                       last++;
        if (had & CEPH_CAP_FILE_BUFFER) {
                if (--ci->i_wb_ref == 0) {
                        last++;
index d01710a..094b8fc 100644 (file)
@@ -496,6 +496,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
        ci->i_rdcache_ref = 0;
        ci->i_wr_ref = 0;
        ci->i_wb_ref = 0;
+       ci->i_fx_ref = 0;
        ci->i_wrbuffer_ref = 0;
        ci->i_wrbuffer_ref_head = 0;
        atomic_set(&ci->i_filelock_ref, 0);
index 037cdfb..2eee34b 100644 (file)
@@ -375,7 +375,7 @@ struct ceph_inode_info {
 
        /* held references to caps */
        int i_pin_ref;
-       int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wb_ref;
+       int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wb_ref, i_fx_ref;
        int i_wrbuffer_ref, i_wrbuffer_ref_head;
        atomic_t i_filelock_ref;
        atomic_t i_shared_gen;       /* increment each time we get FILE_SHARED */