Revert "btrfs: canonicalize the device path before adding it"
authorQu Wenruo <wqu@suse.com>
Thu, 16 Jan 2025 22:39:34 +0000 (09:09 +1030)
committerDavid Sterba <dsterba@suse.com>
Fri, 2 May 2025 11:20:26 +0000 (13:20 +0200)
commit8fb1dcbbcc1ffe6ed7cf3f0f96d2737491dd1fbf
tree6604d3bbd8a1b1f2b75333f21da3770ffe7eed9d
parentf95d186255b319c48a365d47b69bd997fecb674e
Revert "btrfs: canonicalize the device path before adding it"

This reverts commit 7e06de7c83a746e58d4701e013182af133395188.

Commit 7e06de7c83a7 ("btrfs: canonicalize the device path before adding
it") tries to make btrfs to use "/dev/mapper/*" name first, then any
filename inside "/dev/" as the device path.

This is mostly fine when there is only the root namespace involved, but
when multiple namespace are involved, things can easily go wrong for the
d_path() usage.

As d_path() returns a file path that is namespace dependent, the
resulted string may not make any sense in another namespace.

Furthermore, the "/dev/" prefix checks itself is not reliable, one can
still make a valid initramfs without devtmpfs, and fill all needed
device nodes manually.

Overall the userspace has all its might to pass whatever device path for
mount, and we are not going to win the war trying to cover every corner
case.

So just revert that commit, and do no extra d_path() based file path
sanity check.

CC: stable@vger.kernel.org # 6.12+
Link: https://lore.kernel.org/linux-fsdevel/20250115185608.GA2223535@zen.localdomain/
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c