From ca0d589b0cdfeb759452f441df5cf2c2da17228d 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 --- 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 d646cb56294..265b006261a 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -16676,18 +16676,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; @@ -17091,6 +17080,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 efedf90f6fa..bd6b85f0ff0 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -3648,8 +3648,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 @@ -3698,6 +3699,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