]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/FastCDC: better behavior if TARGET_WINDOW_BITS==0
authorSage Weil <sage@newdream.net>
Thu, 21 May 2020 15:36:28 +0000 (10:36 -0500)
committerSage Weil <sage@newdream.net>
Wed, 27 May 2020 12:47:28 +0000 (07:47 -0500)
Skip the middle scan call entirely in that case.

Signed-off-by: Sage Weil <sage@newdream.net>
src/common/FastCDC.cc

index 9576124619d118460c22492aec54bb7f702c3ed5..70358e9782eaadf8e5cc9c0c64ba4a23b9aaaa65 100644 (file)
@@ -155,18 +155,21 @@ void FastCDC::calc_chunks(
     ceph_assert(pos < len);
 
     // find an end marker
-    if (_scan(&p, &pp, &pe, pos,  // for the first "small" region
-             std::min(len,
-                      cstart + (1 << (target_bits - TARGET_WINDOW_BITS))),
-             fp, small_mask, table) &&
-       _scan(&p, &pp, &pe, pos,  // for the middle range (close to our target)
-             std::min(len,
-                      cstart + (1 << (target_bits + TARGET_WINDOW_BITS))),
-             fp, target_mask, table) &&
-       _scan(&p, &pp, &pe, pos,  // we're past target, use large_mask!
-             std::min(len,
-                      cstart + (1 << max_bits)),
-             fp, large_mask, table)) ;
+    if (
+      // for the first "small" region
+      _scan(&p, &pp, &pe, pos,
+           std::min(len, cstart + (1 << (target_bits - TARGET_WINDOW_BITS))),
+           fp, small_mask, table) &&
+      // for the middle range (close to our target)
+      (TARGET_WINDOW_BITS == 0 ||
+       _scan(&p, &pp, &pe, pos,
+            std::min(len, cstart + (1 << (target_bits + TARGET_WINDOW_BITS))),
+            fp, target_mask, table)) &&
+      // we're past target, use large_mask!
+      _scan(&p, &pp, &pe, pos,
+           std::min(len,
+                    cstart + (1 << max_bits)),
+           fp, large_mask, table)) ;
 
     chunks->push_back(std::pair<uint64_t,uint64_t>(cstart, pos - cstart));
   }