Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1392585pxb; Thu, 28 Oct 2021 02:50:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhwt8qB0PIol0ro7ZBRrxCAqB2Em7i0Gt5WFA3DtSP1ZCHB3rDW8TVRyTxfP/pSQxm0T6n X-Received: by 2002:a50:99d1:: with SMTP id n17mr4836348edb.169.1635414653409; Thu, 28 Oct 2021 02:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635414653; cv=none; d=google.com; s=arc-20160816; b=tpGKl0ge5hi4z5D0Gs2KNbXCMCXBCMBehPU9n7YuR8r1Vz1QpVT7e7WwASuesCLdIQ wWiSOS06SXZcGEH+c13uTWMmNMt6NJ4GbNnqS6e+DmqMpdoySVRxpZeUTz5vidhxC+dH nBhebOrTGcqar7bstK1YNuRmEnhlbdGM12h3P1snC+EKgPPOz/sbH1uk0Cc3zYJAoFgz X/3ArOXkaosdBJXIsYbizqvBRtkc7xqkiguF+BVQVenTXR863ySbEcEJyJnKLBm63we+ k632eJK0Bb/3UFUpuHAIz8c619WV9qPQI0BnICnhXZUFiBj7maI0p2EU7f5/A/Xs7sDK ddbg== 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=Yiz7MiIC+w5wxi7ovhqP5wkmEdrKSKSQKMo0rSjvbko=; b=Hf3T8aBvc98/JcA6M5y62xXnNlHK+MXPdsqt5kElYphZmyuN+Q5lAb/JuxNjZA3WGz LFF3jjKtCIohq3gEs0QjnF+fpbq0WX/EvO76rr/xlpFu9R5Zzbt1qU608pdZYWSsVLY4 Uf+W9DjWZEgztBQtZ3C9lyprsWaO4eDX+rLfP3RkNF9iAEnMKM+aMLMqtxAIbC6CPogS rJJaVyHEfFs6I24c8LtQ6k1NoDIaPwBC6Rgn6zLGmsXIjFviSbHz66hfaMe58VVTWByh 1WZBSuThA6Y7WtUkZAJDzyYU0U7iLSo4/yQMHHe2kOOStaP7C2QVR63DK5mKNrdNk/y5 tghw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=JTF2MCL5; 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 g5si3205064ejk.205.2021.10.28.02.50.24; Thu, 28 Oct 2021 02:50:53 -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=JTF2MCL5; 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 S230169AbhJ1Juw (ORCPT + 99 others); Thu, 28 Oct 2021 05:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbhJ1Juu (ORCPT ); Thu, 28 Oct 2021 05:50:50 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43A03C061348 for ; Thu, 28 Oct 2021 02:48:23 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id d10so9140695wrb.1 for ; Thu, 28 Oct 2021 02:48:23 -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=Yiz7MiIC+w5wxi7ovhqP5wkmEdrKSKSQKMo0rSjvbko=; b=JTF2MCL5w0PpoQtF94DGwsa3VstO6Faq3yeusALoRsVLeuyTY044h/nYCZyewX8A8U cuiaM0GLTss4nOzwJOrpPfli1mxpQmBUtu80yJDHR5FZJvA+ua9/iVIeuVeM7By/QYbM 9FQxfRPwyDhdvuvHLcS2ZW1LnvCLIR6WqZtkI= 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=Yiz7MiIC+w5wxi7ovhqP5wkmEdrKSKSQKMo0rSjvbko=; b=VdkQF6Vu8DMNMy9enlhTlYK2fMGqjvBOZh8PfO8lrRHBb+EPdYndzFVc5/6wEAkRA4 sGx3GJv8TMTk114578AawbzUsR8tI3QWWCnOp7cqJxyyhN36aknf+SLEKjfZWkAhfE39 dKDOe/Xk7ivKUYVkzy6rdNo8AKhuEDWin7H19Z8Hql6rA0IgPRRkwxfVEL1dUHgFDCcO uqTjtgkkfedC+w4wdSKYot5a3M434j0V8DdXwcgRw8y4xz8e8sH0Sb+ZUFmqD8+Pt+iI 0PmdqTCUTJ1AdMQPO8Lk0g+ujj8Kxi0Ld1ii3k6jcddWg8GX7IVnZDl1b4y2iPWBwncc Jj1w== X-Gm-Message-State: AOAM5330EXy06fgafJ+QXETrKJNDXNPNeMhfz1R0EhLfy90KC5dPr5O6 DrKKYaNaWDukf48NPzhoF699iA== X-Received: by 2002:adf:e483:: with SMTP id i3mr4231238wrm.175.1635414501867; Thu, 28 Oct 2021 02:48:21 -0700 (PDT) Received: from altair.lan (2.f.6.6.b.3.3.0.3.a.d.b.6.0.6.0.f.f.6.2.a.5.a.7.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:7a5a:26ff:606:bda3:33b:66f2]) by smtp.googlemail.com with ESMTPSA id i6sm3378029wry.71.2021.10.28.02.48.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 02:48:21 -0700 (PDT) From: Lorenz Bauer To: viro@zeniv.linux.org.uk, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: mszeredi@redhat.com, gregkh@linuxfoundation.org, Lorenz Bauer , 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 Message-Id: <20211028094724.59043-3-lmb@cloudflare.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211028094724.59043-1-lmb@cloudflare.com> References: <20211028094724.59043-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. Signed-off-by: Lorenz Bauer --- 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