Re: [PATCH] xfs: prevent close() from hanging on frozen filesystems
From: Christoph Hellwig
Date: Wed Jun 10 2026 - 09:35:32 EST
On Wed, Jun 10, 2026 at 01:13:41PM +0000, Aditya Srivastava wrote:
> A simple C reproducer demonstrating the hang (compile with -pthread):
Can you contribute this under the GPL or a compatible license, and
maybe even wire it up to xfstests?
> + /*
> + * If the filesystem is frozen or freezing, don't trigger transactions
> + * that would block close() indefinitely. Background block garbage
> + * collection will clean up these speculative preallocations once
> + * the filesystem thaws.
> + */
> + if (!xfs_fs_writable(mp, SB_FREEZE_WRITE))
> + return 0;
Note that this is still racy as the freeze could come in right after
this check. Basically what we'd need to fix this properly is a flag
to xfs_trans_alloc that uses sb_start_intwrite_trylock when set, and
returns a suitable error case in that case, which we'd then use to
unwind safely from release.