From 2aa5147cd05fa8342493333e92a0c0fc7f87bbde Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Tue, 6 Dec 2016 17:09:06 -0600 Subject: [PATCH] LU-8918 obdclass: hoist locking in lu_context_exit() Hoist lu_keys_guard locking out of the for loop in lu_context_exit(). Signed-off-by: John L. Hammond Change-Id: I2f79a1321a48d8a459b4f83a7996ca2ae9a8e4bb Reviewed-on: https://review.whamcloud.com/24217 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- lustre/obdclass/lu_object.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 2f0fb3ee..b633d26 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -1795,10 +1795,11 @@ void lu_context_exit(struct lu_context *ctx) LINVRNT(ctx->lc_state == LCS_ENTERED); ctx->lc_state = LCS_LEFT; if (ctx->lc_tags & LCT_HAS_EXIT && ctx->lc_value != NULL) { + /* could race with key quiescency */ + if (ctx->lc_tags & LCT_REMEMBER) + read_lock(&lu_keys_guard); + for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) { - /* could race with key quiescency */ - if (ctx->lc_tags & LCT_REMEMBER) - read_lock(&lu_keys_guard); if (ctx->lc_value[i] != NULL) { struct lu_context_key *key; @@ -1808,9 +1809,10 @@ void lu_context_exit(struct lu_context *ctx) key->lct_exit(ctx, key, ctx->lc_value[i]); } - if (ctx->lc_tags & LCT_REMEMBER) - read_unlock(&lu_keys_guard); } + + if (ctx->lc_tags & LCT_REMEMBER) + read_unlock(&lu_keys_guard); } } EXPORT_SYMBOL(lu_context_exit); -- 1.8.3.1