LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Yan, Zheng" <zyan@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: idryomov@redhat.com, jlayton@redhat.com
Subject: [PATCH 8/8] ceph: hold i_ceph_lock when removing caps for freeing inode
Date: Thu, 23 May 2019 16:06:46 +0800 [thread overview]
Message-ID: <20190523080646.19632-8-zyan@redhat.com> (raw)
In-Reply-To: <20190523080646.19632-1-zyan@redhat.com>
ceph_d_revalidate(, LOOKUP_RCU) may call __ceph_caps_issued_mask()
on a freeing inode.
Cc: stable@vger.kernel.org
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
---
fs/ceph/caps.c | 10 ++++++----
fs/ceph/inode.c | 2 +-
fs/ceph/super.h | 2 +-
3 files changed, 8 insertions(+), 6 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)
}
/*
- * 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_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;
+ /* 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);
}
/*
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index e47a25495be5..30d0cdc21035 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -534,7 +534,7 @@ void ceph_destroy_inode(struct inode *inode)
ceph_fscache_unregister_inode_cookie(ci);
- __ceph_remove_caps(inode);
+ __ceph_remove_caps(ci);
if (__ceph_has_any_quota(ci))
ceph_adjust_quota_realms_count(inode, false);
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 11aeb540b0cf..e74867743e07 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -1003,7 +1003,7 @@ extern void ceph_add_cap(struct inode *inode,
unsigned cap, unsigned seq, u64 realmino, int flags,
struct ceph_cap **new_cap);
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,
struct ceph_cap *cap);
extern int ceph_is_any_caps(struct inode *inode);
--
2.17.2
next prev parent reply other threads:[~2019-05-23 8:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-23 8:06 [PATCH 1/8] ceph: fix error handling in ceph_get_caps() Yan, Zheng
2019-05-23 8:06 ` [PATCH 2/8] ceph: single workqueue for inode related works Yan, Zheng
2019-05-23 8:06 ` [PATCH 3/8] ceph: avoid iput_final() while holding mutex or in dispatch thread Yan, Zheng
2019-05-23 8:06 ` [PATCH 4/8] ceph: close race between d_name_cmp() and update_dentry_lease() Yan, Zheng
2019-05-23 8:06 ` [PATCH 5/8] ceph: fix dir_lease_is_valid() Yan, Zheng
2019-05-23 8:06 ` [PATCH 6/8] ceph: use READ_ONCE to access d_parent in RCU critical section Yan, Zheng
2019-05-23 8:06 ` [PATCH 7/8] ceph: ensure d_name/d_parent stability in ceph_mdsc_lease_send_msg() Yan, Zheng
2019-05-23 8:06 ` Yan, Zheng [this message]
2019-05-29 13:14 ` [PATCH 8/8] ceph: hold i_ceph_lock when removing caps for freeing inode Sasha Levin
2019-05-30 1:46 ` Yan, Zheng
2019-08-02 8:13 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190523080646.19632-8-zyan@redhat.com \
--to=zyan@redhat.com \
--cc=idryomov@redhat.com \
--cc=jlayton@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: [PATCH 8/8] ceph: hold i_ceph_lock when removing caps for freeing inode' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).