Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp236916iol; Thu, 9 Jun 2022 02:55:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+q3d0rhaiOav8r8hIX3sLxvGLtn/LycWgWD3lv92VQXf5diPlMt7X+eBcGAnGCtaOa6Kz X-Received: by 2002:a17:906:90c7:b0:70c:d506:7821 with SMTP id v7-20020a17090690c700b0070cd5067821mr32192616ejw.259.1654768534888; Thu, 09 Jun 2022 02:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654768534; cv=none; d=google.com; s=arc-20160816; b=JQKb8Xyva6vNESjN4NTmLRzBqkDuhFrSc8a0EHYiyGhlfHxHfA1wLAdP+NBNXMxfNC MUkkLyJQblzed2nTdzFIVBfTOzVG1/mXtxTO8AiB/2B+3n47RjkDyWZ3YUQTdvH0Z1cF meayWI80/2WBP0Li89KMp30iWWUnQcidVNw1Put6MvHFTSw+8yHaEQvElKq4FG9oQJdA 5z5oMKdH5ZR3ldw6y2LN7MwQtFXcIXW+70LpfCMy9BhnNfg1tfBhmBOxcVNQw+Nv+dXp AiUK1UOldbBBtjEaLZbPIq4GOk7tW+5qCIfUiHnOEtzhNImAQBinMUIy2BTMX92U2ljL M9hA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=/OByrRXmDTIXHhVMaR8PwxE73rUJySQV3skcisuRFW4=; b=anzn8CNqNHvuS/3HEF3lIuGA7WpEr1HdTVbL80+r/JTuZ+/R4/RK1aD38pvfNqz2Y8 yF+ku3DREcK9j5Vk8o4LkLGRXJ/GdULjhCzdk26tS+1p/Ez2FrSdhIwGu0kaoKdly+zw FrEQUOruR9IWVbw3JgGuVngIV6bT2zAE7Ko2e0MHz43WSN6Thn/P254aoKpRkvAB6N5M nBPj1ckT4zVtpJAFwdyAmlA0b1GMItEgeFs8uYYn8P2C0NcRDOiCvqIjya3xuJ7pKCFh 4V+yHFMJV6oQfPgpI5WqQ0hnDDxEIfwZn5MJ2Z1MvipkOs3T/FII7ZUWbLJbSs8mHoyx XBmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NbLHW3Kz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx18-20020a170906a1d200b00711db4671a9si7527739ejb.634.2022.06.09.02.55.09; Thu, 09 Jun 2022 02:55:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NbLHW3Kz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242367AbiFIJg7 (ORCPT + 99 others); Thu, 9 Jun 2022 05:36:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbiFIJgz (ORCPT ); Thu, 9 Jun 2022 05:36:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0C4D322BEB for ; Thu, 9 Jun 2022 02:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654767412; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=/OByrRXmDTIXHhVMaR8PwxE73rUJySQV3skcisuRFW4=; b=NbLHW3KzgcdOZatpJOl2Ak/tJW8ww0vC59suiP9DZ2HM9NVhweWB7j9up4ul9TTZDucKWa 4syAK+2KB6C6HhISYimd4cfokxWjhg5tnbjJXF81vZiU2niDgjvyK4kaQmusB393M2we6q hbr1fB9utMPlNp2uq2/TWo65tlL1hXc= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-505-siX57AKxOZivtZzi5MVoKA-1; Thu, 09 Jun 2022 05:36:51 -0400 X-MC-Unique: siX57AKxOZivtZzi5MVoKA-1 Received: by mail-wm1-f70.google.com with SMTP id ay1-20020a05600c1e0100b0039c3a3fc6a4so8184095wmb.4 for ; Thu, 09 Jun 2022 02:36:51 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=/OByrRXmDTIXHhVMaR8PwxE73rUJySQV3skcisuRFW4=; b=HtA4iNJ/2DTtaNETSyckk1o1PSyJY3mcbh2QzWYP75iXNUDM++WWwdu0+PyLRR6grf m+WmDExVTDT9vgtIs+2Os2Bkc12YrnIuGHrvbNbbaISen78M8o4iy1Xt7JBxZCSjZD0N kekh2Hbdd8jxl36S1sBvXzCAfT8xHiavjdNvPd9dZ/E1YeAdba35PW2eAUvrbWAIrvhG S9/S3NWxAh9Jd//vVNvA5sfbPsr1cWm9+JZK73jDEnnNR0aiAexd6RqgSH+zUESwhYbC EfMS7EbyF39d5AoI1jBlDwk8QZJekVu/iPz2DRO/+iNvKVJQzjfQWWnNAzLEQR2DWAqm eiYA== X-Gm-Message-State: AOAM533BS2Xl8wcJzIe21rxe+wY8f4+vafwvs7wmCKsOsKQVBNyGNeWS FoAuXNpGuZ9uaC+9U1/ltETzi8SOV6kaKoGFb9UToDexG+UCNugm39j1xUHdcGcvclbRK9lW/pY 92E+YRaEC+CvU0MrHh08W45kOreeO5bZcZQsI1jDCqcMvxKblIgtndKu5QFiyEqe2cayJUUFBHx 8= X-Received: by 2002:a05:600c:35d4:b0:39c:2541:7571 with SMTP id r20-20020a05600c35d400b0039c25417571mr2416251wmq.33.1654767409909; Thu, 09 Jun 2022 02:36:49 -0700 (PDT) X-Received: by 2002:a05:600c:35d4:b0:39c:2541:7571 with SMTP id r20-20020a05600c35d400b0039c25417571mr2416215wmq.33.1654767409553; Thu, 09 Jun 2022 02:36:49 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id m18-20020a05600c3b1200b00397122e63b6sm27385580wms.29.2022.06.09.02.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:36:49 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Peter Jones , Alexander Larsson , Colin Walters , Alberto Ruiz , Muhammad Usama Anjum , Lennart Poettering , Chung-Chiang Cheng , Christian Kellner , OGAWA Hirofumi , Carlos Maiolino , Javier Martinez Canillas , Shuah Khan , linux-kselftest@vger.kernel.org Subject: [PATCH v5 0/4] fat: add support for the renameat2 RENAME_EXCHANGE flag Date: Thu, 9 Jun 2022 11:36:33 +0200 Message-Id: <20220609093638.664034-1-javierm@redhat.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, The series adds support for the renameat2 system call RENAME_EXCHANGE flag (which allows to atomically replace two paths) to the vfat filesystem code. There are many use cases for this, but we are particularly interested in making possible for vfat filesystems to be part of OSTree [0] deployments. Currently OSTree relies on symbolic links to make the deployment updates an atomic transactional operation. But RENAME_EXCHANGE could be used [1] to achieve a similar level of robustness when using a vfat filesystem. Patch #1 is just a preparatory patch to introduce the RENAME_EXCHANGE support, patch #2 moves some code blocks in vfat_rename() to a set of helper functions, that can be reused by tvfat_rename_exchange() that's added by patch #3 and finally patch #4 adds some kselftests to test it. This is a v5 that addresses issues pointed out in v4: https://lore.kernel.org/lkml/18d9e587-b4f7-6ee7-185a-af0e667e0ec5@redhat.com/ [0]: https://github.com/ostreedev/ostree [1]: https://github.com/ostreedev/ostree/issues/1649 Changes in v5: - Only update nlink for different parent dirs and file types (OGAWA Hirofumi). Changes in v4: - Add new patch from OGAWA Hirofumi to use the helpers in vfat_rename(). - Rebase the patch on top of OGAWA Hirofumi proposed changes. - Drop iversion increment for old and new file inodes (OGAWA Hirofumi). - Add Muhammad Usama Anjum Acked-by tag. Changes in v3: - Add a .gitignore for the rename_exchange binary (Muhammad Usama Anjum). - Include $(KHDR_INCLUDES) instead of hardcoding a relative path in Makefile (Muhammad Usama Anjum). Changes in v2: - Only update the new_dir inode version and timestamps if != old_dir (Alex Larsson). - Add some helper functions to avoid duplicating code (OGAWA Hirofumi). - Use braces for multi-lines blocks even if are one statement (OGAWA Hirofumi). - Mention in commit message that the operation is as transactional as possible but within the vfat limitations of not having a journal (Colin Walters). - Call sync to flush the page cache before checking the file contents (Alex Larsson). - Drop RFC prefix since the patches already got some review. Javier Martinez Canillas (3): fat: add a vfat_rename2() and make existing .rename callback a helper fat: add renameat2 RENAME_EXCHANGE flag support selftests/filesystems: add a vfat RENAME_EXCHANGE test OGAWA Hirofumi (1): fat: factor out reusable code in vfat_rename() as helper functions MAINTAINERS | 1 + fs/fat/namei_vfat.c | 232 +++++++++++++++--- tools/testing/selftests/Makefile | 1 + .../selftests/filesystems/fat/.gitignore | 2 + .../selftests/filesystems/fat/Makefile | 7 + .../testing/selftests/filesystems/fat/config | 2 + .../filesystems/fat/rename_exchange.c | 37 +++ .../filesystems/fat/run_fat_tests.sh | 82 +++++++ 8 files changed, 325 insertions(+), 39 deletions(-) create mode 100644 tools/testing/selftests/filesystems/fat/.gitignore create mode 100644 tools/testing/selftests/filesystems/fat/Makefile create mode 100644 tools/testing/selftests/filesystems/fat/config create mode 100644 tools/testing/selftests/filesystems/fat/rename_exchange.c create mode 100755 tools/testing/selftests/filesystems/fat/run_fat_tests.sh -- 2.36.1