Commit 758303d1 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: flush eof/cowblocks if we can't reserve quota for chown

If a file user, group, or project change 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: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent c237dd7c
...@@ -1138,16 +1138,21 @@ xfs_trans_alloc_icreate( ...@@ -1138,16 +1138,21 @@ xfs_trans_alloc_icreate(
int int
xfs_trans_alloc_ichange( xfs_trans_alloc_ichange(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_dquot *udqp, struct xfs_dquot *new_udqp,
struct xfs_dquot *gdqp, struct xfs_dquot *new_gdqp,
struct xfs_dquot *pdqp, struct xfs_dquot *new_pdqp,
bool force, bool force,
struct xfs_trans **tpp) struct xfs_trans **tpp)
{ {
struct xfs_trans *tp; struct xfs_trans *tp;
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_dquot *udqp;
struct xfs_dquot *gdqp;
struct xfs_dquot *pdqp;
bool retried = false;
int error; int error;
retry:
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp);
if (error) if (error)
return error; return error;
...@@ -1165,14 +1170,12 @@ xfs_trans_alloc_ichange( ...@@ -1165,14 +1170,12 @@ xfs_trans_alloc_ichange(
/* /*
* For each quota type, skip quota reservations if the inode's dquots * For each quota type, skip quota reservations if the inode's dquots
* now match the ones that came from the caller, or the caller didn't * now match the ones that came from the caller, or the caller didn't
* pass one in. * pass one in. The inode's dquots can change if we drop the ILOCK to
* perform a blockgc scan, so we must preserve the caller's arguments.
*/ */
if (udqp == ip->i_udquot) udqp = (new_udqp != ip->i_udquot) ? new_udqp : NULL;
udqp = NULL; gdqp = (new_gdqp != ip->i_gdquot) ? new_gdqp : NULL;
if (gdqp == ip->i_gdquot) pdqp = (new_pdqp != ip->i_pdquot) ? new_pdqp : NULL;
gdqp = NULL;
if (pdqp == ip->i_pdquot)
pdqp = NULL;
if (udqp || gdqp || pdqp) { if (udqp || gdqp || pdqp) {
unsigned int qflags = XFS_QMOPT_RES_REGBLKS; unsigned int qflags = XFS_QMOPT_RES_REGBLKS;
...@@ -1188,6 +1191,12 @@ xfs_trans_alloc_ichange( ...@@ -1188,6 +1191,12 @@ xfs_trans_alloc_ichange(
error = xfs_trans_reserve_quota_bydquots(tp, mp, udqp, gdqp, error = xfs_trans_reserve_quota_bydquots(tp, mp, udqp, gdqp,
pdqp, ip->i_d.di_nblocks + ip->i_delayed_blks, pdqp, ip->i_d.di_nblocks + ip->i_delayed_blks,
1, qflags); 1, qflags);
if ((error == -EDQUOT || error == -ENOSPC) && !retried) {
xfs_trans_cancel(tp);
xfs_blockgc_free_dquots(mp, udqp, gdqp, pdqp, 0);
retried = true;
goto retry;
}
if (error) if (error)
goto out_cancel; goto out_cancel;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment