summaryrefslogtreecommitdiffstats
path: root/fs/ceph/mds_client.c
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2019-04-18 11:24:57 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-05-02 09:40:29 +0200
commitbe539bbf3c8619bccc6b74825710f1ff7a8bb068 (patch)
treeeeddd9c4a221804c2885542ae6042c26c0a46f78 /fs/ceph/mds_client.c
parent08152ac980c608f5add894b0f34d111f1fe50be4 (diff)
downloadlinux-stable-be539bbf3c8619bccc6b74825710f1ff7a8bb068.tar.gz
linux-stable-be539bbf3c8619bccc6b74825710f1ff7a8bb068.tar.bz2
linux-stable-be539bbf3c8619bccc6b74825710f1ff7a8bb068.zip
ceph: fix ci->i_head_snapc leak
commit 37659182bff1eeaaeadcfc8f853c6d2b6dbc3f47 upstream. We missed two places that i_wrbuffer_ref_head, i_wr_ref, i_dirty_caps and i_flushing_caps may change. When they are all zeros, we should free i_head_snapc. Cc: stable@vger.kernel.org Link: https://tracker.ceph.com/issues/38224 Reported-and-tested-by: Luis Henriques <lhenriques@suse.com> Signed-off-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/ceph/mds_client.c')
-rw-r--r--fs/ceph/mds_client.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 501805fc142e..e1ded4bd6115 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1219,6 +1219,15 @@ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap,
list_add(&ci->i_prealloc_cap_flush->i_list, &to_remove);
ci->i_prealloc_cap_flush = NULL;
}
+
+ if (drop &&
+ ci->i_wrbuffer_ref_head == 0 &&
+ ci->i_wr_ref == 0 &&
+ ci->i_dirty_caps == 0 &&
+ ci->i_flushing_caps == 0) {
+ ceph_put_snap_context(ci->i_head_snapc);
+ ci->i_head_snapc = NULL;
+ }
}
spin_unlock(&ci->i_ceph_lock);
while (!list_empty(&to_remove)) {