* [PATCH v3] xfs: flush delalloc blocks on ENOSPC in xfs_trans_alloc_icreate
@ 2026-04-22 7:39 Ravi Singh
2026-04-23 5:09 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Ravi Singh @ 2026-04-22 7:39 UTC (permalink / raw)
To: linux-xfs, linux-fsdevel; +Cc: hch, djwong, dchinner, esandeen, cem
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>
---
v3:
- Moved comment to sit above the flush+retry code (Christoph)
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 | 11 +++++++++++
2 files changed, 11 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..148cc32449c1 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -1199,10 +1199,21 @@ 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) {
+ /*
+ * Flush all delalloc blocks to reclaim space from speculative
+ * preallocation. This is similar to the quota retry below
+ * but targets FS-wide ENOSPC.
+ */
+ xfs_flush_inodes(mp);
+ flushed = true;
+ goto retry;
+ }
if (error)
return error;
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] xfs: flush delalloc blocks on ENOSPC in xfs_trans_alloc_icreate
2026-04-22 7:39 [PATCH v3] xfs: flush delalloc blocks on ENOSPC in xfs_trans_alloc_icreate Ravi Singh
@ 2026-04-23 5:09 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2026-04-23 5:09 UTC (permalink / raw)
To: Ravi Singh; +Cc: linux-xfs, linux-fsdevel, hch, djwong, dchinner, esandeen, cem
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-23 5:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-22 7:39 [PATCH v3] xfs: flush delalloc blocks on ENOSPC in xfs_trans_alloc_icreate Ravi Singh
2026-04-23 5:09 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox