aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2018-01-03 13:42:03 -0600
committerEric Sandeen <sandeen@redhat.com>2018-01-03 13:42:03 -0600
commit59630067f764c9f76053058ed51c123da532dc76 (patch)
treefa7ed3f4e0c4da112d5d39b340e7ea95eaf0e290
parentc1a29e922879ae51ad990d9615c8091eb35c0c5b (diff)
downloadxfsprogs-dev-59630067f764c9f76053058ed51c123da532dc76.tar.gz
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 <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>
-rw-r--r--include/xfs_trans.h1
-rw-r--r--libxfs/libxfs_api_defs.h1
-rw-r--r--libxfs/trans.c35
3 files changed, 27 insertions, 10 deletions
diff --git a/include/xfs_trans.h b/include/xfs_trans.h
index 3535568627..d76a324013 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 84a4fc25ec..5d2ca2fbac 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 3d6de982ef..3d64f26225 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -357,6 +357,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.
* The buffer must already be associated with the given transaction.
@@ -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);
}