diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-08-30 15:45:05 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-10-09 09:39:23 -0700 |
commit | 700899d7c79c0ea916bc902100472c42ee577040 (patch) | |
tree | 5adb3d28a00d7e912824da4f712fbb447ed66abc /fs/xfs/xfs_iomap.c | |
parent | 055f78e8d716546e7eeb3733cc40e564ff3e6cdc (diff) |
xfs: flush speculative space allocations when we run out of spacereclaim-space-harder_2019-10-09
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 <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/xfs_iomap.c')
-rw-r--r-- | fs/xfs/xfs_iomap.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index d1b8618fa675..61048aa27728 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -262,6 +262,18 @@ xfs_iomap_write_direct( retry: error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, resrtextents, tflags, &tp); + /* + * We weren't able to reserve enough space for the direct write. Flush + * any disk space that was being held in the hopes of speeding up the + * filesystem. Historically, we expected callers to have preallocated + * all the space before a direct write, but this is not an absolute + * requirement. We still hold the IOLOCK so we cannot do a sync scan. + */ + if (error == -ENOSPC && !cleared_space) { + cleared_space = true; + xfs_inode_free_blocks(ip->i_mount, false); + goto retry; + } if (error) return error; |