OSDN Git Service

fat: add renameat2 RENAME_EXCHANGE flag support
authorJavier Martinez Canillas <javierm@redhat.com>
Fri, 10 Jun 2022 07:57:20 +0000 (09:57 +0200)
committerakpm <akpm@linux-foundation.org>
Fri, 17 Jun 2022 02:58:22 +0000 (19:58 -0700)
commitda87e1725ae2136baeb9aac04c572c283afc917f
tree5819ea0d697708730d1b0e394c8db7fb25989cac
parent204d03203a145b443cd8676dc12dbb47e1a3751f
fat: add renameat2 RENAME_EXCHANGE flag support

The renameat2 RENAME_EXCHANGE flag allows to atomically exchange two paths
but is currently not supported by the Linux vfat filesystem driver.

Add a vfat_rename_exchange() helper function that implements this support.

The super block lock is acquired during the operation to ensure atomicity,
and in the error path actions made are reversed also with the mutex held.

It makes the operation as transactional as possible, within the limitation
impossed by vfat due not having a journal with logs to replay.

Link: https://lkml.kernel.org/r/20220610075721.1182745-4-javierm@redhat.com
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Alexander Larsson <alexl@redhat.com>
Cc: Christian Kellner <ckellner@redhat.com>
Cc: Chung-Chiang Cheng <cccheng@synology.com>
Cc: Colin Walters <walters@verbum.org>
Cc: Lennart Poettering <lennart@poettering.net>
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Peter Jones <pjones@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/fat/namei_vfat.c