diff options
author | Yan, Zheng <zyan@redhat.com> | 2019-05-23 06:01:37 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-08-04 10:33:45 +0300 |
commit | 370bb858d70f330af54a670a54d13ae305bcde83 (patch) | |
tree | 8ab6cd546d726dab90eca9bb5504485f41c1a821 | |
parent | 91c5daaa743b35f63f729b821d015dd87daae3a5 (diff) | |
download | linux-370bb858d70f330af54a670a54d13ae305bcde83.tar.xz |
ceph: hold i_ceph_lock when removing caps for freeing inode
commit d6e47819721ae2d9d090058ad5570a66f3c42e39 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>
-rw-r--r-- | fs/ceph/caps.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index f916cd7b1918..82df349b84f7 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -1081,20 +1081,23 @@ static int send_cap_msg(struct ceph_mds_session *session, } /* - * Queue cap releases when an inode is dropped from our cache. Since - * inode is about to be destroyed, there is no need for i_ceph_lock. + * Queue cap releases when an inode is dropped from our cache. */ void ceph_queue_caps_release(struct inode *inode) { struct ceph_inode_info *ci = ceph_inode(inode); struct rb_node *p; + /* lock i_ceph_lock, because ceph_d_revalidate(..., LOOKUP_RCU) + * may call __ceph_caps_issued_mask() on a freeing inode. */ + spin_lock(&ci->i_ceph_lock); p = rb_first(&ci->i_caps); while (p) { struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node); p = rb_next(p); __ceph_remove_cap(cap, true); } + spin_unlock(&ci->i_ceph_lock); } /* |