linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@hammerspace.com>
To: "viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: Re: why is short-circuiting nfs_lookup() for mkdir(2) et.al. dependent upon v3 or later?
Date: Tue, 30 Mar 2021 11:43:49 +0000	[thread overview]
Message-ID: <f106b42668f23ccd7d1627248f2aeaba64cde765.camel@hammerspace.com> (raw)
In-Reply-To: <YGJ1UyTYumVZCa8v@zeniv-ca.linux.org.uk>

On Tue, 2021-03-30 at 00:48 +0000, Al Viro wrote:
>         In nfs_lookup() we have
>         /*
>          * If we're doing an exclusive create, optimize away the
> lookup
>          * but don't hash the dentry.
>          */
>         if (nfs_is_exclusive_create(dir, flags) || flags &
> LOOKUP_RENAME_TARGET)
>                 return NULL;
> OK, fair enough - we don't need to find out whether it's negative or
> not for
> mkdir() et.al.; if it isn't, server will tell us to sod off and we
> can live
> with not having it in cache - in the worst case, we'll have to do the
> same
> lookup we'd skipped here at some later point.  Same for rename(2)
> destination -
> if it wasn't in dcache, we are not going to bother with sillyrename
> anyway, and
> that's the only thing where we might care about the destination.  If
> rename(2)
> succeeds, we won't see whatever had been there anyway, and if it
> fails, we won't
> lose anything from having lookup done later.
> 
>         What I don't get is why, unlike rename(2) target, mkdir(2)
> argument is
> handled that way only for v3 and later.  It's been a long time since
> I looked
> at NFSv2 servers, but shouldn't we get NFSERR_EXIST if the sucker
> turns out to
> have already been there?
> 
>         What am I missing?

The check for NFS version > 2 is mainly there for the case of CREATE,
which does not have an exclusive create mode in NFSv2.
IOW: I believe we can indeed rely on LINK, MKDIR, and RENAME returning
NFSERR_EXIST, but not the more common case of CREATE.

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



      reply	other threads:[~2021-03-30 11:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30  0:48 why is short-circuiting nfs_lookup() for mkdir(2) et.al. dependent upon v3 or later? Al Viro
2021-03-30 11:43 ` Trond Myklebust [this message]

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=f106b42668f23ccd7d1627248f2aeaba64cde765.camel@hammerspace.com \
    --to=trondmy@hammerspace.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).