From: Hongchao Zhang Date: Sat, 13 Jan 2018 10:08:29 +0000 (+0800) Subject: LU-8346 obdclass: protect key_set_version X-Git-Tag: 2.10.58~58 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F48%2F27448%2F10;p=fs%2Flustre-release.git LU-8346 obdclass: protect key_set_version In lu_context_refill, the key_set_version should be protected before comparing it to version stored in the lu_context. This patch is a supplement of the previous patch https://review.whamcloud.com/#/c/28405/, which adds protection for key_set_version from modification in lu_context_refill and lu_context_key_degister. Change-Id: I201f56214382a717cfc31ba573e06fec9fbedae4 Signed-off-by: Hongchao Zhang Reviewed-on: https://review.whamcloud.com/27448 Reviewed-by: Patrick Farrell Reviewed-by: Fan Yong Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 543efcc..694bab2 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -1408,8 +1408,8 @@ void lu_context_key_degister(struct lu_context_key *key) lu_context_key_quiesce(key); - ++key_set_version; write_lock(&lu_keys_guard); + ++key_set_version; key_fini(&lu_shrink_env.le_ctx, key->lct_index); /** @@ -1779,7 +1779,14 @@ EXPORT_SYMBOL(lu_context_exit); */ int lu_context_refill(struct lu_context *ctx) { - return likely(ctx->lc_version == key_set_version) ? 0 : keys_fill(ctx); + read_lock(&lu_keys_guard); + if (likely(ctx->lc_version == key_set_version)) { + read_unlock(&lu_keys_guard); + return 0; + } + + read_unlock(&lu_keys_guard); + return keys_fill(ctx); } /**