From: Brian Foster Date: Wed, 3 Jan 2018 19:42:03 +0000 (-0600) Subject: xfs: refactor buffer logging into buffer dirtying helper X-Git-Tag: v4.15.0-rc1~79^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59630067f764c9f76053058ed51c123da532dc76;p=thirdparty%2Fxfsprogs-dev.git xfs: refactor buffer logging into buffer dirtying helper Source kernel commit: 9684010d38eccda733b61106765e9357cf436f65 xfs_trans_log_buf() is responsible for logging the dirty segments of a buffer along with setting all of the necessary state on the transaction, buffer, bli, etc., to ensure that the associated items are marked as dirty and prepared for I/O. We have a couple use cases that need to to dirty a buffer in a transaction without actually logging dirty ranges of the buffer. One existing use case is ordered buffers, which are currently logged with arbitrary ranges to accomplish this even though the content of ordered buffers is never written to the log. Another pending use case is to relog an already dirty buffer across rolled transactions within the deferred operations infrastructure. This is required to prevent a held (XFS_BLI_HOLD) buffer from pinning the tail of the log. Refactor xfs_trans_log_buf() into a new function that contains all of the logic responsible to dirty the transaction, lidp, buffer and bli. This new function can be used in the future for the use cases outlined above. This patch does not introduce functional changes. Signed-off-by: Brian Foster Reviewed-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- diff --git a/include/xfs_trans.h b/include/xfs_trans.h index 353556862..d76a32401 100644 --- a/include/xfs_trans.h +++ b/include/xfs_trans.h @@ -106,6 +106,7 @@ void libxfs_trans_brelse(struct xfs_trans *, struct xfs_buf *); void libxfs_trans_binval(struct xfs_trans *, struct xfs_buf *); void libxfs_trans_bjoin(struct xfs_trans *, struct xfs_buf *); void libxfs_trans_bhold(struct xfs_trans *, struct xfs_buf *); +void libxfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *); void libxfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, uint, uint); bool libxfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *); diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 84a4fc25e..5d2ca2fba 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -49,6 +49,7 @@ #define xfs_trans_ijoin_ref libxfs_trans_ijoin_ref #define xfs_trans_init libxfs_trans_init #define xfs_trans_inode_alloc_buf libxfs_trans_inode_alloc_buf +#define xfs_trans_dirty_buf libxfs_trans_dirty_buf #define xfs_trans_log_buf libxfs_trans_log_buf #define xfs_trans_ordered_buf libxfs_trans_ordered_buf #define xfs_trans_log_inode libxfs_trans_log_inode diff --git a/libxfs/trans.c b/libxfs/trans.c index 3d6de982e..3d64f2622 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -356,6 +356,27 @@ libxfs_trans_roll_inode( } +/* + * Mark a buffer dirty in the transaction. + */ +void +libxfs_trans_dirty_buf( + struct xfs_trans *tp, + struct xfs_buf *bp) +{ + struct xfs_buf_log_item *bip; + + ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp); + ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); + + bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *); +#ifdef XACT_DEBUG + fprintf(stderr, "dirtied buffer %p, transaction %p\n", bp, tp); +#endif + tp->t_flags |= XFS_TRANS_DIRTY; + bip->bli_item.li_desc->lid_flags |= XFS_LID_DIRTY; +} + /* * This is called to mark bytes first through last inclusive of the given * buffer as needing to be logged when the transaction is committed. @@ -367,24 +388,18 @@ libxfs_trans_roll_inode( */ void libxfs_trans_log_buf( - xfs_trans_t *tp, - xfs_buf_t *bp, + struct xfs_trans *tp, + struct xfs_buf *bp, uint first, uint last) { - xfs_buf_log_item_t *bip; + struct xfs_buf_log_item *bip; - ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp); - ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); ASSERT((first <= last) && (last < XFS_BUF_COUNT(bp))); -#ifdef XACT_DEBUG - fprintf(stderr, "dirtied buffer %p, transaction %p\n", bp, tp); -#endif bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *); - tp->t_flags |= XFS_TRANS_DIRTY; - bip->bli_item.li_desc->lid_flags |= XFS_LID_DIRTY; + xfs_trans_dirty_buf(tp, bp); xfs_buf_item_log(bip, first, last); }