aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_log_cil.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_log_cil.c')
-rw-r--r--fs/xfs/xfs_log_cil.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 9b21f80f31c..bb17cc044bf 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -200,6 +200,15 @@ xlog_cil_insert(
200 ctx->nvecs += diff_iovecs; 200 ctx->nvecs += diff_iovecs;
201 201
202 /* 202 /*
203 * If this is the first time the item is being committed to the CIL,
204 * store the sequence number on the log item so we can tell
205 * in future commits whether this is the first checkpoint the item is
206 * being committed into.
207 */
208 if (!item->li_seq)
209 item->li_seq = ctx->sequence;
210
211 /*
203 * Now transfer enough transaction reservation to the context ticket 212 * Now transfer enough transaction reservation to the context ticket
204 * for the checkpoint. The context ticket is special - the unit 213 * for the checkpoint. The context ticket is special - the unit
205 * reservation has to grow as well as the current reservation as we 214 * reservation has to grow as well as the current reservation as we
@@ -325,6 +334,10 @@ xlog_cil_free_logvec(
325 * For more specific information about the order of operations in 334 * For more specific information about the order of operations in
326 * xfs_log_commit_cil() please refer to the comments in 335 * xfs_log_commit_cil() please refer to the comments in
327 * xfs_trans_commit_iclog(). 336 * xfs_trans_commit_iclog().
337 *
338 * Called with the context lock already held in read mode to lock out
339 * background commit, returns without it held once background commits are
340 * allowed again.
328 */ 341 */
329int 342int
330xfs_log_commit_cil( 343xfs_log_commit_cil(
@@ -678,3 +691,35 @@ restart:
678 spin_unlock(&cil->xc_cil_lock); 691 spin_unlock(&cil->xc_cil_lock);
679 return commit_lsn; 692 return commit_lsn;
680} 693}
694
695/*
696 * Check if the current log item was first committed in this sequence.
697 * We can't rely on just the log item being in the CIL, we have to check
698 * the recorded commit sequence number.
699 *
700 * Note: for this to be used in a non-racy manner, it has to be called with
701 * CIL flushing locked out. As a result, it should only be used during the
702 * transaction commit process when deciding what to format into the item.
703 */
704bool
705xfs_log_item_in_current_chkpt(
706 struct xfs_log_item *lip)
707{
708 struct xfs_cil_ctx *ctx;
709
710 if (!(lip->li_mountp->m_flags & XFS_MOUNT_DELAYLOG))
711 return false;
712 if (list_empty(&lip->li_cil))
713 return false;
714
715 ctx = lip->li_mountp->m_log->l_cilp->xc_ctx;
716
717 /*
718 * li_seq is written on the first commit of a log item to record the
719 * first checkpoint it is written to. Hence if it is different to the
720 * current sequence, we're in a new checkpoint.
721 */
722 if (XFS_LSN_CMP(lip->li_seq, ctx->sequence) != 0)
723 return false;
724 return true;
725}