* [PATCH] xfs: flush delalloc blocks on ENOSPC when creating symlinks
@ 2026-04-15 7:16 Ravi Singh
2026-04-15 7:20 ` Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Ravi Singh @ 2026-04-15 7:16 UTC (permalink / raw)
To: linux-xfs, linux-fsdevel; +Cc: djwong, dchinner, esandeen, cem
When creating symlinks on a nearly-full XFS filesystem,
xfs_symlink() fails with ENOSPC even though space could be
reclaimed from speculative preallocations. xfs_create() already
handles this by flushing outstanding delalloc blocks via
xfs_flush_inodes() and retrying the transaction allocation, but
xfs_symlink() returns the error immediately.
Add the same ENOSPC flush+retry logic to xfs_symlink() so that
symlink creation behaves consistently with file creation.
Signed-off-by: Ravi Singh <ravising@redhat.com>
---
fs/xfs/xfs_symlink.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index c4da624fb296..bf3cf23892eb 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -148,6 +148,12 @@ xfs_symlink(
error = xfs_trans_alloc_icreate(mp, &M_RES(mp)->tr_symlink, udqp, gdqp,
pdqp, resblks, &tp);
+ if (error == -ENOSPC) {
+ /* flush outstanding delalloc blocks and retry */
+ xfs_flush_inodes(mp);
+ error = xfs_trans_alloc_icreate(mp, &M_RES(mp)->tr_symlink,
+ udqp, gdqp, pdqp, resblks, &tp);
+ }
if (error)
goto out_parent;
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs: flush delalloc blocks on ENOSPC when creating symlinks
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
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2026-04-15 7:20 UTC (permalink / raw)
To: Ravi Singh; +Cc: linux-xfs, linux-fsdevel, djwong, dchinner, esandeen, cem
On Wed, Apr 15, 2026 at 07:16:57AM +0000, Ravi Singh wrote:
> When creating symlinks on a nearly-full XFS filesystem,
> xfs_symlink() fails with ENOSPC even though space could be
> reclaimed from speculative preallocations. xfs_create() already
> handles this by flushing outstanding delalloc blocks via
> xfs_flush_inodes() and retrying the transaction allocation, but
> xfs_symlink() returns the error immediately.
>
> Add the same ENOSPC flush+retry logic to xfs_symlink() so that
> symlink creation behaves consistently with file creation.
While we're at it - do we also want it for tempfiles and scrub?
i.e., should we move this logic into xfs_trans_alloc_icreate,
similar to the quota logic?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs: flush delalloc blocks on ENOSPC when creating symlinks
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
0 siblings, 2 replies; 5+ messages in thread
From: Ravi Singh @ 2026-04-15 13:24 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-xfs, linux-fsdevel, djwong, dchinner, esandeen, cem
On Wed, Apr 15, 2026 at 12:51 PM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Wed, Apr 15, 2026 at 07:16:57AM +0000, Ravi Singh wrote:
> > When creating symlinks on a nearly-full XFS filesystem,
> > xfs_symlink() fails with ENOSPC even though space could be
> > reclaimed from speculative preallocations. xfs_create() already
> > handles this by flushing outstanding delalloc blocks via
> > xfs_flush_inodes() and retrying the transaction allocation, but
> > xfs_symlink() returns the error immediately.
> >
> > Add the same ENOSPC flush+retry logic to xfs_symlink() so that
> > symlink creation behaves consistently with file creation.
>
> While we're at it - do we also want it for tempfiles and scrub?
> i.e., should we move this logic into xfs_trans_alloc_icreate,
> similar to the quota logic?
>
tmpfiles and scrub tempfiles are created without
directory entries, so they don't need a new directory block
allocation and don't hit this ENOSPC path.
As for moving the logic into xfs_trans_alloc_icreate(),
xfs_flush_inodes() is a heavier operation (sync_inodes_sb).
Pushing it down into xfs_trans_alloc_icreate() would make every
caller pay for that flush, including paths that don't need it.
I think keeping it in the callers that actually need it
(xfs_create and xfs_symlink) is the right scope.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs: flush delalloc blocks on ENOSPC when creating symlinks
2026-04-15 13:24 ` Ravi Singh
@ 2026-04-15 14:14 ` Eric Sandeen
2026-04-16 5:13 ` Christoph Hellwig
1 sibling, 0 replies; 5+ messages in thread
From: Eric Sandeen @ 2026-04-15 14:14 UTC (permalink / raw)
To: Ravi Singh, Christoph Hellwig
Cc: linux-xfs, linux-fsdevel, djwong, dchinner, cem
On 4/15/26 8:24 AM, Ravi Singh wrote:
> On Wed, Apr 15, 2026 at 12:51 PM Christoph Hellwig <hch@infradead.org> wrote:
>>
>> On Wed, Apr 15, 2026 at 07:16:57AM +0000, Ravi Singh wrote:
>>> When creating symlinks on a nearly-full XFS filesystem,
>>> xfs_symlink() fails with ENOSPC even though space could be
>>> reclaimed from speculative preallocations. xfs_create() already
>>> handles this by flushing outstanding delalloc blocks via
>>> xfs_flush_inodes() and retrying the transaction allocation, but
>>> xfs_symlink() returns the error immediately.
>>>
>>> Add the same ENOSPC flush+retry logic to xfs_symlink() so that
>>> symlink creation behaves consistently with file creation.
>>
>> While we're at it - do we also want it for tempfiles and scrub?
>> i.e., should we move this logic into xfs_trans_alloc_icreate,
>> similar to the quota logic?
>>
> tmpfiles and scrub tempfiles are created without
> directory entries, so they don't need a new directory block
> allocation and don't hit this ENOSPC path.
>
> As for moving the logic into xfs_trans_alloc_icreate(),
> xfs_flush_inodes() is a heavier operation (sync_inodes_sb).
> Pushing it down into xfs_trans_alloc_icreate() would make every
> caller pay for that flush, including paths that don't need it.
>
> I think keeping it in the callers that actually need it
> (xfs_create and xfs_symlink) is the right scope.
I think that's correct. I had looked at this and came to the same
conclusions after also thinking i.e. tmpfiles needed the same
treatment, couldn't reproduce it, then realized it's because it's
directory block allocation that needs the freed up space, something
tmpfiles don't require.
Thanks,
-Eric
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs: flush delalloc blocks on ENOSPC when creating symlinks
2026-04-15 13:24 ` Ravi Singh
2026-04-15 14:14 ` Eric Sandeen
@ 2026-04-16 5:13 ` Christoph Hellwig
1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2026-04-16 5:13 UTC (permalink / raw)
To: Ravi Singh
Cc: Christoph Hellwig, linux-xfs, linux-fsdevel, djwong, dchinner,
esandeen, cem
On Wed, Apr 15, 2026 at 06:54:00PM +0530, Ravi Singh wrote:
> > While we're at it - do we also want it for tempfiles and scrub?
> > i.e., should we move this logic into xfs_trans_alloc_icreate,
> > similar to the quota logic?
> >
> tmpfiles and scrub tempfiles are created without
> directory entries, so they don't need a new directory block
> allocation and don't hit this ENOSPC path.
But we still ned the ialloc space reservation for all these cases.
> As for moving the logic into xfs_trans_alloc_icreate(),
> xfs_flush_inodes() is a heavier operation (sync_inodes_sb).
> Pushing it down into xfs_trans_alloc_icreate() would make every
> caller pay for that flush, including paths that don't need it.
Only if we git enospc and need to restart the underlying
xfs_trans_alloc call, similar to how it handles quotas.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-16 5:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox