From f08f828db81c0656dc7939375d83c2e8a4a0dbc5 Mon Sep 17 00:00:00 2001 From: huanghua Date: Tue, 17 Mar 2009 05:47:25 +0000 Subject: [PATCH] Branch HEAD b=18711 i=jinshan.xiong i=yong.fan avoid key_fini race condition by hold spin lock. --- lustre/obdclass/lu_object.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 4fd6f0d..273cee1 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -1092,11 +1092,11 @@ void lu_context_key_degister(struct lu_context_key *key) lu_context_key_quiesce(key); ++key_set_version; + spin_lock(&lu_keys_guard); key_fini(&lu_shrink_env.le_ctx, key->lct_index); if (atomic_read(&key->lct_used) > 1) CERROR("key has instances.\n"); - spin_lock(&lu_keys_guard); lu_keys[key->lct_index] = NULL; spin_unlock(&lu_keys_guard); } @@ -1240,6 +1240,7 @@ static void keys_fini(struct lu_context *ctx) { int i; + spin_lock(&lu_keys_guard); if (ctx->lc_value != NULL) { for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) key_fini(ctx, i); @@ -1247,6 +1248,7 @@ static void keys_fini(struct lu_context *ctx) ARRAY_SIZE(lu_keys) * sizeof ctx->lc_value[0]); ctx->lc_value = NULL; } + spin_unlock(&lu_keys_guard); } static int keys_fill(struct lu_context *ctx) -- 1.8.3.1