linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christian Brauner <brauner@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [GIT PULL] vfs: rename
Date: Fri, 23 Jun 2023 13:02:37 +0200	[thread overview]
Message-ID: <20230623-gebacken-abenteuer-00d6913052b6@brauner> (raw)

Hey Linus,

/* Summary */
This contains the work from Jan to fix problems with cross-directory
renames originally reported in [1].

To quickly sum it up some filesystems (so far we know at least about
ext4, udf, f2fs, ocfs2, likely also reiserfs, gfs2 and others) need to
lock the directory when it is being renamed into another directory.

This is because we need to update the parent pointer in the directory in
that case and if that races with other operations on the directory, in
particular a conversion from one directory format into another, bad
things can happen.

So far we've done the locking in the filesystem code but recently
Darrick pointed out in [2] that the RENAME_EXCHANGE case was missing.
That one is particularly nasty because RENAME_EXCHANGE can arbitrarily
mix regular files and directories and proper lock ordering is not
achievable in the filesystems alone.

This patch set adds locking into vfs_rename() so that not only parent
directories but also moved inodes, regardless of whether they are
directories or not, are locked when calling into the filesystem.

This means establishing a locking order for unrelated directories. New
helpers are added for this purpose and our documentation is updated to
cover this in detail.

The locking is now actually easier to follow as we now always lock
source and target. We've always locked the target independent of whether
it was a directory or file and we've always locked source if it was a
regular file. The exact details for why this came about can be found in
[3] and [4].

Link: https://lore.kernel.org/all/20230117123735.un7wbamlbdihninm@quack3 [1]
Link: https://lore.kernel.org/all/20230517045836.GA11594@frogsfrogsfrogs [2]
Link: https://lore.kernel.org/all/20230526-schrebergarten-vortag-9cd89694517e@brauner [3]
Link: https://lore.kernel.org/all/20230530-seenotrettung-allrad-44f4b00139d4@brauner [4]

/* Testing */
clang: Ubuntu clang version 15.0.7
gcc: (Ubuntu 12.2.0-3ubuntu1) 12.2.0

All patches are based on v6.4-rc2 and have been sitting in linux-next.
No build failures or warnings were observed. All old and new tests in
fstests, selftests, and LTP pass without regressions.

/* Conflicts */
At the time of creating this PR no merge conflicts were reported from
linux-next and no merge conflicts showed up doing a test-merge with
current mainline.

The following changes since commit f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6:

  Linux 6.4-rc2 (2023-05-14 12:51:40 -0700)

are available in the Git repository at:

  git@gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs tags/v6.5/vfs.rename.locking

for you to fetch changes up to 2454ad83b90afbc6ed2c22ec1310b624c40bf0d3:

  fs: Restrict lock_two_nondirectories() to non-directory inodes (2023-06-07 09:15:11 +0200)

Please consider pulling these changes from the signed v6.5/vfs.rename.locking tag.

Thanks!
Christian

----------------------------------------------------------------
v6.5/vfs.rename.locking

----------------------------------------------------------------
Jan Kara (6):
      ext4: Remove ext4 locking of moved directory
      Revert "udf: Protect rename against modification of moved directory"
      Revert "f2fs: fix potential corruption when moving a directory"
      fs: Establish locking order for unrelated directories
      fs: Lock moved directories
      fs: Restrict lock_two_nondirectories() to non-directory inodes

 Documentation/filesystems/directory-locking.rst | 26 ++++++-----
 fs/ext4/namei.c                                 | 17 +------
 fs/f2fs/namei.c                                 | 16 +------
 fs/inode.c                                      | 62 +++++++++++++++++++++----
 fs/internal.h                                   |  2 +
 fs/namei.c                                      | 26 +++++++----
 fs/udf/namei.c                                  | 14 +-----
 7 files changed, 89 insertions(+), 74 deletions(-)

             reply	other threads:[~2023-06-23 11:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-23 11:02 Christian Brauner [this message]
2023-06-26 17:34 ` [GIT PULL] vfs: rename pr-tracker-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230623-gebacken-abenteuer-00d6913052b6@brauner \
    --to=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).