From 5eca548e2213ef4d291cc2ca54d9ea6de8f7fd39 Mon Sep 17 00:00:00 2001 From: Jan Musial Date: Tue, 31 Dec 2019 11:31:53 +0100 Subject: [PATCH] Make sure NHIT won't attempt to take the same semaphore twice Signed-off-by: Jan Musial --- src/promotion/nhit/nhit_hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/promotion/nhit/nhit_hash.c b/src/promotion/nhit/nhit_hash.c index f5ab85d..ea8fd23 100644 --- a/src/promotion/nhit/nhit_hash.c +++ b/src/promotion/nhit/nhit_hash.c @@ -312,7 +312,7 @@ static inline void write_lock_hashes(nhit_hash_t ctx, ocf_core_id_t core_id1, if (lock_order[0] != ctx->hash_entries) env_rwsem_down_write(&ctx->hash_locks[lock_order[0]]); - if (lock_order[1] != ctx->hash_entries) + if ((lock_order[1] != ctx->hash_entries) && (lock_order[0] != lock_order[1])) env_rwsem_down_write(&ctx->hash_locks[lock_order[1]]); } @@ -327,7 +327,7 @@ static inline void write_unlock_hashes(nhit_hash_t ctx, ocf_core_id_t core_id1, if (hash1 != ctx->hash_entries) env_rwsem_up_write(&ctx->hash_locks[hash1]); - if (hash2 != ctx->hash_entries) + if ((hash2 != ctx->hash_entries) && (hash1 != hash2)) env_rwsem_up_write(&ctx->hash_locks[hash2]); }