From: Omar Sandoval <osandov@osandov.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Trond Myklebust <trondmy@hammerspace.com>,
"amir73il@gmail.com" <amir73il@gmail.com>,
"dhowells@redhat.com" <dhowells@redhat.com>,
"lsf-pc@lists.linux-foundation.org"
<lsf-pc@lists.linux-foundation.org>, "hch@lst.de" <hch@lst.de>,
"miklos@szeredi.hu" <miklos@szeredi.hu>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: Re: [LSF/MM/BPF TOPIC] Allowing linkat() to replace the destination
Date: Tue, 21 Jan 2020 15:05:21 -0800 [thread overview]
Message-ID: <20200121230521.GA394361@vader> (raw)
In-Reply-To: <20200118022032.GR8904@ZenIV.linux.org.uk>
On Sat, Jan 18, 2020 at 02:20:32AM +0000, Al Viro wrote:
> On Fri, Jan 17, 2020 at 05:17:34PM -0800, Omar Sandoval wrote:
> > > No. This is completely wrong; just make it ->link_replace() and be done
> > > with that; no extra arguments and *always* the same conditions wrt
> > > positive/negative. One of the reasons why ->rename() tends to be
> > > ugly (and a source of quite a few bugs over years) are those "if
> > > target is positive/if target is negative" scattered over the instances.
> > >
> > > Make the choice conditional upon the positivity of target.
> >
> > Yup, you already convinced me that ->link_replace() is better in your
> > last email.
>
> FWIW, that might be not so simple ;-/ Reason: NFS-like stuff. Client
> sees a negative in cache; the problem is how to decide whether to
> tell the server "OK, I want normal link()" vs. "if it turns out that
> someone has created it by the time you see the request, give do
> a replacing link". Sure, if could treat ->link() telling you -EEXIST
> as "OK, repeat it with ->link_replace(), then", but that's an extra
> roundtrip...
So that's a point in favor of ->link(). But then if we overload ->link()
instead of adding ->link_replace() and we want EOPNOTSUPP to fail fast,
we need to add something like FMODE_SUPPORTS_AT_REPLACE.
Some options I see are:
1. Go with ->link_replace() until network filesystem specs support
AT_REPLACE. That would be a bit of a mess down the line, though.
2. Stick with ->link(), let the filesystem implementations deal with the
positive targets, and add FMODE_SUPPORTS_AT_REPLACE so that feature
detection remains easy for userspace.
3. Option 2, but don't bother with FMODE_SUPPORTS_AT_REPLACE.
FWIW, there is precendent for option 3: RENAME_EXCHANGE. That has the
same "files are the same" noop condition, and we don't know whether
RENAME_EXCHANGE is supported until ->rename(). A cursory search shows
that applications using RENAME_EXCHANGE try it and fall back to a
non-atomic exchange on EINVAL. They could do the exact same thing for
AT_REPLACE.
None of it is elegant, but which approach would you hate the least?
next prev parent reply other threads:[~2020-01-21 23:05 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-17 12:49 [LSF/MM/BPF TOPIC] Allowing linkat() to replace the destination David Howells
2020-01-17 14:33 ` Trond Myklebust
2020-01-17 14:47 ` David Howells
2020-01-17 14:56 ` Trond Myklebust
2020-01-17 16:01 ` Al Viro
2020-01-17 15:46 ` Al Viro
2020-01-17 16:12 ` Trond Myklebust
2020-01-17 16:48 ` Al Viro
2020-01-17 16:36 ` Omar Sandoval
2020-01-17 16:59 ` Al Viro
2020-01-17 17:28 ` Omar Sandoval
2020-01-17 18:17 ` Al Viro
2020-01-17 20:22 ` Omar Sandoval
2020-01-17 22:22 ` Al Viro
2020-01-17 23:54 ` Omar Sandoval
2020-01-18 0:47 ` Al Viro
2020-01-18 1:17 ` Omar Sandoval
2020-01-18 2:20 ` Al Viro
2020-01-21 23:05 ` Omar Sandoval [this message]
2020-01-22 6:57 ` Amir Goldstein
2020-01-22 22:10 ` Omar Sandoval
2020-01-23 3:47 ` Al Viro
2020-01-23 7:16 ` Dave Chinner
2020-01-23 7:47 ` Amir Goldstein
2020-01-24 21:25 ` Dave Chinner
2020-01-31 5:24 ` Darrick J. Wong
2020-01-31 5:29 ` hch
2020-01-31 7:00 ` Amir Goldstein
2020-01-31 20:33 ` Omar Sandoval
2020-01-31 21:55 ` Amir Goldstein
2020-01-28 1:27 ` Omar Sandoval
2020-01-28 14:35 ` David Howells
2020-01-31 5:31 ` hch
2020-01-31 8:04 ` David Howells
2020-01-31 8:56 ` Amir Goldstein
2020-01-22 9:53 ` David Howells
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=20200121230521.GA394361@vader \
--to=osandov@osandov.com \
--cc=amir73il@gmail.com \
--cc=dhowells@redhat.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=lsf-pc@lists.linux-foundation.org \
--cc=miklos@szeredi.hu \
--cc=trondmy@hammerspace.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.