On 8/23/21 10:58 PM, Jeff Layton wrote:
On Wed, 2021-08-18 at 16:06 +0800, xiubli@xxxxxxxxxx wrote:
From: Xiubo Li <xiubli@xxxxxxxxxx>
The capsnaps will ihold the inodes when queuing to flush, so when
force umounting it will close the sessions first and if the MDSes
respond very fast and the session connections are closed just
before killing the superblock, which will flush the msgr queue,
then the flush capsnap callback won't ever be called, which will
lead the memory leak bug for the ceph_inode_info.
URL: https://tracker.ceph.com/issues/52295
Signed-off-by: Xiubo Li <xiubli@xxxxxxxxxx>
---
fs/ceph/caps.c | 47 +++++++++++++++++++++++++++++---------------
fs/ceph/mds_client.c | 23 +++++++++++++++++++++-
fs/ceph/super.h | 3 +++
3 files changed, 56 insertions(+), 17 deletions(-)
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index e239f06babbc..7def99fbdca6 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -3663,6 +3663,34 @@ static void handle_cap_flush_ack(struct inode *inode, u64 flush_tid,
iput(inode);
}
+/*
+ * Caller hold s_mutex and i_ceph_lock.
+ */
+void ceph_remove_capsnap(struct inode *inode, struct ceph_cap_snap *capsnap,
+ bool *wake_ci, bool *wake_mdsc)
+{
+ struct ceph_inode_info *ci = ceph_inode(inode);
+ struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+ bool ret;
+
+ dout("removing capsnap %p, inode %p ci %p\n", capsnap, inode, ci);
+
+ WARN_ON(capsnap->dirty_pages || capsnap->writing);
Can we make this a WARN_ON_ONCE too?
Yeah, will fix it.
Thanks