Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:60898 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751482AbdK3Hzy (ORCPT ); Thu, 30 Nov 2017 02:55:54 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0DA82883C9 for ; Thu, 30 Nov 2017 07:55:54 +0000 (UTC) Received: from ovpn-12-168.pek2.redhat.com (ovpn-12-168.pek2.redhat.com [10.72.12.168]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 62B795D973 for ; Thu, 30 Nov 2017 07:55:53 +0000 (UTC) From: "Yan, Zheng" Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8BIT Mime-Version: 1.0 (Mac OS X Mail 11.1 \(3445.4.7\)) Subject: Re: [PATCH] ceph: decease session->s_trim_caps only after caps get trimmed Date: Thu, 30 Nov 2017 15:55:49 +0800 References: <20171130075358.7803-1-zyan@redhat.com> To: stable@vger.kernel.org In-Reply-To: <20171130075358.7803-1-zyan@redhat.com> Message-Id: Sender: stable-owner@vger.kernel.org List-ID: Please ignore this mail. > On 30 Nov 2017, at 15:53, Yan, Zheng wrote: > > d_prune_aliases() does not prune dentry that has non-zero reference > count. If we want trim_caps() to trim 'N' caps, the first 'N' inodes > in session->s_caps are all directories with child dentry, trim_caps() > can fail to trim anything. > > Cc: stable@vger.kernel.org > Signed-off-by: "Yan, Zheng" > --- > fs/ceph/mds_client.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c > index 80339e278ad8..da181acd4a61 100644 > --- a/fs/ceph/mds_client.c > +++ b/fs/ceph/mds_client.c > @@ -1490,16 +1490,20 @@ static int trim_caps_cb(struct inode *inode, struct ceph_cap *cap, void *arg) > if ((used | wanted) & ~oissued & mine) > goto out; /* we need these caps */ > > - session->s_trim_caps--; > if (oissued) { > /* we aren't the only cap.. just remove us */ > __ceph_remove_cap(cap, true); > + session->s_trim_caps--; > } else { > + int refs; > /* try dropping referring dentries */ > spin_unlock(&ci->i_ceph_lock); > d_prune_aliases(inode); > + refs = atomic_read(&inode->i_count); > + if (refs == 1) > + session->s_trim_caps--; > dout("trim_caps_cb %p cap %p pruned, count now %d\n", > - inode, cap, atomic_read(&inode->i_count)); > + inode, cap, refs); > return 0; > } > > -- > 2.13.6 >