From: Yingxin Cheng Date: Fri, 30 Sep 2022 03:26:17 +0000 (+0800) Subject: crimson/os/seastore: drop the replaced seastore/block_off_t X-Git-Tag: v18.1.0~1035^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f70258285bf7f951c8871b147f80d4a1e03b882c;p=ceph.git crimson/os/seastore: drop the replaced seastore/block_off_t Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/os/seastore/seastore_types.cc b/src/crimson/os/seastore/seastore_types.cc index becc16ce6d28..bb41a9f78d37 100644 --- a/src/crimson/os/seastore/seastore_types.cc +++ b/src/crimson/os/seastore/seastore_types.cc @@ -66,15 +66,6 @@ std::ostream &operator<<(std::ostream &out, const segment_id_t &segment) } } -std::ostream &operator<<(std::ostream &out, const seastore_off_printer_t &off) -{ - if (off.off == NULL_SEG_OFF) { - return out << "NULL_OFF"; - } else { - return out << off.off; - } -} - std::ostream& operator<<(std::ostream& out, segment_type_t t) { switch(t) { @@ -147,7 +138,6 @@ journal_seq_t journal_seq_t::add_offset( } else { assert(type == journal_type_t::RANDOM_BLOCK); auto boff = offset.as_blk_paddr().get_device_off(); - assert(boff <= MAX_SEG_OFF); joff = boff; } auto roll_end = roll_start + roll_size; diff --git a/src/crimson/os/seastore/seastore_types.h b/src/crimson/os/seastore/seastore_types.h index 5f2f3341e2a3..17a9fc825b5d 100644 --- a/src/crimson/os/seastore/seastore_types.h +++ b/src/crimson/os/seastore/seastore_types.h @@ -415,23 +415,6 @@ private: size_t total_segments = 0; }; -// Offset within a segment on disk, see SegmentManager -// may be negative for relative offsets -using seastore_off_t = int32_t; -using u_seastore_off_t = uint32_t; -constexpr seastore_off_t MAX_SEG_OFF = - std::numeric_limits::max(); -constexpr seastore_off_t MIN_SEG_OFF = - std::numeric_limits::min(); -constexpr seastore_off_t NULL_SEG_OFF = MAX_SEG_OFF; -constexpr auto SEGMENT_OFF_BITS = std::numeric_limits::digits; - -struct seastore_off_printer_t { - seastore_off_t off; -}; - -std::ostream &operator<<(std::ostream&, const seastore_off_printer_t&); - /** * paddr_t * @@ -452,14 +435,11 @@ std::ostream &operator<<(std::ostream&, const seastore_off_printer_t&); using internal_paddr_t = uint64_t; constexpr auto PADDR_BITS = std::numeric_limits::digits; -static_assert(PADDR_BITS == SEGMENT_ID_BITS + SEGMENT_OFF_BITS); /** * device_off_t * * Offset within a device, may be negative for relative offsets. - * - * TODO: replace block_off_t */ using device_off_t = int64_t; using u_device_off_t = uint64_t; @@ -468,20 +448,17 @@ constexpr auto DEVICE_OFF_MAX = std::numeric_limits::max() >> DEVICE_ID_BITS; constexpr auto DEVICE_OFF_MIN = -(DEVICE_OFF_MAX + 1); -using block_off_t = internal_paddr_t; -constexpr auto BLOCK_OFF_BITS = PADDR_BITS - DEVICE_ID_BITS; -constexpr auto BLOCK_OFF_MAX = - std::numeric_limits::max() >> DEVICE_ID_BITS; - /** * segment_off_t * * Offset within a segment on disk, may be negative for relative offsets. - * - * TODO: replace seastore_off_t */ using segment_off_t = int32_t; using u_segment_off_t = uint32_t; +constexpr auto SEGMENT_OFF_MAX = std::numeric_limits::max(); +constexpr auto SEGMENT_OFF_MIN = std::numeric_limits::min(); +constexpr auto SEGMENT_OFF_BITS = std::numeric_limits::digits; +static_assert(PADDR_BITS == SEGMENT_ID_BITS + SEGMENT_OFF_BITS); constexpr auto DEVICE_ID_MASK = ((internal_paddr_t(1) << DEVICE_ID_BITS) - 1) << DEVICE_OFF_BITS; @@ -491,7 +468,6 @@ constexpr auto SEGMENT_ID_MASK = ((internal_paddr_t(1) << SEGMENT_ID_BITS) - 1) << SEGMENT_OFF_BITS; constexpr auto SEGMENT_OFF_MASK = (internal_paddr_t(1) << SEGMENT_OFF_BITS) - 1; -constexpr auto SEASTORE_OFF_MASK = SEGMENT_OFF_MASK; constexpr internal_paddr_t encode_device_off(device_off_t off) { return static_cast(off) & DEVICE_OFF_MASK; @@ -680,7 +656,7 @@ private: struct const_construct_t {}; constexpr paddr_t(device_id_t d_id, device_off_t offset, const_construct_t) - : internal_paddr((static_cast(d_id) << BLOCK_OFF_BITS) | + : internal_paddr((static_cast(d_id) << DEVICE_OFF_BITS) | static_cast(offset)) {} friend struct paddr_le_t; @@ -712,7 +688,7 @@ struct seg_paddr_t : public paddr_t { paddr_t add_offset(device_off_t o) const { device_off_t off = get_segment_off() + o; assert(off >= 0); - assert(off <= MAX_SEG_OFF); + assert(off <= SEGMENT_OFF_MAX); return paddr_t::make_seg_paddr( get_segment_id(), static_cast(off)); } @@ -1228,7 +1204,7 @@ struct delta_info_t { laddr_t laddr = L_ADDR_NULL; ///< logical address uint32_t prev_crc = 0; uint32_t final_crc = 0; - extent_len_t length = NULL_SEG_OFF; ///< extent length + extent_len_t length = 0; ///< extent length extent_version_t pversion; ///< prior version segment_seq_t ext_seq; ///< seq of the extent's segment segment_type_t seg_type; @@ -1933,7 +1909,7 @@ struct record_group_t { extent_len_t block_size) { size.account(record.size, block_size); records.push_back(std::move(record)); - assert(size.get_encoded_length() < MAX_SEG_OFF); + assert(size.get_encoded_length() < SEGMENT_OFF_MAX); } void reserve(std::size_t limit) { diff --git a/src/crimson/os/seastore/segment_manager.h b/src/crimson/os/seastore/segment_manager.h index 4c137a4fd919..21241c03e093 100644 --- a/src/crimson/os/seastore/segment_manager.h +++ b/src/crimson/os/seastore/segment_manager.h @@ -47,7 +47,7 @@ struct block_sm_superblock_t { ceph_assert(block_size > 0); ceph_assert(segment_size > 0 && segment_size % block_size == 0); - ceph_assert_always(segment_size <= MAX_SEG_OFF); + ceph_assert_always(segment_size <= SEGMENT_OFF_MAX); ceph_assert(size > segment_size && size % block_size == 0); ceph_assert_always(size <= DEVICE_OFF_MAX); diff --git a/src/crimson/os/seastore/segment_manager/ephemeral.h b/src/crimson/os/seastore/segment_manager/ephemeral.h index e98ed691cbf9..1dab899be575 100644 --- a/src/crimson/os/seastore/segment_manager/ephemeral.h +++ b/src/crimson/os/seastore/segment_manager/ephemeral.h @@ -25,7 +25,7 @@ struct ephemeral_config_t { ceph_assert_always(size > 0); ceph_assert_always(size <= DEVICE_OFF_MAX); ceph_assert_always(segment_size > 0); - ceph_assert_always(segment_size <= MAX_SEG_OFF); + ceph_assert_always(segment_size <= SEGMENT_OFF_MAX); ceph_assert_always(size / segment_size > 0); ceph_assert_always(size / segment_size <= DEVICE_SEGMENT_ID_MAX); } diff --git a/src/crimson/os/seastore/segment_manager/zns.h b/src/crimson/os/seastore/segment_manager/zns.h index 65e0d213ad67..62caf8f893c3 100644 --- a/src/crimson/os/seastore/segment_manager/zns.h +++ b/src/crimson/os/seastore/segment_manager/zns.h @@ -63,7 +63,7 @@ namespace crimson::os::seastore::segment_manager::zns { ceph_assert_always(size > 0); ceph_assert_always(size <= DEVICE_OFF_MAX); ceph_assert_always(segment_capacity > 0); - ceph_assert_always(segment_capacity <= MAX_SEG_OFF); + ceph_assert_always(segment_capacity <= SEGMENT_OFF_MAX); ceph_assert_always(segments > 0); ceph_assert_always(segments <= DEVICE_SEGMENT_ID_MAX); }