From: Ravi Singh <ravising@redhat.com>
To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: djwong@kernel.org, dchinner@redhat.com, esandeen@redhat.com,
cem@kernel.org
Subject: [PATCH v2] xfs: flush delalloc blocks on ENOSPC in xfs_trans_alloc_icreate
Date: Mon, 20 Apr 2026 10:06:37 +0000 [thread overview]
Message-ID: <20260420100637.3584-1-ravising@redhat.com> (raw)
In-Reply-To: <aeBv_xvDTmuzEhV1@infradead.org>
xfs_trans_alloc_icreate() can fail with ENOSPC when delalloc
reservations have consumed most of the available block count
(fdblocks). xfs_trans_alloc() already retries internally with
xfs_blockgc_flush_all(), but that only trims post-EOF speculative
preallocation and may not free enough space for the transaction
reservation.
Add a retry with xfs_flush_inodes() when xfs_trans_alloc() returns
ENOSPC. This forces writeback of all dirty inodes via
sync_inodes_sb(), converting delalloc reservations to real
allocations and freeing the over-reserved portion back to fdblocks.
This fixes all callers of xfs_trans_alloc_icreate() and removes
the existing caller-level retry from xfs_create(), which is now
handled centrally.
Signed-off-by: Ravi Singh <ravising@redhat.com>
---
v2:
- Moved xfs_flush_inodes() retry into xfs_trans_alloc_icreate()
instead of xfs_symlink() (Christoph)
- Removed caller-level retry from xfs_create()
- All callers now covered: xfs_create, xfs_symlink,
xfs_create_tmpfile, xcrep_tempfile_create
fs/xfs/xfs_inode.c | 6 ------
fs/xfs/xfs_trans.c | 9 +++++++++
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index beaa26ec62da..9978ac1422fc 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -699,12 +699,6 @@ xfs_create(
*/
error = xfs_trans_alloc_icreate(mp, tres, udqp, gdqp, pdqp, resblks,
&tp);
- if (error == -ENOSPC) {
- /* flush outstanding delalloc blocks and retry */
- xfs_flush_inodes(mp);
- error = xfs_trans_alloc_icreate(mp, tres, udqp, gdqp, pdqp,
- resblks, &tp);
- }
if (error)
goto out_parent;
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index bcc470f56e46..2796634b7d2b 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -1186,6 +1186,9 @@ xfs_trans_reserve_more_inode(
/*
* Allocate an transaction in preparation for inode creation by reserving quota
* against the given dquots. Callers are not required to hold any inode locks.
+ * If the block reservation fails with ENOSPC, flush all delalloc blocks to
+ * reclaim space from speculative preallocation and retry. This is similar to
+ * the quota retry but targets FS-wide ENOSPC.
*/
int
xfs_trans_alloc_icreate(
@@ -1199,10 +1202,16 @@ xfs_trans_alloc_icreate(
{
struct xfs_trans *tp;
bool retried = false;
+ bool flushed = false;
int error;
retry:
error = xfs_trans_alloc(mp, resv, dblocks, 0, 0, &tp);
+ if (error == -ENOSPC && !flushed) {
+ xfs_flush_inodes(mp);
+ flushed = true;
+ goto retry;
+ }
if (error)
return error;
--
2.53.0
next prev parent reply other threads:[~2026-04-20 10:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 7:16 [PATCH] xfs: flush delalloc blocks on ENOSPC when creating symlinks Ravi Singh
2026-04-15 7:20 ` Christoph Hellwig
2026-04-15 13:24 ` Ravi Singh
2026-04-15 14:14 ` Eric Sandeen
2026-04-16 5:13 ` Christoph Hellwig
2026-04-20 9:58 ` Ravi Singh
2026-04-20 10:06 ` Ravi Singh [this message]
2026-04-22 6:27 ` [PATCH v2] xfs: flush delalloc blocks on ENOSPC in xfs_trans_alloc_icreate Christoph Hellwig
2026-04-22 7:42 ` Ravi Singh
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=20260420100637.3584-1-ravising@redhat.com \
--to=ravising@redhat.com \
--cc=cem@kernel.org \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=esandeen@redhat.com \
--cc=linux-fsdevel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.