Skip to content

Commit

Permalink
xfs: flush speculative space allocations when we run out of space
Browse files Browse the repository at this point in the history
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 <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
  • Loading branch information
Darrick J. Wong committed Feb 3, 2021
1 parent 85c5b27 commit a1a7d05
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fs/xfs/xfs_trans.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ xfs_trans_alloc(
tp->t_firstblock = NULLFSBLOCK;

error = xfs_trans_reserve(tp, resp, blocks, rtextents);
if (error == -ENOSPC) {
/*
* We weren't able to reserve enough space for the transaction.
* Flush the other speculative space allocations to free space.
* Do not perform a synchronous scan because callers can hold
* other locks.
*/
error = xfs_blockgc_free_space(mp, NULL);
if (!error)
error = xfs_trans_reserve(tp, resp, blocks, rtextents);
}
if (error) {
xfs_trans_cancel(tp);
return error;
Expand Down

0 comments on commit a1a7d05

Please sign in to comment.