diff mbox series

[RFC,09/11] ceph: add refcounting for Lx caps

Message ID 20190409194229.8247-10-jlayton@kernel.org (mailing list archive)
State New, archived
Headers show
Series [RFC,01/11] ceph: after an MDS request, do callback and completions | expand

Commit Message

Jeff Layton April 9, 2019, 7:42 p.m. UTC
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/caps.c  | 7 +++++++
 fs/ceph/inode.c | 1 +
 fs/ceph/super.h | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 6dc96844fdee..d022e15c8378 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -989,6 +989,8 @@  int __ceph_caps_used(struct ceph_inode_info *ci)
 		used |= CEPH_CAP_FILE_BUFFER;
 	if (ci->i_fx_ref)
 		used |= CEPH_CAP_FILE_EXCL;
+	if (ci->i_lx_ref)
+		used |= CEPH_CAP_LINK_EXCL;
 	return used;
 }
 
@@ -2506,6 +2508,8 @@  static void __take_cap_refs(struct ceph_inode_info *ci, int got,
 		ci->i_rdcache_ref++;
 	if (got & CEPH_CAP_FILE_EXCL)
 		ci->i_fx_ref++;
+	if (got & CEPH_CAP_LINK_EXCL)
+		ci->i_lx_ref++;
 	if (got & CEPH_CAP_FILE_WR) {
 		if (ci->i_wr_ref == 0 && !ci->i_head_snapc) {
 			BUG_ON(!snap_rwsem_locked);
@@ -2872,6 +2876,9 @@  void ceph_put_cap_refs(struct ceph_inode_info *ci, int had)
 	if (had & CEPH_CAP_FILE_EXCL)
 		if (--ci->i_fx_ref == 0)
 			last++;
+	if (had & CEPH_CAP_LINK_EXCL)
+		if (--ci->i_lx_ref == 0)
+			last++;
 	if (had & CEPH_CAP_FILE_BUFFER) {
 		if (--ci->i_wb_ref == 0) {
 			last++;
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 2a5b22985699..a7385ce4500b 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -495,6 +495,7 @@  struct inode *ceph_alloc_inode(struct super_block *sb)
 	ci->i_wr_ref = 0;
 	ci->i_wb_ref = 0;
 	ci->i_fx_ref = 0;
+	ci->i_lx_ref = 0;
 	ci->i_wrbuffer_ref = 0;
 	ci->i_wrbuffer_ref_head = 0;
 	atomic_set(&ci->i_filelock_ref, 0);
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 03cbb80faab1..3c5608f2108a 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -368,7 +368,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, i_fx_ref;
+	int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wb_ref, i_fx_ref, i_lx_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 */