diff mbox series

[09/10] libxfs: fix buffer log item lifetime weirdness

Message ID 155594794719.115924.7816478131558954855.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>

In xfsprogs, the lifetime of xfs_buf log items doesn't match the kernel
because we keep them around after comitting or cancelling transactions.
This is confusing, so change the lifetime to be consistent.  Worse yet,
if an inode cluster buffer gets bjoined to a transaction (e.g. someone
called xfs_trans_read_buf) we'll leak it when flushing an inode core
back to that buffer.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/trans.c |    2 ++
 1 file changed, 2 insertions(+)

Comments

Bill O'Donnell April 23, 2019, 9:15 p.m. UTC | #1
On Mon, Apr 22, 2019 at 08:45:47AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> In xfsprogs, the lifetime of xfs_buf log items doesn't match the kernel
> because we keep them around after comitting or cancelling transactions.
> This is confusing, so change the lifetime to be consistent.  Worse yet,
> if an inode cluster buffer gets bjoined to a transaction (e.g. someone
> called xfs_trans_read_buf) we'll leak it when flushing an inode core
> back to that buffer.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

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

> ---
>  libxfs/trans.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> 
> diff --git a/libxfs/trans.c b/libxfs/trans.c
> index d562cdc0..22926236 100644
> --- a/libxfs/trans.c
> +++ b/libxfs/trans.c
> @@ -545,6 +545,7 @@ libxfs_trans_brelse(
>  	xfs_trans_del_item(&bip->bli_item);
>  	if (bip->bli_flags & XFS_BLI_HOLD)
>  		bip->bli_flags &= ~XFS_BLI_HOLD;
> +	xfs_buf_item_put(bip);
>  	bp->b_transp = NULL;
>  	libxfs_putbuf(bp);
>  }
> @@ -904,6 +905,7 @@ buf_item_unlock(
>  
>  	hold = bip->bli_flags & XFS_BLI_HOLD;
>  	bip->bli_flags &= ~XFS_BLI_HOLD;
> +	xfs_buf_item_put(bip);
>  	if (!hold)
>  		libxfs_putbuf(bp);
>  }
>
diff mbox series

Patch

diff --git a/libxfs/trans.c b/libxfs/trans.c
index d562cdc0..22926236 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -545,6 +545,7 @@  libxfs_trans_brelse(
 	xfs_trans_del_item(&bip->bli_item);
 	if (bip->bli_flags & XFS_BLI_HOLD)
 		bip->bli_flags &= ~XFS_BLI_HOLD;
+	xfs_buf_item_put(bip);
 	bp->b_transp = NULL;
 	libxfs_putbuf(bp);
 }
@@ -904,6 +905,7 @@  buf_item_unlock(
 
 	hold = bip->bli_flags & XFS_BLI_HOLD;
 	bip->bli_flags &= ~XFS_BLI_HOLD;
+	xfs_buf_item_put(bip);
 	if (!hold)
 		libxfs_putbuf(bp);
 }