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: Wed, 9 Mar 2022 16:29:22 +1100 [thread overview]
Message-ID: <20220309052937.2696447-2-david@fromorbit.com> (raw)
In-Reply-To: <20220309052937.2696447-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>
Reviewed-by: Chandan Babu R <chandan.babu@oracle.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 83a039762b81..ab96565529d8 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -858,6 +858,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.
*
@@ -882,11 +917,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;
@@ -1035,24 +1068,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
@@ -1068,7 +1085,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
@@ -1132,7 +1149,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:[~2022-03-09 5:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-09 5:29 [PATCH 00/16 v8] xfs: rework xlog_write() Dave Chinner
2022-03-09 5:29 ` Dave Chinner [this message]
2022-03-09 5:29 ` [PATCH 02/16] xfs: only CIL pushes require a start record Dave Chinner
2022-03-09 5:29 ` [PATCH 03/16] xfs: embed the xlog_op_header in the unmount record Dave Chinner
2022-03-09 5:29 ` [PATCH 04/16] xfs: embed the xlog_op_header in the commit record Dave Chinner
2022-03-09 5:29 ` [PATCH 05/16] xfs: log tickets don't need log client id Dave Chinner
2022-03-09 5:29 ` [PATCH 06/16] xfs: move log iovec alignment to preparation function Dave Chinner
2022-03-09 5:29 ` [PATCH 07/16] xfs: reserve space and initialise xlog_op_header in item formatting Dave Chinner
2022-03-09 5:29 ` [PATCH 08/16] xfs: log ticket region debug is largely useless Dave Chinner
2022-03-09 5:29 ` [PATCH 09/16] xfs: pass lv chain length into xlog_write() Dave Chinner
2022-03-09 5:29 ` [PATCH 10/16] xfs: change the type of ic_datap Dave Chinner
2022-03-09 5:29 ` [PATCH 11/16] xfs: introduce xlog_write_full() Dave Chinner
2022-03-09 5:29 ` [PATCH 12/16] xfs: introduce xlog_write_partial() Dave Chinner
2022-03-09 5:29 ` [PATCH 13/16] xfs: remove xlog_verify_dest_ptr Dave Chinner
2022-03-09 5:29 ` [PATCH 14/16] xfs: xlog_write() no longer needs contwr state Dave Chinner
2022-03-09 5:29 ` [PATCH 15/16] xfs: xlog_write() doesn't need optype anymore Dave Chinner
2022-03-09 5:29 ` [PATCH 16/16] xfs: CIL context doesn't need to count iovecs Dave Chinner
-- strict thread matches above, loose matches on Subject: below --
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
2021-11-09 1:50 [PATCH 00/16 v6] xfs: rework xlog_write() Dave Chinner
2021-11-09 1:50 ` [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=20220309052937.2696447-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).