Skip to content

Commit d727239

Browse files
ukernelLee Jones
authored andcommitted
ceph: hold i_ceph_lock when removing caps for freeing inode
commit d6e4781 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Change-Id: Ic69bce882e1ebd8b33fa9c1774ada4c72846327a
1 parent 5d9c3b7 commit d727239

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

fs/ceph/caps.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,20 +1070,23 @@ void __queue_cap_release(struct ceph_mds_session *session,
10701070
}
10711071

10721072
/*
1073-
* Queue cap releases when an inode is dropped from our cache. Since
1074-
* inode is about to be destroyed, there is no need for i_ceph_lock.
1073+
* Queue cap releases when an inode is dropped from our cache.
10751074
*/
10761075
void ceph_queue_caps_release(struct inode *inode)
10771076
{
10781077
struct ceph_inode_info *ci = ceph_inode(inode);
10791078
struct rb_node *p;
10801079

1080+
/* lock i_ceph_lock, because ceph_d_revalidate(..., LOOKUP_RCU)
1081+
* may call __ceph_caps_issued_mask() on a freeing inode. */
1082+
spin_lock(&ci->i_ceph_lock);
10811083
p = rb_first(&ci->i_caps);
10821084
while (p) {
10831085
struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node);
10841086
p = rb_next(p);
10851087
__ceph_remove_cap(cap, true);
10861088
}
1089+
spin_unlock(&ci->i_ceph_lock);
10871090
}
10881091

10891092
/*

0 commit comments

Comments
 (0)