Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1689175pxj; Wed, 19 May 2021 11:31:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMrWT/4FK7+KKojgJcN8mnTgaVlBvWNMR6tZ98E7wnRt8dsy9PsIZczUbtGPRSP56/cq6P X-Received: by 2002:a17:906:a0a:: with SMTP id w10mr502899ejf.416.1621449073497; Wed, 19 May 2021 11:31:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621449073; cv=none; d=google.com; s=arc-20160816; b=PNtRB1sEghwyEHVB+GQn4PIq1XqtPjSe8jm/btAZVJEeC328HbYrkLOp6YuewwSrC8 eI9VHZ6d0Qe84W4TqWZ6/qU4MR6eLrt43k4W3LfVkk/vcv1y5Tf18Im7ySyVhUsqlq+x kBqIhKsX23AbYxli/ux6NHdue7ui+ijkRD2AY6gAnOljwMfZMOjQXJkqny5XMoK7kSKF Apx0kFBvJg6Hs5EGo4x0xeJixsx1M644dc0fz9KtMGRmjMDA1LUosCj3XlnGVc75PSuK 5m5N6WT6xaaSzEIVh3r5mt/jTuca5IVTmT5scBEyWOC5Pafz5gj8+qkucgFidPGpZUkA 5jzA== 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=pcz8UXo9//gxbL3GlspfgdEbVFVh6hDUCWykYhuttcw=; b=ntc09gkNHZRgRlNzCAo8O5dE0gri+lyGixHZ0aCY8sSIPU3rB4Wv1IpRB/KIOxZPc9 S0T62h1bRKiI7pn/9RUNaDGj74BIY/38+xjYbqtGWkJ8IFsRtPROmsLlUZv2x0wYYnL8 U/sP5eajMSgD6dIzTT7TSHn033xz+SXXueqZQQJKjcohrMJgIp9nqV1IageiVbF515AB +Vg0lzvAv3KwIR1IrbiuOUJACPCdfbIfbRNxYf73Y7JE9U+wbC9UR/F7pnL+JiB/wUAX XFzaweMRR6aqOADUe5w8cYjkpYN6dhKvaLpipKFtonSH+GhAGFzahQZphIek6MPsFnjF VIkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=s9bpohjW; 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 bz25si394265ejc.295.2021.05.19.11.30.48; Wed, 19 May 2021 11:31:13 -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=s9bpohjW; 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 S1351611AbhERSlU (ORCPT + 99 others); Tue, 18 May 2021 14:41:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343747AbhERSlT (ORCPT ); Tue, 18 May 2021 14:41:19 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7166C061573 for ; Tue, 18 May 2021 11:40:00 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id C35054F7D; Tue, 18 May 2021 14:39:59 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org C35054F7D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1621363199; bh=pcz8UXo9//gxbL3GlspfgdEbVFVh6hDUCWykYhuttcw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=s9bpohjW/0j5QYiJyrhWDVirY3lPd+OyNbO/17tu1nBnqQOrW34/2u26gwxbOwr6/ a8THasDie4ieMaBlY970ADPHuYEcKxk18mgMh/vlWQIStAlv6UYKkrpCi6r3OzHp8e o4crlVE4WesxNsfGrt+p2FgrYrW0q42QfbBauC10= Date: Tue, 18 May 2021 14:39:59 -0400 From: "bfields@fieldses.org" To: Trond Myklebust Cc: "robbieko@synology.com" , "bingjingc@synology.com" , "linux-nfs@vger.kernel.org" , "hch@infradead.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: <20210518183959.GC26957@fieldses.org> References: <20210514035829.5230-1-nickhuang@synology.com> <00195ec8bf1752306f549540eed74c3938c5e312.camel@hammerspace.com> <4387867bd64c5d3d8c67830a633b90e4a7e1ba38.camel@hammerspace.com> <20210518182115.GB26957@fieldses.org> <924d92d52116cff9c0203b84a02d45352bfad361.camel@hammerspace.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <924d92d52116cff9c0203b84a02d45352bfad361.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 06:36:23PM +0000, Trond Myklebust wrote: > On Tue, 2021-05-18 at 14:21 -0400, bfields@fieldses.org wrote: > > 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? > > As I said above, the dentry is negative at this point. It doesn't carry > a reference to the inode any more, so that wouldn't defer the inode > truncation. Oh, of course, thanks! --b. > > > > > 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. > > -- > Trond Myklebust > Linux NFS client maintainer, Hammerspace > trond.myklebust@hammerspace.com > >