]> git.apps.os.sepia.ceph.com Git - ceph.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)
committerNathan Cutler <ncutler@suse.com>
Tue, 5 Sep 2017 15:17:15 +0000 (17:17 +0200)
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>
(cherry picked from commit 8ec4b4960f9b93ff6d85a02308ccda0bccadb599)

src/os/bluestore/BlueStore.cc

index b87d0302b306a9fc5526e001391e0f67cf9f2b4d..cafe8c5685d310575e354e13db5335bd44933794 100644 (file)
@@ -9987,6 +9987,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;
@@ -10004,18 +10012,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) {