diff mbox series

[10/10] libxfs: shorten inode item lifetime

Message ID 155594795339.115924.2841573798611518042.stgit@magnolia (mailing list archive)
State Accepted, archived
Headers show
Series xfsprogs-5.0: fix various problems | expand

Commit Message

Darrick J. Wong April 22, 2019, 3:45 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Shorten the inode item lifetime so that we only keep them around while
the inode is joined with a transaction.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/rdwr.c  |    4 +---
 libxfs/trans.c |   19 ++++++++++++++++---
 2 files changed, 17 insertions(+), 6 deletions(-)

Comments

Bill O'Donnell April 23, 2019, 9:22 p.m. UTC | #1
On Mon, Apr 22, 2019 at 08:45:53AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Shorten the inode item lifetime so that we only keep them around while
> the inode is joined with a transaction.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Reviewed-by: Bill O'Donnell <billodo@redhat.com>

> ---
>  libxfs/rdwr.c  |    4 +---
>  libxfs/trans.c |   19 ++++++++++++++++---
>  2 files changed, 17 insertions(+), 6 deletions(-)
> 
> 
> diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
> index bc2ed38c..a5efc805 100644
> --- a/libxfs/rdwr.c
> +++ b/libxfs/rdwr.c
> @@ -1428,9 +1428,7 @@ void
>  libxfs_irele(
>  	struct xfs_inode	*ip)
>  {
> -	if (ip->i_itemp)
> -		kmem_zone_free(xfs_ili_zone, ip->i_itemp);
> -	ip->i_itemp = NULL;
> +	ASSERT(ip->i_itemp == NULL);
>  	libxfs_idestroy(ip);
>  	kmem_zone_free(xfs_inode_zone, ip);
>  }
> diff --git a/libxfs/trans.c b/libxfs/trans.c
> index 22926236..1dcdebf3 100644
> --- a/libxfs/trans.c
> +++ b/libxfs/trans.c
> @@ -785,6 +785,16 @@ _("Transaction block reservation exceeded! %u > %u\n"),
>  	tp->t_flags |= (XFS_TRANS_SB_DIRTY | XFS_TRANS_DIRTY);
>  }
>  
> +static void
> +xfs_inode_item_put(
> +	struct xfs_inode_log_item	*iip)
> +{
> +	struct xfs_inode		*ip = iip->ili_inode;
> +
> +	ip->i_itemp = NULL;
> +	kmem_zone_free(xfs_ili_zone, iip);
> +}
> +
>  
>  /*
>   * Transaction commital code follows (i.e. write to disk in libxfs)
> @@ -809,7 +819,7 @@ inode_item_done(
>  	if (!(iip->ili_fields & XFS_ILOG_ALL)) {
>  		ip->i_transp = NULL;	/* disassociate from transaction */
>  		iip->ili_flags = 0;	/* reset all flags */
> -		return;
> +		goto free;
>  	}
>  
>  	/*
> @@ -819,7 +829,7 @@ inode_item_done(
>  	if (error) {
>  		fprintf(stderr, _("%s: warning - imap_to_bp failed (%d)\n"),
>  			progname, error);
> -		return;
> +		goto free;
>  	}
>  
>  	/*
> @@ -835,7 +845,7 @@ inode_item_done(
>  		fprintf(stderr, _("%s: warning - iflush_int failed (%d)\n"),
>  			progname, error);
>  		libxfs_putbuf(bp);
> -		return;
> +		goto free;
>  	}
>  
>  	libxfs_writebuf(bp, 0);
> @@ -843,6 +853,8 @@ inode_item_done(
>  	fprintf(stderr, "flushing dirty inode %llu, buffer %p\n",
>  			ip->i_ino, bp);
>  #endif
> +free:
> +	xfs_inode_item_put(iip);
>  }
>  
>  static void
> @@ -920,6 +932,7 @@ inode_item_unlock(
>  	ip->i_transp = NULL;
>  
>  	iip->ili_flags = 0;
> +	xfs_inode_item_put(iip);
>  }
>  
>  /* Detach and unlock all of the items in a transaction */
>
diff mbox series

Patch

diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index bc2ed38c..a5efc805 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -1428,9 +1428,7 @@  void
 libxfs_irele(
 	struct xfs_inode	*ip)
 {
-	if (ip->i_itemp)
-		kmem_zone_free(xfs_ili_zone, ip->i_itemp);
-	ip->i_itemp = NULL;
+	ASSERT(ip->i_itemp == NULL);
 	libxfs_idestroy(ip);
 	kmem_zone_free(xfs_inode_zone, ip);
 }
diff --git a/libxfs/trans.c b/libxfs/trans.c
index 22926236..1dcdebf3 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -785,6 +785,16 @@  _("Transaction block reservation exceeded! %u > %u\n"),
 	tp->t_flags |= (XFS_TRANS_SB_DIRTY | XFS_TRANS_DIRTY);
 }
 
+static void
+xfs_inode_item_put(
+	struct xfs_inode_log_item	*iip)
+{
+	struct xfs_inode		*ip = iip->ili_inode;
+
+	ip->i_itemp = NULL;
+	kmem_zone_free(xfs_ili_zone, iip);
+}
+
 
 /*
  * Transaction commital code follows (i.e. write to disk in libxfs)
@@ -809,7 +819,7 @@  inode_item_done(
 	if (!(iip->ili_fields & XFS_ILOG_ALL)) {
 		ip->i_transp = NULL;	/* disassociate from transaction */
 		iip->ili_flags = 0;	/* reset all flags */
-		return;
+		goto free;
 	}
 
 	/*
@@ -819,7 +829,7 @@  inode_item_done(
 	if (error) {
 		fprintf(stderr, _("%s: warning - imap_to_bp failed (%d)\n"),
 			progname, error);
-		return;
+		goto free;
 	}
 
 	/*
@@ -835,7 +845,7 @@  inode_item_done(
 		fprintf(stderr, _("%s: warning - iflush_int failed (%d)\n"),
 			progname, error);
 		libxfs_putbuf(bp);
-		return;
+		goto free;
 	}
 
 	libxfs_writebuf(bp, 0);
@@ -843,6 +853,8 @@  inode_item_done(
 	fprintf(stderr, "flushing dirty inode %llu, buffer %p\n",
 			ip->i_ino, bp);
 #endif
+free:
+	xfs_inode_item_put(iip);
 }
 
 static void
@@ -920,6 +932,7 @@  inode_item_unlock(
 	ip->i_transp = NULL;
 
 	iip->ili_flags = 0;
+	xfs_inode_item_put(iip);
 }
 
 /* Detach and unlock all of the items in a transaction */