linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs: enhance btrfs device path rename
@ 2024-09-24  5:17 Qu Wenruo
  2024-09-24  5:17 ` [PATCH 1/2] btrfs: avoid unnecessary device path update for the same device Qu Wenruo
  2024-09-24  5:17 ` [PATCH 2/2] btrfs: canonicalize the device path before adding it Qu Wenruo
  0 siblings, 2 replies; 8+ messages in thread
From: Qu Wenruo @ 2024-09-24  5:17 UTC (permalink / raw)
  To: linux-btrfs

Fabian Vogt reported a very interesting case where we can use
"/proc/self/fd/3" to mount a btrfs, then that /proc name will remain as
the device path for the btrfs.

Sometimes udev scan can trigger a rename, and get a proper name back,
but if that doesn't win the race, we got the "/proc/self/fd/3" in the
mtab which makes no sense, since "/proc/self" is bounded to the current
process, no one is going to know where the real device is.

So to enhance the handling:

- Do proper path comparation to determine if we want to update device
  path
  Currently the path comparation is done by strcmp(), which will never
  handle hard nor soft links at all.

  Instead go with path_equal() on the resolved paths, which is way more
  reliable.
  This should reduce the unnecessary path name updates in the first
  place.

- Canonicalize the device path if it's not inside "/dev/"
  If we pass a soft link which is not inside "/dev/", we just follow the
  soft link and use the final destination instead.

  It can be something like "/dev/dm-2", other than more readable LVM
  names like "/dev/test/scratch1", but it's still way better than
  "/proc/self/fd/3".

  If the soft link itself is already inside "/dev/", then we can
  directly use the path.

  This is to allow fstest run properly without forced to use
  "/dev/dm-*" instead of the "/dev/mapper/test-scratch1" as test
  devices.
  Otherwise fs tests will reject runs because it believe the btrfs
  is mounted somewhere else.


Qu Wenruo (2):
  btrfs: avoid unnecessary device path update for the same device
  btrfs: canonicalize the device path before adding it

 fs/btrfs/volumes.c | 107 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 105 insertions(+), 2 deletions(-)

-- 
2.46.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-09-24 21:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-24  5:17 [PATCH 0/2] btrfs: enhance btrfs device path rename Qu Wenruo
2024-09-24  5:17 ` [PATCH 1/2] btrfs: avoid unnecessary device path update for the same device Qu Wenruo
2024-09-24 11:47   ` Filipe Manana
2024-09-24 21:12     ` Qu Wenruo
2024-09-24  5:17 ` [PATCH 2/2] btrfs: canonicalize the device path before adding it Qu Wenruo
2024-09-24 12:12   ` Filipe Manana
2024-09-24 16:21     ` Roman Mamedov
2024-09-24 21:16     ` Qu Wenruo

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).