On Sun, Jan 31, 2021 at 06:06:17PM -0800, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@xxxxxxxxxx> > > 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: Darrick J. Wong <djwong@xxxxxxxxxx> > --- Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx> > fs/xfs/xfs_trans.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > > diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c > index ee3cb916c5c9..3203841ab19b 100644 > --- a/fs/xfs/xfs_trans.c > +++ b/fs/xfs/xfs_trans.c > @@ -1149,8 +1149,10 @@ xfs_trans_alloc_ichange( > struct xfs_dquot *new_udqp; > struct xfs_dquot *new_gdqp; > struct xfs_dquot *new_pdqp; > + bool retried = false; > int error; > > +retry: > error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp); > if (error) > return error; > @@ -1175,6 +1177,13 @@ xfs_trans_alloc_ichange( > if (new_udqp || new_gdqp || new_pdqp) { > error = xfs_trans_reserve_quota_chown(tp, ip, new_udqp, > new_gdqp, new_pdqp, force); > + if (!retried && (error == -EDQUOT || error == -ENOSPC)) { > + xfs_trans_cancel(tp); > + xfs_blockgc_free_dquots(new_udqp, new_gdqp, new_pdqp, > + 0); > + retried = true; > + goto retry; > + } > if (error) > goto out_cancel; > } >