From: "bfields@fieldses.org" <bfields@fieldses.org>
To: Trond Myklebust <trondmy@hammerspace.com>
Cc: "robbieko@synology.com" <robbieko@synology.com>,
"bingjingc@synology.com" <bingjingc@synology.com>,
"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
"hch@infradead.org" <hch@infradead.org>,
"nickhuang@synology.com" <nickhuang@synology.com>,
"chuck.lever@oracle.com" <chuck.lever@oracle.com>
Subject: Re: [PATCH] nfsd: Prevent truncation of an unlinked inode from blocking access to its directory
Date: Tue, 18 May 2021 14:39:59 -0400 [thread overview]
Message-ID: <20210518183959.GC26957@fieldses.org> (raw)
In-Reply-To: <924d92d52116cff9c0203b84a02d45352bfad361.camel@hammerspace.com>
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
>
>
next prev parent reply other threads:[~2021-05-18 18:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-14 3:58 [PATCH] nfsd: Prevent truncation of an unlinked inode from blocking access to its directory Nick Huang
2021-05-14 15:09 ` J. Bruce Fields
2021-05-14 15:46 ` Trond Myklebust
2021-05-15 7:02 ` Christoph Hellwig
2021-05-17 18:56 ` bfields
2021-05-18 7:33 ` Christoph Hellwig
2021-05-18 17:53 ` Trond Myklebust
2021-05-18 18:21 ` bfields
2021-05-18 18:36 ` Trond Myklebust
2021-05-18 18:39 ` bfields [this message]
2021-05-18 21:06 ` bfields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210518183959.GC26957@fieldses.org \
--to=bfields@fieldses.org \
--cc=bingjingc@synology.com \
--cc=chuck.lever@oracle.com \
--cc=hch@infradead.org \
--cc=linux-nfs@vger.kernel.org \
--cc=nickhuang@synology.com \
--cc=robbieko@synology.com \
--cc=trondmy@hammerspace.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox