Skip to content

Commit f85122a

Browse files
jtlaytonidryomov
authored andcommitted
ceph: add refcounting for Fx caps
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>
1 parent 3db0a2f commit f85122a

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎fs/ceph/caps.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,8 @@ int __ceph_caps_used(struct ceph_inode_info *ci)
965965
used |= CEPH_CAP_FILE_WR;
966966
if (ci->i_wb_ref || ci->i_wrbuffer_ref)
967967
used |= CEPH_CAP_FILE_BUFFER;
968+
if (ci->i_fx_ref)
969+
used |= CEPH_CAP_FILE_EXCL;
968970
return used;
969971
}
970972

@@ -2500,6 +2502,8 @@ static void __take_cap_refs(struct ceph_inode_info *ci, int got,
25002502
ci->i_rd_ref++;
25012503
if (got & CEPH_CAP_FILE_CACHE)
25022504
ci->i_rdcache_ref++;
2505+
if (got & CEPH_CAP_FILE_EXCL)
2506+
ci->i_fx_ref++;
25032507
if (got & CEPH_CAP_FILE_WR) {
25042508
if (ci->i_wr_ref == 0 && !ci->i_head_snapc) {
25052509
BUG_ON(!snap_rwsem_locked);
@@ -2911,6 +2915,9 @@ void ceph_put_cap_refs(struct ceph_inode_info *ci, int had)
29112915
if (had & CEPH_CAP_FILE_CACHE)
29122916
if (--ci->i_rdcache_ref == 0)
29132917
last++;
2918+
if (had & CEPH_CAP_FILE_EXCL)
2919+
if (--ci->i_fx_ref == 0)
2920+
last++;
29142921
if (had & CEPH_CAP_FILE_BUFFER) {
29152922
if (--ci->i_wb_ref == 0) {
29162923
last++;

‎fs/ceph/inode.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
496496
ci->i_rdcache_ref = 0;
497497
ci->i_wr_ref = 0;
498498
ci->i_wb_ref = 0;
499+
ci->i_fx_ref = 0;
499500
ci->i_wrbuffer_ref = 0;
500501
ci->i_wrbuffer_ref_head = 0;
501502
atomic_set(&ci->i_filelock_ref, 0);

‎fs/ceph/super.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ struct ceph_inode_info {
375375

376376
/* held references to caps */
377377
int i_pin_ref;
378-
int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wb_ref;
378+
int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wb_ref, i_fx_ref;
379379
int i_wrbuffer_ref, i_wrbuffer_ref_head;
380380
atomic_t i_filelock_ref;
381381
atomic_t i_shared_gen; /* increment each time we get FILE_SHARED */

0 commit comments

Comments
 (0)