From 55afbf5934e145e48a31193de601abd58e605a42 Mon Sep 17 00:00:00 2001 From: Sergey Cheremencev Date: Wed, 8 Apr 2015 22:18:07 +0300 Subject: [PATCH] LU-6527 ext4: journal_commit_callback optimization Don't take spinlock in tgt_cb_last_committed, if exp_last_committed was updated with higher trasno. Also change list_add_tail to list_add. It gives advantages to ldiskfs in tgt_cb_last_committed. In the beginning of list will be placed thandles with the highest transaction numbers. So at the first iterations we will have the highest transno. It will save from extra call of ptlrpc_commit_replies. Change-Id: Ib6f9cc54dae7d9ac1ca301402299f308b825ede4 Signed-off-by: Sergey Cheremencev Xyratex-bug-id: MRP-2575 Reviewed-on: http://es-gerrit.xyus.xyratex.com:8080/5907 Tested-by: Jenkins Reviewed-by: Alexander Zarochentsev Reviewed-by: Alexander Boyko Tested-by: Alexander Lezhoev Reviewed-by: Alexey Leonidovich Lyashkov Reviewed-on: http://review.whamcloud.com/14611 Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- .../kernel_patches/patches/rhel6.3/ext4-journal-callback.patch | 2 +- lustre/target/tgt_lastrcvd.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-journal-callback.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-journal-callback.patch index 7f8a90c..9255ebf 100644 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-journal-callback.patch +++ b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-journal-callback.patch @@ -73,7 +73,7 @@ Index: linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/ext4_jbd2.h + /* Add the jce to transaction's private list */ + jce->jce_func = func; + spin_lock(&sbi->s_md_lock); -+ list_add_tail(&jce->jce_list, &handle->h_transaction->t_private_list); ++ list_add(&jce->jce_list, &handle->h_transaction->t_private_list); + spin_unlock(&sbi->s_md_lock); +} + diff --git a/lustre/target/tgt_lastrcvd.c b/lustre/target/tgt_lastrcvd.c index 8b0f9a0..a152f05 100644 --- a/lustre/target/tgt_lastrcvd.c +++ b/lustre/target/tgt_lastrcvd.c @@ -761,14 +761,19 @@ static void tgt_cb_last_committed(struct lu_env *env, struct thandle *th, ccb = container_of0(cb, struct tgt_last_committed_callback, llcc_cb); + LASSERT(ccb->llcc_exp); LASSERT(ccb->llcc_tgt != NULL); LASSERT(ccb->llcc_exp->exp_obd == ccb->llcc_tgt->lut_obd); + /* Fast path w/o spinlock, if exp_last_committed was updated + * with higher transno, no need to take spinlock and check, + * also no need to update obd_last_committed. */ + if (ccb->llcc_transno <= ccb->llcc_exp->exp_last_committed) + goto out; spin_lock(&ccb->llcc_tgt->lut_translock); if (ccb->llcc_transno > ccb->llcc_tgt->lut_obd->obd_last_committed) ccb->llcc_tgt->lut_obd->obd_last_committed = ccb->llcc_transno; - LASSERT(ccb->llcc_exp); if (ccb->llcc_transno > ccb->llcc_exp->exp_last_committed) { ccb->llcc_exp->exp_last_committed = ccb->llcc_transno; spin_unlock(&ccb->llcc_tgt->lut_translock); @@ -776,6 +781,7 @@ static void tgt_cb_last_committed(struct lu_env *env, struct thandle *th, } else { spin_unlock(&ccb->llcc_tgt->lut_translock); } +out: class_export_cb_put(ccb->llcc_exp); if (ccb->llcc_transno) CDEBUG(D_HA, "%s: transno "LPD64" is committed\n", -- 1.8.3.1