summaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_log_cil.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2022-07-01 18:11:52 +0200
committerDave Chinner <david@fromorbit.com>2022-07-01 18:11:52 +0200
commit12380d237b819bd6cf2183f10b55ab47cdaab5e6 (patch)
tree01aaf6b84715c8f4a4b2c14b6953f42e0a9aa524 /fs/xfs/xfs_log_cil.c
parentxfs: use the CIL space used counter for emptiness checks (diff)
downloadlinux-12380d237b819bd6cf2183f10b55ab47cdaab5e6.tar.xz
linux-12380d237b819bd6cf2183f10b55ab47cdaab5e6.zip
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: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs/xfs_log_cil.c')
-rw-r--r--fs/xfs/xfs_log_cil.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 36c0ce77d41b..8a83d901e465 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -462,23 +462,19 @@ xlog_cil_insert_items(
*/
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
* 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) &&
- 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->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? */
iclog_space = log->l_iclog_size - log->l_iclog_hsize;
@@ -488,13 +484,12 @@ xlog_cil_insert_items(
/* need to take into account split region headers, too */
split_res *= log->l_iclog_hsize + sizeof(struct xlog_op_header);
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 += released_space;
+ tp->t_ticket->t_curr_res -= split_res + ctx_res + len;
+ ctx->ticket->t_curr_res += split_res + ctx_res;
ctx->space_used += len;
+
+ tp->t_ticket->t_curr_res += released_space;
ctx->space_used -= released_space;
/*
@@ -532,6 +527,9 @@ xlog_cil_insert_items(
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);
if (tp->t_ticket->t_curr_res < 0)