From: "Darrick J. Wong" <djwong@kernel.org>
To: Aditya Prakash Srivastava <aditya.ansh182@gmail.com>
Cc: Carlos Maiolino <cem@kernel.org>, Christoph Hellwig <hch@lst.de>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 1/1] xfs: prevent close() from hanging on frozen filesystems
Date: Mon, 14 Sep 2026 07:59:52 -0700 [thread overview]
Message-ID: <20260914145952.GN6265@frogsfrogsfrogs> (raw)
In-Reply-To: <20260914093152.1698-2-aditya.ansh182@gmail.com>
On Mon, Sep 14, 2026 at 09:31:51AM +0000, Aditya Prakash Srivastava wrote:
> When a file is closed, xfs_file_release() attempts to trim speculative
> post-EOF blocks. This requires allocating a transaction, which blocks
> indefinitely if the filesystem is frozen.
>
> Fix the hang by wrapping the preallocation cleanup block with
> sb_start_write_trylock() and xfs_ilock_nowait() to bypass the trim
> best-effort when the filesystem is frozen or locking fails.
>
> Suggested-by: Darrick J. Wong <djwong@kernel.org>
> Signed-off-by: Aditya Prakash Srivastava <aditya.ansh182@gmail.com>
Looks great, can't wait to see how the integration testing goes ;)
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_file.c | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index d8202da15aca..dd6d2e08faff 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -1872,17 +1872,21 @@ xfs_file_release(
> return 0;
>
> /*
> - * If we can't get the iolock just skip truncating the blocks past EOF
> - * because we could deadlock with the mmap_lock otherwise. We'll get
> - * another chance to drop them once the last reference to the inode is
> - * dropped, so we'll never leak blocks permanently.
> + * If we can't get the iolock or if the filesystem is frozen, just skip
> + * truncating the blocks past EOF because we could deadlock with the
> + * mmap_lock or hang the close() call. We'll get another chance to drop
> + * them once the last reference to the inode is dropped, so we'll never
> + * leak blocks permanently.
> */
> if (!xfs_iflags_test(ip, XFS_EOFBLOCKS_RELEASED) &&
> - xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
> - if (xfs_can_free_eofblocks(ip) &&
> - !xfs_iflags_test_and_set(ip, XFS_EOFBLOCKS_RELEASED))
> - xfs_free_eofblocks(ip);
> - xfs_iunlock(ip, XFS_IOLOCK_EXCL);
> + sb_start_write_trylock(mp->m_super)) {
> + if (xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
> + if (xfs_can_free_eofblocks(ip) &&
> + !xfs_iflags_test_and_set(ip, XFS_EOFBLOCKS_RELEASED))
> + xfs_free_eofblocks(ip);
> + xfs_iunlock(ip, XFS_IOLOCK_EXCL);
> + }
> + sb_end_write(mp->m_super);
> }
>
> return 0;
> --
> 2.47.3
>
>
prev parent reply other threads:[~2026-09-14 14:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 9:31 [PATCH v6 0/1] xfs: prevent close() hangs " Aditya Prakash Srivastava
2026-09-14 9:31 ` [PATCH v6 1/1] xfs: prevent close() from hanging " Aditya Prakash Srivastava
2026-09-14 14:59 ` Darrick J. Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260914145952.GN6265@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aditya.ansh182@gmail.com \
--cc=cem@kernel.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®