Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1687964pxj; Wed, 19 May 2021 11:29:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxu/Up2ZvOyLvwsqm4SelhFB4KqcOLG8qck3HlOMOF9uZGE1L1Oaz36QZ/c2oHN7BBqOo37 X-Received: by 2002:a02:630e:: with SMTP id j14mr304821jac.115.1621448973914; Wed, 19 May 2021 11:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621448973; cv=none; d=google.com; s=arc-20160816; b=GynTNxPAA/75TJu88PLCABDWsCWsCSKPzt7xg8fRI996WZVF2FgCUidZu5bGM1jhSv DT+FW6nbBoYZhdPHmUX0Aq6rs6FM+xh0P1tZ+KejrIILvxf0HrGtCQSkjnvOaa6rhVH4 aD1/tJD4q0UXhtNeHkyt8px9wLQw+ZgGxNgTemX3881IVDoE9Zvzx1OQf4SmIrvV15rN I1Phv4sF4QVHAjM7ODdwM7/OJX5slJV3JobVehLQBAooTbAorTNgpzgb1eYxgd2Bgr5V rUQ6PCiCGd6UybjDeBTfkeoSGSQoZU6axYC1NYHRHNPnr+BiGYRzMxqRerBd3KMJLhx0 PoRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-filter; bh=eDZ5wijqSsSeETdzDqG2bQWmCJjMFwhiJ2aNURILkjE=; b=Vbd16gJkDKpWds7lhOfHzfcT0O1h9LS6qc6Sq3th6ja9v5d2WSD5jaRnoQO3Xky0mJ Jve23+Q0eAcgj8Yif6MzhPonRkxOuBMv9/dtkMOaQucf/oPb8J3Sc9qdL1crPFSxhCtC A0QTH41SWzSZNqIQmZfuObW8OEw1fgtz0yK0OfB1+pYl5CUX2dolsIF36FXvHKfaO347 n8NOox4DuZZ+6pl6s8MDW1lDmSryoqGXUi7jNeAFDGX4B4L4HG3gvC2lr4vBit0sGXk/ iPQzVUzXvouG6LCGL3N9UzB1HUAJIGa6NC7vLCEVhL//cY8xrbcfKzo/NF2qNxCEK4IA gyKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=RSnQ6lCQ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si273865ilm.86.2021.05.19.11.29.20; Wed, 19 May 2021 11:29:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=RSnQ6lCQ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344389AbhERSWf (ORCPT + 99 others); Tue, 18 May 2021 14:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245506AbhERSWe (ORCPT ); Tue, 18 May 2021 14:22:34 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4041EC061573 for ; Tue, 18 May 2021 11:21:16 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 1688C64B9; Tue, 18 May 2021 14:21:15 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 1688C64B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1621362075; bh=eDZ5wijqSsSeETdzDqG2bQWmCJjMFwhiJ2aNURILkjE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RSnQ6lCQDcVnjwpekBKIKvlfhoTLk513jTU4K4vAL6hZKsPYTkk+cbrzYUz4hDXqU Ja8XX9ZvZbvB/fD/2n1bL/ZOpjuHE/aqgsmQoI9ZeDnX7EX+SykYAF4oqj2asr8ZlT S037iWBEbNPvPf5jSFWXY5KaSSGt15IRgNppjW4A= Date: Tue, 18 May 2021 14:21:15 -0400 From: "bfields@fieldses.org" To: Trond Myklebust Cc: "hch@infradead.org" , "robbieko@synology.com" , "bingjingc@synology.com" , "linux-nfs@vger.kernel.org" , "nickhuang@synology.com" , "chuck.lever@oracle.com" Subject: Re: [PATCH] nfsd: Prevent truncation of an unlinked inode from blocking access to its directory Message-ID: <20210518182115.GB26957@fieldses.org> References: <20210514035829.5230-1-nickhuang@synology.com> <00195ec8bf1752306f549540eed74c3938c5e312.camel@hammerspace.com> <4387867bd64c5d3d8c67830a633b90e4a7e1ba38.camel@hammerspace.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4387867bd64c5d3d8c67830a633b90e4a7e1ba38.camel@hammerspace.com> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Tue, May 18, 2021 at 05:53:47PM +0000, Trond Myklebust wrote: > On Sat, 2021-05-15 at 08:02 +0100, Christoph Hellwig wrote: > > On Fri, May 14, 2021 at 03:46:57PM +0000, Trond Myklebust wrote: > > > Why leave the commit_metadata() call under the lock? If you're > > > concerned about latency, then it makes more sense to call > > > fh_unlock() > > > before flushing those metadata updates to disk. > > > > Also I'm not sure why the extra inode reference is needed.  What > > speaks > > against just moving the dput out of the locked section? > > Isn't the inode reference taken just in order to ensure that the call > to iput_final() (and in particular the call to > truncate_inode_pages_final()) is performed outside the lock? > > The dput() is presumably usually not particularly expensive, since the > dentry is just a completely ordinary negative dentry at this point. Right, but why bother with the extra ihold/iput instead of just postponing the dput? diff --git a/fs/namei.c b/fs/namei.c index 79b0ff9b151e..aeed93c9874c 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4084,7 +4084,6 @@ long do_unlinkat(int dfd, struct filename *name) inode = dentry->d_inode; if (d_is_negative(dentry)) goto slashes; - ihold(inode); error = security_path_unlink(&path, dentry); if (error) goto exit2; @@ -4092,11 +4091,10 @@ long do_unlinkat(int dfd, struct filename *name) error = vfs_unlink(mnt_userns, path.dentry->d_inode, dentry, &delegated_inode); exit2: - dput(dentry); } inode_unlock(path.dentry->d_inode); - if (inode) - iput(inode); /* truncate the inode here */ + if (!IS_ERR(dentry)) + dput(dentry); /* truncate the inode here */ inode = NULL; if (delegated_inode) { error = break_deleg_wait(&delegated_inode); ? --b.