summaryrefslogtreecommitdiffstats
path: root/fs/ceph/caps.c
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2019-05-22 23:01:37 -0400
committerIlya Dryomov <idryomov@gmail.com>2019-07-08 08:01:42 -0400
commitd6e47819721ae2d9d090058ad5570a66f3c42e39 (patch)
tree86e4c8bba5d0a7915388e00b6631a69601be8330 /fs/ceph/caps.c
parent8f2a98ef3c1adf815ce38d5cc2f4e2a8759e98c5 (diff)
ceph: hold i_ceph_lock when removing caps for freeing inode
ceph_d_revalidate(, LOOKUP_RCU) may call __ceph_caps_issued_mask() on a freeing inode. Signed-off-by: "Yan, Zheng" <zyan@redhat.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r--fs/ceph/caps.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 0176241eaea7..7754d7679122 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1263,20 +1263,22 @@ static int send_cap_msg(struct cap_msg_args *arg)
1263} 1263}
1264 1264
1265/* 1265/*
1266 * Queue cap releases when an inode is dropped from our cache. Since 1266 * Queue cap releases when an inode is dropped from our cache.
1267 * inode is about to be destroyed, there is no need for i_ceph_lock.
1268 */ 1267 */
1269void __ceph_remove_caps(struct inode *inode) 1268void __ceph_remove_caps(struct ceph_inode_info *ci)
1270{ 1269{
1271 struct ceph_inode_info *ci = ceph_inode(inode);
1272 struct rb_node *p; 1270 struct rb_node *p;
1273 1271
1272 /* lock i_ceph_lock, because ceph_d_revalidate(..., LOOKUP_RCU)
1273 * may call __ceph_caps_issued_mask() on a freeing inode. */
1274 spin_lock(&ci->i_ceph_lock);
1274 p = rb_first(&ci->i_caps); 1275 p = rb_first(&ci->i_caps);
1275 while (p) { 1276 while (p) {
1276 struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node); 1277 struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node);
1277 p = rb_next(p); 1278 p = rb_next(p);
1278 __ceph_remove_cap(cap, true); 1279 __ceph_remove_cap(cap, true);
1279 } 1280 }
1281 spin_unlock(&ci->i_ceph_lock);
1280} 1282}
1281 1283
1282/* 1284/*