From b1a24a8185c2a9e07e68e250a6caa841d2fabfa8 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Fri, 26 Apr 2019 16:50:48 -0500 Subject: [PATCH] libxfs: shorten inode item lifetime 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 Reviewed-by: Bill O'Donnell Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- 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 bc2ed38c1..a5efc805a 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 4fdf4b1f3..db90624be 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 @@ -921,6 +933,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 */ -- 2.39.2