]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: refactor buffer logging into buffer dirtying helper
authorBrian Foster <bfoster@redhat.com>
Wed, 3 Jan 2018 19:42:03 +0000 (13:42 -0600)
committerEric Sandeen <sandeen@redhat.com>
Wed, 3 Jan 2018 19:42:03 +0000 (13:42 -0600)
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 <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/xfs_trans.h
libxfs/libxfs_api_defs.h
libxfs/trans.c

index 353556862787cb9ef975920ec0972a4be0e37a77..d76a3240133717cf6ef650e855ab1335608bb852 100644 (file)
@@ -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 *);
index 84a4fc25ec1d741a1fe4748fbbf28b6920344b0b..5d2ca2fbac9abc350a2b4d7e6973ad531672e4af 100644 (file)
@@ -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
index 3d6de982efe543eddb3c916efae29d0893691e58..3d64f2622501d043db56d1b1d9cf74716ff60e0a 100644 (file)
@@ -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);
 }