From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2E22C433EF for ; Tue, 24 May 2022 07:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235338AbiEXHgi (ORCPT ); Tue, 24 May 2022 03:36:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235322AbiEXHgb (ORCPT ); Tue, 24 May 2022 03:36:31 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 64852522C0 for ; Tue, 24 May 2022 00:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653377787; 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=uosxK4cQkjZjNxJr746xjmTAMJsu6zGR2xaVMuHwMwY=; b=Qt1iBhOsZNcAsFMZbNB4VuLDJlvi/hl1gaXSms6RS/1z22oCqQRgEg5QC5ODww4s7I2REK H00RD9N8XXi6V6RJfvZ+GgOHc2NAe+6lHs08x+ZFnaOcVxc5bmEe9ASm/txiuwvIYWTtuy 8HllEr1mLBzoVk5Nqsuhl1tZ6psYgwU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-176-hWBNZWK9OjKd8JkIL-7Wqw-1; Tue, 24 May 2022 03:36:24 -0400 X-MC-Unique: hWBNZWK9OjKd8JkIL-7Wqw-1 Received: by mail-wr1-f70.google.com with SMTP id bu4-20020a056000078400b0020e61501044so4439531wrb.0 for ; Tue, 24 May 2022 00:36:24 -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=uosxK4cQkjZjNxJr746xjmTAMJsu6zGR2xaVMuHwMwY=; b=z+qVZMG5kI4Wq9EGedu2Daj49gsmrueYp12Giw9aXOte5iX8j/52zywR7TgvwLObPB J+hFZn7vwIFkLHGbPlf6iKu8bzd+mrFLEB+5b2IRCbpz4zrZKs+DeOfbkdhSTOSwXm4W IZ15G7tgWhHlVDR7M5j33fipN4HCkff22Wb8PXE8wngzYgdepaZudYut0hqUa0pnPaAd AKALWz7ia5kRmD5O1TfuOdWaGuAzEXznrVeM9YJxok9fBkG5I3nSqN6s8s6x2AAuoVWw REqendEHBz3sX4cVcXFZ+KojGUW24s/C3yc7O/HVVDXGUadd8+aMSz7/uD0bG3w6mFsI /2IA== X-Gm-Message-State: AOAM530RLv6+tACMv5ANpWJnmbNSawNZWNtZJ1bZle5EmO9lPPNtviYA sA2LRdvgT3i7VLMl1E3LmMdIwOWee0E75kNxzv71zMp5YfLrxKIyFasjf1kxDWo5NvKavlJ9/Zj KSD9HXonA7dMMvGAHy07aNYaeJYRlc0rN+bFnSZbtm4I7+FoQjQwuE/KS0Ky/2zjEQwp+aQZusn w= X-Received: by 2002:a7b:c2a9:0:b0:397:9a4:f66b with SMTP id c9-20020a7bc2a9000000b0039709a4f66bmr2454157wmk.128.1653377783466; Tue, 24 May 2022 00:36:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/Cwz5jOogKed9CA8JaKkoHRc42pmAwU1T7LN2zbNsfSba8Fm0H5+hJzMmRKFlhnD9ie+/vQ== X-Received: by 2002:a7b:c2a9:0:b0:397:9a4:f66b with SMTP id c9-20020a7bc2a9000000b0039709a4f66bmr2454124wmk.128.1653377783103; Tue, 24 May 2022 00:36:23 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id f2-20020adfc982000000b0020c5253d927sm12202174wrh.115.2022.05.24.00.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 00:36:22 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Chung-Chiang Cheng , Lennart Poettering , Colin Walters , Peter Jones , Alexander Larsson , Alberto Ruiz , Christian Kellner , Javier Martinez Canillas , OGAWA Hirofumi , Shuah Khan , linux-kselftest@vger.kernel.org Subject: [PATCH v2 0/3] fat: add support for the renameat2 RENAME_EXCHANGE flag Date: Tue, 24 May 2022 09:36:01 +0200 Message-Id: <20220524073604.247790-1-javierm@redhat.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, This series add 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 in patch #2 and finally patch #3 adds some kselftests to test it. This is a v2 that addresses issues pointed out in the first version that was posted as an RFC: https://lore.kernel.org/lkml/20220519092343.2776414-1-javierm@redhat.com/ [0]: https://github.com/ostreedev/ostree [1]: https://github.com/ostreedev/ostree/issues/1649 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 MAINTAINERS | 1 + fs/fat/namei_vfat.c | 193 +++++++++++++++++- tools/testing/selftests/Makefile | 1 + .../selftests/filesystems/fat/Makefile | 7 + .../testing/selftests/filesystems/fat/config | 2 + .../filesystems/fat/rename_exchange.c | 37 ++++ .../filesystems/fat/run_fat_tests.sh | 82 ++++++++ 7 files changed, 316 insertions(+), 7 deletions(-) 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