Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp971465pxb; Wed, 27 Oct 2021 16:23:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxffpmOYeac/4u496ReawREp/oCHQSxW4fcmtYc43LhPM9KMIvOp7n5RrgXz4slOarbUelA X-Received: by 2002:a17:906:5347:: with SMTP id j7mr724227ejo.562.1635377020088; Wed, 27 Oct 2021 16:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635377020; cv=none; d=google.com; s=arc-20160816; b=hpAjxd56h90bejsNPAVsoHQe1wMJcWgXW8TmTs6s4CZDe8JtfK6Ez4BVrBtZBNmR1G A2zK+DzA8atCNNIytAxdSXRhuZzDl8fo5y5OnV9yDLWltAikIpKZ9CDZ1rMFx8FGyHbH UpC5PnlM7bM0oWPUvkrnHKobBU/kL7c+fpfao+jTIWVnhmOsmmEdrrCLoExq2ell8cU4 /gx2SqqxodawTQs9GjEpCiR26O8UfHKzY+mvN30/XPund/vWP4isRmuMkQRTJS4hkzAw iPkAjnR2C0XIBC+jv18/Nf7bbNgmQ698O7ZB+AyQpPO7V8UQQ5LPaj5OzNuHZHvS3Ew+ ejOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=QujWW+1yg8o1DcwfElQM6HIAh0kKFxMWHXx1fP7pH0w=; b=dCz+2VxPQ59aFFCeFA/5085agtalOwPgV9zNugHTnAwsnvMncmferoMn9wcWJckQxI 0S+ftAmVZ3YQnKEbec1crbXkVH5z6Dlf00v+5wkMoxPZOcOJhmKIv7FTQ1UMSnj+KL1W LlTCOcyX1mTg4hDPKeDsKr8t2DsiTE7IINUWLbRcqrKDa0bHLs7UtGe/xsfpwRRrbxSg 5TRLaL+tukUMly+6KPTtt636R9pLohcu7+QpBbCBDNcYujQEu/FtALYQifjvWlkLzBPd MjM+TO3Ul6YScrTvf/qIG8xvBYosOSZCgcK6cIHpy4nWU80OCei0Y+UIVowQm5JAavE4 DoGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 28si1549233ejb.18.2021.10.27.16.23.12; Wed, 27 Oct 2021 16:23:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230317AbhJ0XXq (ORCPT + 99 others); Wed, 27 Oct 2021 19:23:46 -0400 Received: from www62.your-server.de ([213.133.104.62]:41594 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229836AbhJ0XXq (ORCPT ); Wed, 27 Oct 2021 19:23:46 -0400 Received: from sslproxy05.your-server.de ([78.46.172.2]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1mfsEM-000GsC-7q; Thu, 28 Oct 2021 01:21:14 +0200 Received: from [85.1.206.226] (helo=linux.home) by sslproxy05.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mfsEL-00060m-VZ; Thu, 28 Oct 2021 01:21:13 +0200 Subject: Re: [PATCH bpf-next v2 1/3] libfs: support RENAME_EXCHANGE in simple_rename() To: Lorenz Bauer , Alexander Viro , Alexei Starovoitov , Andrii Nakryiko 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 References: <20211021151528.116818-1-lmb@cloudflare.com> <20211021151528.116818-2-lmb@cloudflare.com> From: Daniel Borkmann Message-ID: Date: Thu, 28 Oct 2021 01:21:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20211021151528.116818-2-lmb@cloudflare.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.3/26335/Wed Oct 27 10:28:55 2021) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 > --- > 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); > >