Go to file
Anand Jain d565fffa68 btrfs: do not skip re-registration for the mounted device
There are reports that since version 6.7 update-grub fails to find the
device of the root on systems without initrd and on a single device.

This looks like the device name changed in the output of
/proc/self/mountinfo:

6.5-rc5 working

  18 1 0:16 / / rw,noatime - btrfs /dev/sda8 ...

6.7 not working:

  17 1 0:15 / / rw,noatime - btrfs /dev/root ...

and "update-grub" shows this error:

  /usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?)

This looks like it's related to the device name, but grub-probe
recognizes the "/dev/root" path and tries to find the underlying device.
However there's a special case for some filesystems, for btrfs in
particular.

The generic root device detection heuristic is not done and it all
relies on reading the device infos by a btrfs specific ioctl. This ioctl
returns the device name as it was saved at the time of device scan (in
this case it's /dev/root).

The change in 6.7 for temp_fsid to allow several single device
filesystem to exist with the same fsid (and transparently generate a new
UUID at mount time) was to skip caching/registering such devices.

This also skipped mounted device. One step of scanning is to check if
the device name hasn't changed, and if yes then update the cached value.

This broke the grub-probe as it always read the device /dev/root and
couldn't find it in the system. A temporary workaround is to create a
symlink but this does not survive reboot.

The right fix is to allow updating the device path of a mounted
filesystem even if this is a single device one.

In the fix, check if the device's major:minor number matches with the
cached device. If they do, then we can allow the scan to happen so that
device_list_add() can take care of updating the device path. The file
descriptor remains unchanged.

This does not affect the temp_fsid feature, the UUID of the mounted
filesystem remains the same and the matching is based on device major:minor
which is unique per mounted filesystem.

This covers the path when the device (that exists for all mounted
devices) name changes, updating /dev/root to /dev/sdx. Any other single
device with filesystem and is not mounted is still skipped.

Note that if a system is booted and initial mount is done on the
/dev/root device, this will be the cached name of the device. Only after
the command "btrfs device scan" it will change as it triggers the
rename.

The fix was verified by users whose systems were affected.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=218353
Link: https://lore.kernel.org/lkml/CAKLYgeJ1tUuqLcsquwuFqjDXPSJpEiokrWK2gisPKDZLs8Y2TQ@mail.gmail.com/
Fixes: bc27d6f0aa ("btrfs: scan but don't register device on single device filesystem")
CC: stable@vger.kernel.org # 6.7+
Tested-by: Alex Romosan <aromosan@gmail.com>
Tested-by: CHECK_1234543212345@protonmail.com
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2024-03-18 19:16:50 +01:00
Documentation ARM: SoC drivers for 6.9 2024-03-12 10:35:24 -07:00
LICENSES
arch asm-generic updates for 6.9 2024-03-12 10:56:28 -07:00
block Revert "dm: use queue_limits_set" 2024-03-11 17:11:28 -07:00
certs
crypto crypto: lskcipher - Copy IV in lskcipher glue code always 2024-02-24 08:37:24 +08:00
drivers ARM: SoC drivers for 6.9 2024-03-12 10:35:24 -07:00
fs btrfs: do not skip re-registration for the mounted device 2024-03-18 19:16:50 +01:00
include for-6.9-tag 2024-03-12 12:28:34 -07:00
init Misc cleanups, including a large series from Thomas Gleixner to 2024-03-11 19:37:56 -07:00
io_uring for-6.9/io_uring-20240310 2024-03-11 11:35:31 -07:00
ipc
kernel Core x86 changes for v6.9: 2024-03-11 19:53:15 -07:00
lib s390 updates for 6.9 merge window 2024-03-12 10:14:22 -07:00
mm ARM: SoC drivers for 6.9 2024-03-12 10:35:24 -07:00
net Core x86 changes for v6.9: 2024-03-11 19:53:15 -07:00
rust workqueue: Changes for v6.9 2024-03-11 12:50:42 -07:00
samples work around gcc bugs with 'asm goto' with outputs 2024-02-09 15:57:48 -08:00
scripts asm-generic updates for 6.9 2024-03-12 10:56:28 -07:00
security integrity-v6.8-fix 2024-03-05 13:21:30 -08:00
sound ASoC: Fixes for v6.8 2024-03-08 08:53:36 +01:00
tools s390 updates for 6.9 merge window 2024-03-12 10:14:22 -07:00
usr Kbuild updates for v6.8 2024-01-18 17:57:07 -08:00
virt KVM: Make KVM_MEM_GUEST_MEMFD mutually exclusive with KVM_MEM_READONLY 2024-02-22 17:07:06 -08:00
.clang-format
.cocciconfig
.editorconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap drm fixes for 6.8 final 2024-03-08 12:44:56 -08:00
.rustfmt.toml
COPYING
CREDITS vfs-6.9.ntfs 2024-03-11 09:55:17 -07:00
Kbuild
Kconfig
MAINTAINERS ARM: SoC code updates for 6.9 2024-03-12 10:47:33 -07:00
Makefile Rust changes for v6.9 2024-03-11 12:31:28 -07:00
README

README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.