]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_dedup_tool: fix threshold comparison 45369/head
authormyoungwon oh <ohmyoungwon@gmail.com>
Sat, 17 Sep 2022 07:11:49 +0000 (16:11 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Mon, 19 Sep 2022 04:22:16 +0000 (13:22 +0900)
If threadhold count is 2, existing code always returns true
even though reference count is 1 actually  because it additionally
adds one via ++.

Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/tools/ceph_dedup_tool.cc

index e95aad68aaca4a9b804912187496934ac8c83bcb..f3c942a976044e64db7e17c4c817072e96a017f4 100644 (file)
@@ -561,13 +561,13 @@ public:
     bool add(chunk_t& chunk) {
       std::unique_lock lock(fingerprint_lock);
       auto found_iter = fp_map.find(chunk.fingerprint);
+      ssize_t cur_reference = 1;
       if (found_iter == fp_map.end()) {
-        auto ret = fp_map.insert({chunk.fingerprint, 1});
-        found_iter = ret.first;
+        fp_map.insert({chunk.fingerprint, 1});
+      } else {
+       cur_reference = ++found_iter->second;
       }
-      auto &target = found_iter->second;
-      target++;
-      return target >= dedup_threshold && dedup_threshold != -1;
+      return cur_reference >= dedup_threshold && dedup_threshold != -1;
     }
 
     void init(size_t dedup_threshold_) {