Commit d6e47819 authored by Yan, Zheng's avatar Yan, Zheng Committed by Ilya Dryomov

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: default avatar"Yan, Zheng" <zyan@redhat.com>
Reviewed-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 8f2a98ef
...@@ -1263,20 +1263,22 @@ static int send_cap_msg(struct cap_msg_args *arg) ...@@ -1263,20 +1263,22 @@ static int send_cap_msg(struct cap_msg_args *arg)
} }
/* /*
* Queue cap releases when an inode is dropped from our cache. Since * Queue cap releases when an inode is dropped from our cache.
* inode is about to be destroyed, there is no need for i_ceph_lock.
*/ */
void __ceph_remove_caps(struct inode *inode) void __ceph_remove_caps(struct ceph_inode_info *ci)
{ {
struct ceph_inode_info *ci = ceph_inode(inode);
struct rb_node *p; 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); p = rb_first(&ci->i_caps);
while (p) { while (p) {
struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node); struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node);
p = rb_next(p); p = rb_next(p);
__ceph_remove_cap(cap, true); __ceph_remove_cap(cap, true);
} }
spin_unlock(&ci->i_ceph_lock);
} }
/* /*
......
...@@ -533,7 +533,7 @@ void ceph_destroy_inode(struct inode *inode) ...@@ -533,7 +533,7 @@ void ceph_destroy_inode(struct inode *inode)
ceph_fscache_unregister_inode_cookie(ci); ceph_fscache_unregister_inode_cookie(ci);
__ceph_remove_caps(inode); __ceph_remove_caps(ci);
if (__ceph_has_any_quota(ci)) if (__ceph_has_any_quota(ci))
ceph_adjust_quota_realms_count(inode, false); ceph_adjust_quota_realms_count(inode, false);
......
...@@ -1004,7 +1004,7 @@ extern void ceph_add_cap(struct inode *inode, ...@@ -1004,7 +1004,7 @@ extern void ceph_add_cap(struct inode *inode,
unsigned cap, unsigned seq, u64 realmino, int flags, unsigned cap, unsigned seq, u64 realmino, int flags,
struct ceph_cap **new_cap); struct ceph_cap **new_cap);
extern void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release); extern void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release);
extern void __ceph_remove_caps(struct inode* inode); extern void __ceph_remove_caps(struct ceph_inode_info *ci);
extern void ceph_put_cap(struct ceph_mds_client *mdsc, extern void ceph_put_cap(struct ceph_mds_client *mdsc,
struct ceph_cap *cap); struct ceph_cap *cap);
extern int ceph_is_any_caps(struct inode *inode); extern int ceph_is_any_caps(struct inode *inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment