From: Omar Sandoval <osandov@osandov.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-api@vger.kernel.org, kernel-team@fb.com,
Xi Wang <xi@cs.washington.edu>
Subject: Re: [RFC PATCH v3 0/2] fs: add AT_REPLACE flag for linkat()
Date: Tue, 24 Apr 2018 08:26:10 -0700 [thread overview]
Message-ID: <20180424152610.GA6989@vader> (raw)
In-Reply-To: <20180424132107.GA14919@infradead.org>
On Tue, Apr 24, 2018 at 06:21:07AM -0700, Christoph Hellwig wrote:
> > Patch 1 implements the VFS support for this flag. The implementation
> > resembles sys_renameat2(), and I took care to preserve all of the
> > original error cases and make the new error cases consistent with
> > rename.
>
> Shouldn't we try to reuse the rename code and the ->rename method
> instead of largely duplicating it?
As I mentioned in my cover letter, I did try, and it was uglier to reuse
rename.
For O_TMPFILE, we can't pass a meaningful old_dir to ->rename(), so now
every ->rename() supporting AT_EMPTY_PATH has to grow a bunch of special
cases for ignoring old_dir (I looked at Btrfs, ext4, and XFS, and it'd
be messy for all three). Conversely, ->link() just needs the extra
unlink before link logic (I added ->link2() for this RFC, but for the
actual patch I'll just add the flag to ->link()).
On the VFS side, in my opinion, there isn't that much duplication -- we
have the may_delete()/is_local_mountpoint() a la unlink, delegation
handling, and some specific error cases we need to handle similarly to
rename, but that's not too suprising for a new primitive.
> In fact I wonder if a better interface would just use renameat(2)
> and accept the AT_EMPTY_PATH (for the source name only).
renameat() makes sense for the O_TMPFILE case, but linkat() + AT_REPLACE
also supports a normal, named source file, and renameat() +
AT_EMPTY_PATH for that doesn't make sense at all (rename this file by
file descriptor, but don't really rename it?).
next prev parent reply other threads:[~2018-04-24 15:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-24 6:19 [RFC PATCH v3 0/2] fs: add AT_REPLACE flag for linkat() Omar Sandoval
2018-04-24 6:19 ` [RFC PATCH v3 1/2] fs: add AT_REPLACE flag for linkat() which replaces the target Omar Sandoval
2018-04-24 22:14 ` Omar Sandoval
2018-04-24 6:19 ` [RFC PATCH v3 2/2] Btrfs: add support for linkat() AT_REPLACE Omar Sandoval
2018-04-24 13:21 ` [RFC PATCH v3 0/2] fs: add AT_REPLACE flag for linkat() Christoph Hellwig
2018-04-24 15:26 ` Omar Sandoval [this message]
2018-04-26 7:49 ` Omar Sandoval
2018-04-27 12:00 ` Michael Kerrisk (man-pages)
2018-05-04 18:29 ` Omar Sandoval
2018-05-04 18:30 ` Omar Sandoval
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=20180424152610.GA6989@vader \
--to=osandov@osandov.com \
--cc=hch@infradead.org \
--cc=kernel-team@fb.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
--cc=xi@cs.washington.edu \
/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.