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 <darrick.wong@oracle.com>
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index bc2ed38..a5efc80 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -1428,9 +1428,7 @@
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 2292623..1dcdebf 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -785,6 +785,16 @@
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 @@
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 @@
if (error) {
fprintf(stderr, _("%s: warning - imap_to_bp failed (%d)\n"),
progname, error);
- return;
+ goto free;
}
/*
@@ -835,7 +845,7 @@
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 @@
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 @@
ip->i_transp = NULL;
iip->ili_flags = 0;
+ xfs_inode_item_put(iip);
}
/* Detach and unlock all of the items in a transaction */