diff options
author | Darrick J. Wong <djwong@kernel.org> | 2021-01-22 16:48:39 -0800 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2021-02-03 09:18:49 -0800 |
commit | a1a7d05a05765eec042942a5c360e909c0dd0131 (patch) | |
tree | 373b32e9a62675fab730b9ae0dbf76021668226b /fs/xfs | |
parent | 85c5b27075ba0389855d9f46ff1b1d5c34a44c94 (diff) | |
download | linux-a1a7d05a05765eec042942a5c360e909c0dd0131.tar.bz2 |
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 <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_trans.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index a23400f59e7d..44f72c09c203 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -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; |