From: Al Viro <viro@zeniv.linux.org.uk>
To: Omar Sandoval <osandov@osandov.com>
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: Fri, 17 Jan 2020 18:17:30 +0000 [thread overview]
Message-ID: <20200117181730.GO8904@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20200117172855.GA295250@vader>
On Fri, Jan 17, 2020 at 09:28:55AM -0800, Omar Sandoval wrote:
> On Fri, Jan 17, 2020 at 04:59:04PM +0000, Al Viro wrote:
> > On Fri, Jan 17, 2020 at 08:36:16AM -0800, Omar Sandoval wrote:
> >
> > > The semantics I implemented in my series were basically "linkat with
> > > AT_REPLACE replaces the target iff rename would replace the target".
> > > Therefore, symlinks are replaced, not followed, and mountpoints get
> > > EXDEV. In my opinion that's both sane and unsurprising.
> >
> > Umm... EXDEV in rename() comes when _parents_ are on different mounts.
> > rename() over a mountpoint is EBUSY if it has mounts in caller's
> > namespace, but it succeeds (and detaches all mounts on the victim
> > in any namespaces) otherwise.
> >
> > When are you returning EXDEV?
>
> EXDEV was a thinko, the patch does what rename does:
>
>
> + if (is_local_mountpoint(new_dentry)) {
> + error = -EBUSY;
> + goto out;
> + }
>
> ...
>
> + if (target) {
> + dont_mount(new_dentry);
> + detach_mounts(new_dentry);
> + }
>
> Anyways, my point is that the rename semantics cover 90% of AT_REPLACE.
> Before I resend the patches, I'll write up the documentation and we can
> see what other corner cases I missed.
OK... rename() has a major difference from linkat(), though, in not
following links (or allowing fd + empty path). link() is deeply
asymmetric in treatment of pathnames - the first argument is
"pathname describes a filesystem object" and the second - "pathname
descripes an entry in a directory" (the link to be). rename() is
not - both arguments are pathnames-as-link-specifiers. And that
affects what is and what is not allowed there, so that'll need
a careful look into.
FWIW, currently linkat() semantics can be described simply enough
* oldfd/oldname specifies an fs object; symlink traversal is
optional.
* newfd/newname specifies an entry in some directory. Directory
must be on the same mount as the object specified by oldname.
Entry must be a normal component (no empty paths allowed, no . or ..
either). Trailing slashes are not allowed. There must be no
entry with that name (which automatically implies that trailing
symlinks are not to be followed and there can't be anything
mounted on it).
* the object specified by oldname must be a non-directory.
* if the object is not a never-linked-yet anonymous,
it must still have some links.
* caller must have permission to create links in the
affected directory.
* append-only and immutables are not allowed (rationale:
they can't be unlinked)
* filesystem is allowed to fail for any reasons, as with
any operation; a linkat()-specific one is having the link count
overflow, but any generic error is possible (out of memory, IO
error, EPERM-because-I-feel-like-that, etc.)
All checks related to object in question are atomic wrt operations
that add or remove links to that object. Checks on parent are
atomic wrt operations modifying the parent. Neither group is
atomic wrt operations modifying the _old_ parent (if there's
any, in the first place).
next prev parent reply other threads:[~2020-01-17 18:17 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 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 [this message]
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
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
2020-01-17 14:47 ` David Howells
2020-01-17 14:56 ` Trond Myklebust
2020-01-17 16:01 ` Al Viro
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=20200117181730.GO8904@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--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=osandov@osandov.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;
as well as URLs for NNTP newsgroup(s).