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 | 055f78e8d716546e7eeb3733cc40e564ff3e6cdc (patch) | |
tree | e651cd13f4bbad8cde71ebff4b97b52b0b9a46bf /fs/xfs/xfs_inode.c | |
parent | f5af145228885fd3a3fb4cf391b70f52304ca651 (diff) |
xfs: flush speculative space allocations when we run out of quota
If a fs modification (creation, file write, reflink, etc.) is unable to
reserve enough quota 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_inode.c')
-rw-r--r-- | fs/xfs/xfs_inode.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 4d0a373a3229..a96e2ce6a5c5 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1135,6 +1135,7 @@ xfs_create( struct xfs_dquot *gdqp = NULL; struct xfs_dquot *pdqp = NULL; struct xfs_trans_res *tres; + bool cleared_space = false; uint resblks; trace_xfs_create(dp, name); @@ -1168,6 +1169,7 @@ xfs_create( * the case we'll drop the one we have and get a more * appropriate transaction later. */ +retry: error = xfs_trans_alloc(mp, tres, resblks, 0, 0, &tp); if (error == -ENOSPC) { /* flush outstanding delalloc blocks and retry */ @@ -1185,6 +1187,21 @@ xfs_create( */ error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, pdqp, resblks, 1, 0); + /* + * We weren't able to reserve enough quota to handle adding the inode. + * Flush any disk space that was being held in the hopes of speeding up + * the filesystem. + */ + if ((error == -EDQUOT || error == -ENOSPC) && !cleared_space) { + xfs_trans_cancel(tp); + if (unlock_dp_on_error) + xfs_iunlock(dp, XFS_ILOCK_EXCL); + unlock_dp_on_error = false; + cleared_space = xfs_inode_free_quota_blocks(dp, true); + if (cleared_space) + goto retry; + goto out_release_inode; + } if (error) goto out_trans_cancel; |