Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1270498pxb; Wed, 20 Oct 2021 01:31:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztfAul75luTKi5ApjjTzcSfq6XYuQWcsx3xrN7nas5wLr3f2BuajHyki3jbsV3/7heS3mR X-Received: by 2002:a63:b218:: with SMTP id x24mr25368896pge.29.1634718683206; Wed, 20 Oct 2021 01:31:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634718683; cv=none; d=google.com; s=arc-20160816; b=c99bw6N0fBGGbTfOqRpXN5HOf6ZwT+H8k6BgoWDrM0zUEwAh0pSGLBiOqgL+JM0E4G kShrZ+OfwWKB02htDgcFgv0FMzYEIZ1bEnGqAFazS9vF79zUqnY3iownq5z8MKg08IHa TPqjo1qJvl/J0NZNAqcyQOSSK1BvSvgPhHs+g8G9ULuMUM5ZNvoIwS3Uw83OuPXxw1HG iJwWujVcTuopHNOLpcdQNmDycFXbZt+iftTvptf2msixFYyWdPziRX/QP+tVy3H9kTi1 w7H+CcChmGKXTXM9az/vHDijEzXuEOcbsCGSoAEwC+u9mMH8sut/mTvSCsveHXVh3zGf YmMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CbvtrLjcUbfgAMTLROLIlvj1tZ7LmmnXHpndaPRCItA=; b=V7Rzi2+J0UI6r95xDc/0821VSmqgxJ1tDgTa2umOTZWbLgu9qmD9bZPWxw5I180I3V CrwxAljZ5n+H6MqT98BlZ1nil6R1wyCmbGuLJcL48TYTZPnSNC4QQbWDKSn6KuLF+jeG m/EfQYFCRTO71Dnp8B1lr5gqi7s44eVqTdKmIHry/tmLHVI/KiGIt7ExZfxlAcsYZs4R TMip7UnpIZfKAkbUSi3N7BJJL03XS9SCOFTly2CcS0YI1nj2i+pXv1YnIjwSaF6S2kCl QtSGaGgJKIgQ8D1YgwZ2k4ONP7iGyEnbarHHWJAaIFe9BBE+NLKC6lqTNdAuM5W1QKLd p2Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=UCGyUGeV; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k27si2061311pgl.419.2021.10.20.01.31.09; Wed, 20 Oct 2021 01:31:23 -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; dkim=pass header.i=@cloudflare.com header.s=google header.b=UCGyUGeV; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229663AbhJTIc2 (ORCPT + 99 others); Wed, 20 Oct 2021 04:32:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbhJTIcW (ORCPT ); Wed, 20 Oct 2021 04:32:22 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45E10C06161C for ; Wed, 20 Oct 2021 01:30:07 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id a140-20020a1c7f92000000b0030d8315b593so9213956wmd.5 for ; Wed, 20 Oct 2021 01:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CbvtrLjcUbfgAMTLROLIlvj1tZ7LmmnXHpndaPRCItA=; b=UCGyUGeVpWan4WCX6U/T8SPsoDfVI8CRM1oqIfsJkpGsZUjZ1PJjuoy0Yx2XdBYhOA FDjDLlXRKmgBMVew3f4H+plLhk3YEnccbeLeSMewyXqwlvLWiTZXI6oGP5do8odiS9yj oG7NPxnJhXvgZTREotbgPMKNA+K7wPzH1puMc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CbvtrLjcUbfgAMTLROLIlvj1tZ7LmmnXHpndaPRCItA=; b=VsGFeTlWqZyd3decMYtuCAlo84E+rTyEtNEkJhymKLE7xB0It2MHH2i0UaSytQqrtt nGTyFZw1AAotNNivvcTFqibr2ARD5MbTEcoJgIvimW38KurEiuf+243nxpZnxEOiMawF B7QdT5Nn4848KXJrJgkceJAU2/AnBDlhyhq9ZFG4CLk8O7OjeHtySF1/bKte9EgKul43 Xv34Mc9bmWNUWSqJB5HlSA8ysn+/uYqeoZUKKSibrNHxzb2Rs4w+NbTl6wkXT/l/VcGv /eUT+r2zDALJyc1TecFv4f/sRr4jMy67DvkBbOxyi037NnYXoh3xpf5kUkXioinPTTaN OHHw== X-Gm-Message-State: AOAM533CFXqIfyPJekNiGKlhRkhzF1cbnM3Y0wXQ01IpvE5fd7fh0gWK yfQtSq3A0b7hgvDCy2i8PyWMxg== X-Received: by 2002:a05:6000:1acc:: with SMTP id i12mr49580282wry.249.1634718605797; Wed, 20 Oct 2021 01:30:05 -0700 (PDT) Received: from antares.. (d.5.c.c.6.2.1.6.f.5.3.5.c.9.c.f.f.f.6.2.a.5.a.7.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:7a5a:26ff:fc9c:535f:6126:cc5d]) by smtp.gmail.com with ESMTPSA id s13sm4473133wmc.47.2021.10.20.01.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Oct 2021 01:30:05 -0700 (PDT) From: Lorenz Bauer To: Alexander Viro , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: kernel-team@cloudflare.com, Lorenz Bauer , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH bpf-next 1/2] libfs: support RENAME_EXCHANGE in simple_rename() Date: Wed, 20 Oct 2021 09:29:55 +0100 Message-Id: <20211020082956.8359-2-lmb@cloudflare.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211020082956.8359-1-lmb@cloudflare.com> References: <20211020082956.8359-1-lmb@cloudflare.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.30.2