Re: [PATCH] fs: don't return -EINVAL for successful nested thaw
From: Lars Ellenberg
Date: Fri Aug 21 2026 - 06:12:14 EST
On Fri, Aug 21, 2026 at 10:54:51AM +0200, Moritz Tanner wrote:
> This breaks bdev-initiated freezing. When a filesystem is frozen with
> FIFREEZE and additionally frozen via bdev_freeze() -- which nests by
> design, see fs_bdev_freeze() -- the subsequent bdev_thaw() receives
> -EINVAL from the holder op although its freeze reference was dropped,
> and therefore keeps bd_fsfreeze_count elevated.
The other thaw order is the same defect seen from userspace: while the
bdev freeze is still held, fsfreeze -u returns EINVAL although it did
drop its reference, and the filesystem stays frozen until the block
layer holder thaws it.
In-kernel holders get the spurious error as well, whenever a userspace
freeze is held at the same time: xfs_scrub's xchk_fsthaw() carries the
comment "This should always succeed, we have a kernel freeze", and
f2fs_ioc_gc_range() hands the error to userspace.
Tested-by: Lars Ellenberg <lars.ellenberg@xxxxxxxxxx>
Reviewed-by: Lars Ellenberg <lars.ellenberg@xxxxxxxxxx>