]> git.ipfire.org Git - thirdparty/systemd.git/commit
repart: Discard only once
authorKai Lüke <kai@amutable.com>
Thu, 5 Feb 2026 17:51:07 +0000 (18:51 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 10 Feb 2026 12:09:33 +0000 (13:09 +0100)
commiteefb46c83b130ccec16891c3dd89aa4f32229e80
tree97c55e0b19619356c9120d761f79e71ef785079a
parent7081618cd9dad1515b65143ee99935c8ac2b1458
repart: Discard only once

The indirect discard in mkfs.btrfs on the loop device mapped to the
region on disk can hang and fail the first-boot creation of the rootfs.
Since there already is a discard done we anyway don't need to do it
twice. This might help for most cases to avoid the failure in
mkfs.btrfs.
Keep track if the direct discard worked and then skip the mkfs.btrfs
discard if it did. This still leaves the case where mkfs.btrfs can hang
when the direct discard couldn't succeed and mkfs.btrfs tries again but
since the conditions are rather the same it might be that this case is
not easy to trigger. If the problem still shows up and the kernel won't
be fixed soon we can still disable the mkfs discard for at least btrfs.
src/repart/repart.c