diff mbox series

[08/11] xfs: force inode inactivation and retry fs writes when there isn't space

Message ID 161543198495.1947934.14544893595452477454.stgit@magnolia (mailing list archive)
State Superseded, archived
Headers show
Series xfs: deferred inode inactivation | expand

Commit Message

Darrick J. Wong March 11, 2021, 3:06 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Any time we try to modify a file's contents and it fails due to ENOSPC
or EDQUOT, force inode inactivation work to try to free space.  We're
going to use the xfs_inodegc_free_space function externally in the next
patch, so add it to xfs_icache.h now to reduce churn.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/xfs_icache.c |   10 ++++++++--
 fs/xfs/xfs_icache.h |    1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig March 15, 2021, 6:54 p.m. UTC | #1
On Wed, Mar 10, 2021 at 07:06:25PM -0800, Darrick J. Wong wrote:
> +	error =  xfs_inode_walk(mp, 0, xfs_blockgc_scan_inode, eofb,
>  			XFS_ICI_BLOCKGC_TAG);

Nit: strange double whitespace here.
Darrick J. Wong March 15, 2021, 7:06 p.m. UTC | #2
On Mon, Mar 15, 2021 at 06:54:53PM +0000, Christoph Hellwig wrote:
> On Wed, Mar 10, 2021 at 07:06:25PM -0800, Darrick J. Wong wrote:
> > +	error =  xfs_inode_walk(mp, 0, xfs_blockgc_scan_inode, eofb,
> >  			XFS_ICI_BLOCKGC_TAG);
> 
> Nit: strange double whitespace here.

Yeah, that'll go away in the next version.  As part of a new small
series to eliminate the indirect calls in xfs_inode_walk when possible,
I figured out that we could get rid of the flags and tag arguments.

--D
diff mbox series

Patch

diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 6081bba3c6ce..594d340bbe37 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1868,10 +1868,16 @@  xfs_blockgc_free_space(
 	struct xfs_mount	*mp,
 	struct xfs_eofblocks	*eofb)
 {
+	int			error;
+
 	trace_xfs_blockgc_free_space(mp, eofb, _RET_IP_);
 
-	return xfs_inode_walk(mp, 0, xfs_blockgc_scan_inode, eofb,
+	error =  xfs_inode_walk(mp, 0, xfs_blockgc_scan_inode, eofb,
 			XFS_ICI_BLOCKGC_TAG);
+	if (error)
+		return error;
+
+	return xfs_inodegc_free_space(mp, eofb);
 }
 
 /*
@@ -2054,7 +2060,7 @@  xfs_inactive_inode(
  * corrupted, we still need to clear the INACTIVE iflag so that we can move
  * on to reclaiming the inode.
  */
-static int
+int
 xfs_inodegc_free_space(
 	struct xfs_mount	*mp,
 	struct xfs_eofblocks	*eofb)
diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h
index c199b920722a..9d5a1f4c0369 100644
--- a/fs/xfs/xfs_icache.h
+++ b/fs/xfs/xfs_icache.h
@@ -86,5 +86,6 @@  void xfs_inodegc_worker(struct work_struct *work);
 void xfs_inodegc_force(struct xfs_mount *mp);
 void xfs_inodegc_stop(struct xfs_mount *mp);
 void xfs_inodegc_start(struct xfs_mount *mp);
+int xfs_inodegc_free_space(struct xfs_mount *mp, struct xfs_eofblocks *eofb);
 
 #endif