Commit 735fbf67 authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: factor out the CIL transaction header building

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: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarChandan Babu R <chandan.babu@oracle.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent ce522ba9
...@@ -868,6 +868,41 @@ xlog_cil_write_commit_record( ...@@ -868,6 +868,41 @@ xlog_cil_write_commit_record(
return error; 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. * Push the Committed Item List to the log.
* *
...@@ -892,11 +927,9 @@ xlog_cil_push_work( ...@@ -892,11 +927,9 @@ xlog_cil_push_work(
struct xlog *log = cil->xc_log; struct xlog *log = cil->xc_log;
struct xfs_log_vec *lv; struct xfs_log_vec *lv;
struct xfs_cil_ctx *new_ctx; struct xfs_cil_ctx *new_ctx;
struct xlog_ticket *tic;
int num_iovecs; int num_iovecs;
int error = 0; int error = 0;
struct xfs_trans_header thdr; struct xlog_cil_trans_hdr thdr;
struct xfs_log_iovec lhdr;
struct xfs_log_vec lvhdr = { NULL }; struct xfs_log_vec lvhdr = { NULL };
xfs_csn_t push_seq; xfs_csn_t push_seq;
bool push_commit_stable; bool push_commit_stable;
...@@ -1025,24 +1058,8 @@ xlog_cil_push_work( ...@@ -1025,24 +1058,8 @@ xlog_cil_push_work(
* Build a checkpoint transaction header and write it to the log to * 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 * 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(). * 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 xlog_cil_build_trans_hdr(ctx, &thdr, &lvhdr, num_iovecs);
* 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;
error = xlog_cil_write_chain(ctx, &lvhdr); error = xlog_cil_write_chain(ctx, &lvhdr);
if (error) if (error)
...@@ -1052,7 +1069,7 @@ xlog_cil_push_work( ...@@ -1052,7 +1069,7 @@ xlog_cil_push_work(
if (error) if (error)
goto out_abort_free_ticket; 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 * If the checkpoint spans multiple iclogs, wait for all previous iclogs
...@@ -1116,7 +1133,7 @@ xlog_cil_push_work( ...@@ -1116,7 +1133,7 @@ xlog_cil_push_work(
return; return;
out_abort_free_ticket: out_abort_free_ticket:
xfs_log_ticket_ungrant(log, tic); xfs_log_ticket_ungrant(log, ctx->ticket);
ASSERT(xlog_is_shutdown(log)); ASSERT(xlog_is_shutdown(log));
if (!ctx->commit_iclog) { if (!ctx->commit_iclog) {
xlog_cil_committed(ctx); xlog_cil_committed(ctx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment