From: Adam Kupczyk Date: Thu, 16 Nov 2023 17:18:37 +0000 (+0000) Subject: os/bluestore: Add csum_type to WriteContext X-Git-Tag: v20.0.0~1280^2~26 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ca0d589b0cdfeb759452f441df5cf2c2da17228d;p=ceph.git os/bluestore: Add csum_type to WriteContext It is more organized this way. Signed-off-by: Adam Kupczyk --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index d646cb56294f2..265b006261aa4 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 efedf90f6fa30..bd6b85f0ff0ce 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(