Skip to content

Commit a1a7d05

Browse files
author
Darrick J. Wong
committed
xfs: flush speculative space allocations when we run out of space
If a fs modification (creation, file write, reflink, etc.) is unable to reserve enough space to handle the modification, try clearing whatever space the filesystem might have been hanging onto in the hopes of speeding up the filesystem. The flushing behavior will become particularly important when we add deferred inode inactivation because that will increase the amount of space that isn't actively tied to user data. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Brian Foster <[email protected]>
1 parent 85c5b27 commit a1a7d05

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

fs/xfs/xfs_trans.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,17 @@ xfs_trans_alloc(
289289
tp->t_firstblock = NULLFSBLOCK;
290290

291291
error = xfs_trans_reserve(tp, resp, blocks, rtextents);
292+
if (error == -ENOSPC) {
293+
/*
294+
* We weren't able to reserve enough space for the transaction.
295+
* Flush the other speculative space allocations to free space.
296+
* Do not perform a synchronous scan because callers can hold
297+
* other locks.
298+
*/
299+
error = xfs_blockgc_free_space(mp, NULL);
300+
if (!error)
301+
error = xfs_trans_reserve(tp, resp, blocks, rtextents);
302+
}
292303
if (error) {
293304
xfs_trans_cancel(tp);
294305
return error;

0 commit comments

Comments
 (0)