浏览代码

ceph: fix cache revoke race

handle following sequence of events:

- non-auth MDS revokes Fc cap. queue invalidate work
- auth MDS issues Fc cap through request reply. i_rdcache_gen gets
  increased.
- invalidate work runs. it finds i_rdcache_revoking != i_rdcache_gen,
  so it does nothing.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Yan, Zheng 11 年之前
父节点
当前提交
9563f88c1f
共有 3 个文件被更改,包括 8 次插入4 次删除
  1. 1 1
      fs/ceph/caps.c
  2. 5 3
      fs/ceph/inode.c
  3. 2 0
      fs/ceph/super.h

+ 1 - 1
fs/ceph/caps.c

@@ -816,7 +816,7 @@ int __ceph_caps_revoking_other(struct ceph_inode_info *ci,
 
 
 	for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) {
 	for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) {
 		cap = rb_entry(p, struct ceph_cap, ci_node);
 		cap = rb_entry(p, struct ceph_cap, ci_node);
-		if (cap != ocap && __cap_is_valid(cap) &&
+		if (cap != ocap &&
 		    (cap->implemented & ~cap->issued & mask))
 		    (cap->implemented & ~cap->issued & mask))
 			return 1;
 			return 1;
 	}
 	}

+ 5 - 3
fs/ceph/inode.c

@@ -1466,7 +1466,8 @@ static void ceph_invalidate_work(struct work_struct *work)
 	dout("invalidate_pages %p gen %d revoking %d\n", inode,
 	dout("invalidate_pages %p gen %d revoking %d\n", inode,
 	     ci->i_rdcache_gen, ci->i_rdcache_revoking);
 	     ci->i_rdcache_gen, ci->i_rdcache_revoking);
 	if (ci->i_rdcache_revoking != ci->i_rdcache_gen) {
 	if (ci->i_rdcache_revoking != ci->i_rdcache_gen) {
-		/* nevermind! */
+		if (__ceph_caps_revoking_other(ci, NULL, CEPH_CAP_FILE_CACHE))
+			check = 1;
 		spin_unlock(&ci->i_ceph_lock);
 		spin_unlock(&ci->i_ceph_lock);
 		mutex_unlock(&ci->i_truncate_mutex);
 		mutex_unlock(&ci->i_truncate_mutex);
 		goto out;
 		goto out;
@@ -1487,13 +1488,14 @@ static void ceph_invalidate_work(struct work_struct *work)
 		dout("invalidate_pages %p gen %d raced, now %d revoking %d\n",
 		dout("invalidate_pages %p gen %d raced, now %d revoking %d\n",
 		     inode, orig_gen, ci->i_rdcache_gen,
 		     inode, orig_gen, ci->i_rdcache_gen,
 		     ci->i_rdcache_revoking);
 		     ci->i_rdcache_revoking);
+		if (__ceph_caps_revoking_other(ci, NULL, CEPH_CAP_FILE_CACHE))
+			check = 1;
 	}
 	}
 	spin_unlock(&ci->i_ceph_lock);
 	spin_unlock(&ci->i_ceph_lock);
 	mutex_unlock(&ci->i_truncate_mutex);
 	mutex_unlock(&ci->i_truncate_mutex);
-
+out:
 	if (check)
 	if (check)
 		ceph_check_caps(ci, 0, NULL);
 		ceph_check_caps(ci, 0, NULL);
-out:
 	iput(inode);
 	iput(inode);
 }
 }
 
 

+ 2 - 0
fs/ceph/super.h

@@ -528,6 +528,8 @@ static inline int __ceph_caps_dirty(struct ceph_inode_info *ci)
 }
 }
 extern int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask);
 extern int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask);
 
 
+extern int __ceph_caps_revoking_other(struct ceph_inode_info *ci,
+				      struct ceph_cap *ocap, int mask);
 extern int ceph_caps_revoking(struct ceph_inode_info *ci, int mask);
 extern int ceph_caps_revoking(struct ceph_inode_info *ci, int mask);
 extern int __ceph_caps_used(struct ceph_inode_info *ci);
 extern int __ceph_caps_used(struct ceph_inode_info *ci);