From 93c781d19ddded39464b824ac040cdb749ea774e Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Thu, 16 Nov 2023 17:18:37 +0000 Subject: [PATCH] os/bluestore: Add csum_type to WriteContext It is more organized this way. Signed-off-by: Adam Kupczyk (cherry picked from commit ca0d589b0cdfeb759452f441df5cf2c2da17228d) --- src/os/bluestore/BlueStore.cc | 28 ++++++++++++++++------------ src/os/bluestore/BlueStore.h | 4 +++- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 18913e6833f1b..690f0063d76e2 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -15595,18 +15595,7 @@ int BlueStore::_do_alloc_write( } // checksum - int64_t csum = csum_type.load(); - csum = select_option( - "csum_type", - csum, - [&]() { - int64_t val; - if (coll->pool_opts.get(pool_opts_t::CSUM_TYPE, &val)) { - return std::optional(val); - } - return std::optional(); - } - ); + int64_t csum = wctx->csum_type; // compress (as needed) and calc needed space uint64_t need = 0; @@ -16067,6 +16056,21 @@ void BlueStore::_choose_write_options( // apply basic csum block size wctx->csum_order = block_size_order; + // checksum + int64_t csum = csum_type.load(); + csum = select_option( + "csum_type", + csum, + [&]() { + int64_t val; + if (c->pool_opts.get(pool_opts_t::CSUM_TYPE, &val)) { + return std::optional(val); + } + return std::optional(); + } + ); + wctx->csum_type = csum; + // compression parameters unsigned alloc_hints = o->onode.alloc_hint_flags; auto cm = select_option( diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index ca792a0a85521..14c09fcf74e3e 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -3411,8 +3411,9 @@ private: struct WriteContext { bool buffered = false; ///< buffered write bool compress = false; ///< compressed write - uint64_t target_blob_size = 0; ///< target (max) blob size + uint8_t csum_type = 0; ///< checksum type for new blobs unsigned csum_order = 0; ///< target checksum chunk order + uint64_t target_blob_size = 0; ///< target (max) blob size old_extent_map_t old_extents; ///< must deref these blobs interval_set extents_to_gc; ///< extents for garbage collection @@ -3461,6 +3462,7 @@ private: buffered = other.buffered; compress = other.compress; target_blob_size = other.target_blob_size; + csum_type = other.csum_type; csum_order = other.csum_order; } void write( -- 2.39.5