Commit 12380d23 authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: lift init CIL reservation out of xc_cil_lock

The xc_cil_lock is the most highly contended lock in XFS now. To
start the process of getting rid of it, lift the initial reservation
of the CIL log space out from under the xc_cil_lock.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent 88591e7f
...@@ -462,23 +462,19 @@ xlog_cil_insert_items( ...@@ -462,23 +462,19 @@ xlog_cil_insert_items(
*/ */
xlog_cil_insert_format_items(log, tp, &len); xlog_cil_insert_format_items(log, tp, &len);
spin_lock(&cil->xc_cil_lock);
/* attach the transaction to the CIL if it has any busy extents */
if (!list_empty(&tp->t_busy))
list_splice_init(&tp->t_busy, &ctx->busy_extents);
/* /*
* We need to take the CIL checkpoint unit reservation on the first * We need to take the CIL checkpoint unit reservation on the first
* commit into the CIL. Test the XLOG_CIL_EMPTY bit first so we don't * commit into the CIL. Test the XLOG_CIL_EMPTY bit first so we don't
* unnecessarily do an atomic op in the fast path here. * unnecessarily do an atomic op in the fast path here. We don't need to
* hold the xc_cil_lock here to clear the XLOG_CIL_EMPTY bit as we are
* under the xc_ctx_lock here and that needs to be held exclusively to
* reset the XLOG_CIL_EMPTY bit.
*/ */
if (test_bit(XLOG_CIL_EMPTY, &cil->xc_flags) && if (test_bit(XLOG_CIL_EMPTY, &cil->xc_flags) &&
test_and_clear_bit(XLOG_CIL_EMPTY, &cil->xc_flags)) { test_and_clear_bit(XLOG_CIL_EMPTY, &cil->xc_flags))
ctx_res = ctx->ticket->t_unit_res; ctx_res = ctx->ticket->t_unit_res;
ctx->ticket->t_curr_res = ctx_res;
tp->t_ticket->t_curr_res -= ctx_res; spin_lock(&cil->xc_cil_lock);
}
/* do we need space for more log record headers? */ /* do we need space for more log record headers? */
iclog_space = log->l_iclog_size - log->l_iclog_hsize; iclog_space = log->l_iclog_size - log->l_iclog_hsize;
...@@ -488,13 +484,12 @@ xlog_cil_insert_items( ...@@ -488,13 +484,12 @@ xlog_cil_insert_items(
/* need to take into account split region headers, too */ /* need to take into account split region headers, too */
split_res *= log->l_iclog_hsize + sizeof(struct xlog_op_header); split_res *= log->l_iclog_hsize + sizeof(struct xlog_op_header);
ctx->ticket->t_unit_res += split_res; ctx->ticket->t_unit_res += split_res;
ctx->ticket->t_curr_res += split_res;
tp->t_ticket->t_curr_res -= split_res;
ASSERT(tp->t_ticket->t_curr_res >= len);
} }
tp->t_ticket->t_curr_res -= len; tp->t_ticket->t_curr_res -= split_res + ctx_res + len;
tp->t_ticket->t_curr_res += released_space; ctx->ticket->t_curr_res += split_res + ctx_res;
ctx->space_used += len; ctx->space_used += len;
tp->t_ticket->t_curr_res += released_space;
ctx->space_used -= released_space; ctx->space_used -= released_space;
/* /*
...@@ -532,6 +527,9 @@ xlog_cil_insert_items( ...@@ -532,6 +527,9 @@ xlog_cil_insert_items(
list_move_tail(&lip->li_cil, &cil->xc_cil); list_move_tail(&lip->li_cil, &cil->xc_cil);
} }
/* attach the transaction to the CIL if it has any busy extents */
if (!list_empty(&tp->t_busy))
list_splice_init(&tp->t_busy, &ctx->busy_extents);
spin_unlock(&cil->xc_cil_lock); spin_unlock(&cil->xc_cil_lock);
if (tp->t_ticket->t_curr_res < 0) if (tp->t_ticket->t_curr_res < 0)
......
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