mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Lorenz Bauer <lmb@cloudflare.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: kernel-team@cloudflare.com, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	bpf@vger.kernel.org, mszeredi@redhat.com,
	gregkh@linuxfoundation.org
Subject: Re: [PATCH bpf-next v2 1/3] libfs: support RENAME_EXCHANGE in simple_rename()
Date: Thu, 28 Oct 2021 01:21:12 +0200	[thread overview]
Message-ID: <b215bb8c-3ffd-2b43-44a3-5b25243db5be@iogearbox.net> (raw)
In-Reply-To: <20211021151528.116818-2-lmb@cloudflare.com>

[ Adding Miklos & Greg to Cc for review given e0e0be8a8355 ("libfs: support RENAME_NOREPLACE in
   simple_rename()"). If you have a chance, would be great if you could take a look, thanks! ]

On 10/21/21 5:15 PM, Lorenz Bauer wrote:
> Allow atomic exchange via RENAME_EXCHANGE when using simple_rename.
> This affects binderfs, ramfs, hubetlbfs and bpffs. There isn't much
> to do except update the various *time fields.
> 
> Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
> ---
>   fs/libfs.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/libfs.c b/fs/libfs.c
> index 51b4de3b3447..93c03d593749 100644
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -455,9 +455,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)
> +		goto done;
> +
>   	if (!simple_empty(new_dentry))
>   		return -ENOTEMPTY;
>   
> @@ -472,6 +475,7 @@ int simple_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
>   		inc_nlink(new_dir);
>   	}
>   
> +done:
>   	old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime =
>   		new_dir->i_mtime = inode->i_ctime = current_time(old_dir);
>   
> 


  parent reply	other threads:[~2021-10-27 23:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20211021151528.116818-1-lmb@cloudflare.com>
2021-10-21 15:15 ` Lorenz Bauer
2021-10-22  0:34   ` Alexei Starovoitov
2021-10-27 23:21   ` Daniel Borkmann [this message]
2021-10-28  8:43     ` Miklos Szeredi
2021-10-28  9:49       ` Lorenz Bauer
2021-10-21 15:15 ` [PATCH bpf-next v2 2/3] selftests: bpf: convert test_bpffs to ASSERT macros Lorenz Bauer
2021-10-21 15:15 ` [PATCH bpf-next v2 3/3] 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=b215bb8c-3ffd-2b43-44a3-5b25243db5be@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-team@cloudflare.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lmb@cloudflare.com \
    --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

all inboxes | Powered by JetHome®