From: Dave Chinner <david@fromorbit.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 01/16] xfs: factor out the CIL transaction header building
Date: Tue, 9 Nov 2021 12:50:40 +1100 [thread overview]
Message-ID: <20211109015055.1547604-2-david@fromorbit.com> (raw)
In-Reply-To: <20211109015055.1547604-1-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
It is static code deep in the middle of the CIL push logic. Factor
it out into a helper so that it is clear and easy to modify
separately.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
---
fs/xfs/xfs_log_cil.c | 61 ++++++++++++++++++++++++++++----------------
1 file changed, 39 insertions(+), 22 deletions(-)
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 6c93c8ada6f3..28f8104fbef1 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -834,6 +834,41 @@ xlog_cil_write_commit_record(
return error;
}
+struct xlog_cil_trans_hdr {
+ struct xfs_trans_header thdr;
+ struct xfs_log_iovec lhdr;
+};
+
+/*
+ * Build a checkpoint transaction header to begin the journal transaction. We
+ * need to account for the space used by the transaction header here as it is
+ * not accounted for in xlog_write().
+ */
+static void
+xlog_cil_build_trans_hdr(
+ struct xfs_cil_ctx *ctx,
+ struct xlog_cil_trans_hdr *hdr,
+ struct xfs_log_vec *lvhdr,
+ int num_iovecs)
+{
+ struct xlog_ticket *tic = ctx->ticket;
+
+ memset(hdr, 0, sizeof(*hdr));
+
+ hdr->thdr.th_magic = XFS_TRANS_HEADER_MAGIC;
+ hdr->thdr.th_type = XFS_TRANS_CHECKPOINT;
+ hdr->thdr.th_tid = tic->t_tid;
+ hdr->thdr.th_num_items = num_iovecs;
+ hdr->lhdr.i_addr = &hdr->thdr;
+ hdr->lhdr.i_len = sizeof(xfs_trans_header_t);
+ hdr->lhdr.i_type = XLOG_REG_TYPE_TRANSHDR;
+ tic->t_curr_res -= hdr->lhdr.i_len + sizeof(struct xlog_op_header);
+
+ lvhdr->lv_niovecs = 1;
+ lvhdr->lv_iovecp = &hdr->lhdr;
+ lvhdr->lv_next = ctx->lv_chain;
+}
+
/*
* Push the Committed Item List to the log.
*
@@ -858,11 +893,9 @@ xlog_cil_push_work(
struct xlog *log = cil->xc_log;
struct xfs_log_vec *lv;
struct xfs_cil_ctx *new_ctx;
- struct xlog_ticket *tic;
int num_iovecs;
int error = 0;
- struct xfs_trans_header thdr;
- struct xfs_log_iovec lhdr;
+ struct xlog_cil_trans_hdr thdr;
struct xfs_log_vec lvhdr = { NULL };
xfs_lsn_t preflush_tail_lsn;
xfs_csn_t push_seq;
@@ -1011,24 +1044,8 @@ xlog_cil_push_work(
* Build a checkpoint transaction header and write it to the log to
* begin the transaction. We need to account for the space used by the
* transaction header here as it is not accounted for in xlog_write().
- *
- * The LSN we need to pass to the log items on transaction commit is
- * the LSN reported by the first log vector write. If we use the commit
- * record lsn then we can move the tail beyond the grant write head.
*/
- tic = ctx->ticket;
- thdr.th_magic = XFS_TRANS_HEADER_MAGIC;
- thdr.th_type = XFS_TRANS_CHECKPOINT;
- thdr.th_tid = tic->t_tid;
- thdr.th_num_items = num_iovecs;
- lhdr.i_addr = &thdr;
- lhdr.i_len = sizeof(xfs_trans_header_t);
- lhdr.i_type = XLOG_REG_TYPE_TRANSHDR;
- tic->t_curr_res -= lhdr.i_len + sizeof(xlog_op_header_t);
-
- lvhdr.lv_niovecs = 1;
- lvhdr.lv_iovecp = &lhdr;
- lvhdr.lv_next = ctx->lv_chain;
+ xlog_cil_build_trans_hdr(ctx, &thdr, &lvhdr, num_iovecs);
/*
* Before we format and submit the first iclog, we have to ensure that
@@ -1044,7 +1061,7 @@ xlog_cil_push_work(
if (error)
goto out_abort_free_ticket;
- xfs_log_ticket_ungrant(log, tic);
+ xfs_log_ticket_ungrant(log, ctx->ticket);
/*
* If the checkpoint spans multiple iclogs, wait for all previous iclogs
@@ -1108,7 +1125,7 @@ xlog_cil_push_work(
return;
out_abort_free_ticket:
- xfs_log_ticket_ungrant(log, tic);
+ xfs_log_ticket_ungrant(log, ctx->ticket);
ASSERT(xlog_is_shutdown(log));
if (!ctx->commit_iclog) {
xlog_cil_committed(ctx);
--
2.33.0
next prev parent reply other threads:[~2021-11-09 1:51 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 1:50 [PATCH 00/16 v6] xfs: rework xlog_write() Dave Chinner
2021-11-09 1:50 ` Dave Chinner [this message]
2021-11-09 1:50 ` [PATCH 02/16] xfs: only CIL pushes require a start record Dave Chinner
2021-11-11 7:55 ` Christoph Hellwig
2021-11-18 4:38 ` Dave Chinner
2021-11-09 1:50 ` [PATCH 03/16] xfs: embed the xlog_op_header in the unmount record Dave Chinner
2021-11-09 1:50 ` [PATCH 04/16] xfs: embed the xlog_op_header in the commit record Dave Chinner
2021-11-11 8:00 ` Christoph Hellwig
2021-11-18 4:43 ` Dave Chinner
2021-11-09 1:50 ` [PATCH 05/16] xfs: log tickets don't need log client id Dave Chinner
2021-11-09 1:50 ` [PATCH 06/16] xfs: move log iovec alignment to preparation function Dave Chinner
2021-11-09 1:50 ` [PATCH 07/16] xfs: reserve space and initialise xlog_op_header in item formatting Dave Chinner
2021-11-11 8:10 ` Christoph Hellwig
2021-11-09 1:50 ` [PATCH 08/16] xfs: log ticket region debug is largely useless Dave Chinner
2021-11-09 1:50 ` [PATCH 09/16] xfs: pass lv chain length into xlog_write() Dave Chinner
2021-11-11 8:10 ` Christoph Hellwig
2021-11-09 1:50 ` [PATCH 10/16] xfs: change the type of ic_datap Dave Chinner
2021-11-17 4:50 ` Darrick J. Wong
2021-11-09 1:50 ` [PATCH 11/16] xfs: introduce xlog_write_full() Dave Chinner
2021-11-11 8:12 ` Christoph Hellwig
2021-11-17 4:56 ` Darrick J. Wong
2021-11-09 1:50 ` [PATCH 12/16] xfs:_introduce xlog_write_partial() Dave Chinner
2021-11-11 8:27 ` Christoph Hellwig
2021-11-17 5:21 ` Darrick J. Wong
2021-11-18 5:22 ` Dave Chinner
2021-11-09 1:50 ` [PATCH 13/16] xfs: remove xlog_verify_dest_ptr Dave Chinner
2021-11-17 5:02 ` Darrick J. Wong
2021-11-09 1:50 ` [PATCH 14/16] xfs: xlog_write() no longer needs contwr state Dave Chinner
2021-11-11 8:28 ` Christoph Hellwig
2021-11-09 1:50 ` [PATCH 15/16] xfs: xlog_write() doesn't need optype anymore Dave Chinner
2021-11-11 8:29 ` Christoph Hellwig
2021-11-09 1:50 ` [PATCH 16/16] xfs: CIL context doesn't need to count iovecs Dave Chinner
2021-11-11 8:29 ` Christoph Hellwig
2021-11-18 23:13 [PATCH 00/16 v7] xfs: rework xlog_write() Dave Chinner
2021-11-18 23:13 ` [PATCH 01/16] xfs: factor out the CIL transaction header building Dave Chinner
2021-11-22 10:48 ` Chandan Babu R
2022-03-09 5:29 [PATCH 00/16 v8] xfs: rework xlog_write() Dave Chinner
2022-03-09 5:29 ` [PATCH 01/16] xfs: factor out the CIL transaction header building Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211109015055.1547604-2-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.