From 6a6754f8dc834dbb13144cebdeeea2ff29e09127 Mon Sep 17 00:00:00 2001 From: Alexey Sheplyakov Date: Fri, 26 Feb 2016 15:01:11 +0300 Subject: [PATCH] hammer: tools: fix race condition in seq/rand bench (part 2) Commit c2c6d02591519dfd15ddcb397ac440322a964deb which is intended to cherry-pick 9bcf5f065c4ed4b10d8f98961d1f99493bcdc9b8 incorrectly resolved a conflict by adding code where it should have been removed. The incorrect conflict resolution can been displayed with commit=c2c6d02591519dfd15ddcb397ac440322a964deb picked_from=9bcf5f065c4ed4b10d8f98961d1f99493bcdc9b8 diff -u --ignore-matching-lines '^[^+-]' <(git show $picked_from) <(git show $commit) --- /dev/fd/63 2016-03-03 14:09:51.354329129 +0700 +++ /dev/fd/62 2016-03-03 14:09:51.358329122 +0700 @@ -76,20 +79,18 @@ ++data.in_flight; - if (!no_verify) { - snprintf(data.object_contents, data.object_size, "I'm the %16dth object!", current_index); -- lock.Unlock(); + lock.Unlock(); - if (memcmp(data.object_contents, cur_contents->c_str(), data.object_size) != 0) { - cerr << name[slot] << " is not correct!" << std::endl; - ++errors; - } -- } else { -- lock.Unlock(); -- } -- -+ lock.Unlock(); - name[slot] = newName; - } - -@@ -789,11 +791,14 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr ++ if (memcmp(data.object_contents, cur_contents->c_str(), data.object_size) != 0) { ++ cerr << name[slot] << " is not correct!" << std::endl; ++ ++errors; + } else { + lock.Unlock(); + } +@@ -776,11 +785,14 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr } lc.cond.Wait(lock); } http://tracker.ceph.com/issues/14873 Fixes: #14873 Signed-off-by: Alexey Sheplyakov --- src/common/obj_bencher.cc | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc index db4fd8f8c73a8..000e4330e6702 100644 --- a/src/common/obj_bencher.cc +++ b/src/common/obj_bencher.cc @@ -624,14 +624,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre lock.Lock(); ++data.started; ++data.in_flight; - lock.Unlock(); - if (memcmp(data.object_contents, cur_contents->c_str(), data.object_size) != 0) { - cerr << name[slot] << " is not correct!" << std::endl; - ++errors; - } else { - lock.Unlock(); - } - + lock.Unlock(); name[slot] = newName; } -- 2.39.5