From: Lorenz Bauer <lmb@cloudflare.com>
To: viro@zeniv.linux.org.uk, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: mszeredi@redhat.com, gregkh@linuxfoundation.org,
Lorenz Bauer <lmb@cloudflare.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: [PATCH bpf-next v3 2/4] libfs: support RENAME_EXCHANGE in simple_rename()
Date: Thu, 28 Oct 2021 10:47:22 +0100 [thread overview]
Message-ID: <20211028094724.59043-3-lmb@cloudflare.com> (raw)
In-Reply-To: <20211028094724.59043-1-lmb@cloudflare.com>
Allow atomic exchange via RENAME_EXCHANGE when using simple_rename.
This affects binderfs, ramfs, hubetlbfs and bpffs.
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
---
fs/libfs.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/libfs.c b/fs/libfs.c
index 1cf144dc9ed2..ba7438ab9371 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -479,9 +479,12 @@ int simple_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
struct inode *inode = d_inode(old_dentry);
int they_are_dirs = d_is_dir(old_dentry);
- if (flags & ~RENAME_NOREPLACE)
+ if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE))
return -EINVAL;
+ if (flags & RENAME_EXCHANGE)
+ return simple_rename_exchange(old_dir, old_dentry, new_dir, new_dentry);
+
if (!simple_empty(new_dentry))
return -ENOTEMPTY;
--
2.32.0
next prev parent reply other threads:[~2021-10-28 9:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20211028094724.59043-1-lmb@cloudflare.com>
2021-10-28 9:47 ` [PATCH bpf-next v3 1/4] libfs: move shmem_exchange to simple_rename_exchange Lorenz Bauer
2021-10-29 15:28 ` Daniel Borkmann
2021-11-02 8:58 ` Miklos Szeredi
2021-10-28 9:47 ` Lorenz Bauer [this message]
2021-11-02 9:25 ` [PATCH bpf-next v3 2/4] libfs: support RENAME_EXCHANGE in simple_rename() Miklos Szeredi
2021-11-02 10:11 ` Daniel Borkmann
2021-11-02 11:36 ` Christian Brauner
2021-10-28 9:47 ` [PATCH bpf-next v3 3/4] selftests: bpf: convert test_bpffs to ASSERT macros Lorenz Bauer
2021-10-28 9:47 ` [PATCH bpf-next v3 4/4] selftests: bpf: test RENAME_EXCHANGE and RENAME_NOREPLACE on bpffs Lorenz Bauer
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=20211028094724.59043-3-lmb@cloudflare.com \
--to=lmb@cloudflare.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=netdev@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