From: xie xingguo Date: Thu, 31 Aug 2017 03:42:37 +0000 (+0800) Subject: os/bluestore: don't re-initialize csum-setting for existing blobs X-Git-Tag: v12.2.1~89^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ca667063b77445a2f45cdce04110b3affbdf6bed;p=ceph.git os/bluestore: don't re-initialize csum-setting for existing blobs 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 (cherry picked from commit 8ec4b4960f9b93ff6d85a02308ccda0bccadb599) --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index b87d0302b306..cafe8c5685d3 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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) {