]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: don't re-initialize csum-setting for existing blobs
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 31 Aug 2017 03:42:37 +0000 (11:42 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 1 Sep 2017 04:33:40 +0000 (12:33 +0800)
The global checksum setting may change, e.g., from NONE to CRC32,
which can cause improper re-initialization of the csum-settings of
existing blobs(e.g., partial write/overwrite may turn out to shrink
'csum_data').

We could develop some complicated solutions but for now let's not
bother since the above scenario is rare.

Fixes: http://tracker.ceph.com/issues/21175
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index 541ac20abc02ebed3a23c8140544e8a70d2f990c..b4003b5b41702fc4eab5cdf43a18cc4e1b8afaa2 100644 (file)
@@ -9929,6 +9929,14 @@ int BlueStore::_do_alloc_write(
         csum_length += suggested_boff - b_off;
         b_off = suggested_boff;
       }
+      if (csum != Checksummer::CSUM_NONE) {
+        dout(20) << __func__ << " initialize csum setting for new blob " << *b
+                 << " csum_type " << Checksummer::get_csum_type_string(csum)
+                 << " csum_order " << csum_order
+                 << " csum_length 0x" << std::hex << csum_length << std::dec
+                 << dendl;
+        dblob.init_csum(csum, csum_order, csum_length);
+      }
     }
 
     AllocExtentVector extents;
@@ -9946,18 +9954,11 @@ int BlueStore::_do_alloc_write(
     }
     dblob.allocated(P2ALIGN(b_off, min_alloc_size), final_length, extents);
 
-    dout(20) << __func__ << " blob " << *b
-            << " csum_type " << Checksummer::get_csum_type_string(csum)
-            << " csum_order " << csum_order
-            << " csum_length 0x" << std::hex << csum_length << std::dec
-            << dendl;
-
-    if (csum != Checksummer::CSUM_NONE) {
-      if (!dblob.has_csum()) {
-       dblob.init_csum(csum, csum_order, csum_length);
-      }
+    dout(20) << __func__ << " blob " << *b << dendl;
+    if (dblob.has_csum()) {
       dblob.calc_csum(b_off, *l);
     }
+
     if (wi.mark_unused) {
       auto b_end = b_off + wi.bl.length();
       if (b_off) {