]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: shorten inode item lifetime
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 26 Apr 2019 21:50:48 +0000 (16:50 -0500)
committerEric Sandeen <sandeen@redhat.com>
Fri, 26 Apr 2019 21:50:48 +0000 (16:50 -0500)
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>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/rdwr.c
libxfs/trans.c

index bc2ed38c1eb411cc6b84af0171a621c91b4ab3f7..a5efc805a5f641ec1de431640394ef583ae5b8cc 100644 (file)
@@ -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);
 }
index 4fdf4b1f36439c3538fdc2d2bbc27b181475ec58..db90624be9116480b5530a49a15cda81ecf1d16d 100644 (file)
@@ -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 */