Re: [PATCH 12/12] xfs: flush speculative space allocations when we run out of space

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 29, 2021 at 11:10:47AM -0500, Brian Foster wrote:
> On Thu, Jan 28, 2021 at 06:18:54PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@xxxxxxxxxx>
> > 
> > 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@xxxxxxxxxx>
> > Reviewed-by: Christoph Hellwig <hch@xxxxxx>
> > ---
> >  fs/xfs/xfs_trans.c |   12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> > 
> > 
> > diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> > index b08bb5a8fb60..3c2b26a21c6d 100644
> > --- a/fs/xfs/xfs_trans.c
> > +++ b/fs/xfs/xfs_trans.c
> > @@ -289,6 +289,18 @@ 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)
> > +			return error;
> > +		error = xfs_trans_reserve(tp, resp, blocks, rtextents);
> > +	}
> 
> We probably want to cancel the transaction if the scan fails. Perhaps
> tweak this to:
> 
> 		...
> 		error = xfs_blockgc_free_space(mp, NULL);
> 		if (!error)
> 			error = xfs_trans_reserve(tp, resp, blocks, rtextents);
> 	}
> 	...
> 
> Hm?

Doh, yes, good catch!  Will fix.

--D

> Brian
> 
> >  	if (error) {
> >  		xfs_trans_cancel(tp);
> >  		return error;
> > 
> 



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux