diff options
8 files changed, 74 insertions, 73 deletions
diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/dummy.h b/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/dummy.h index ab5971dfe5f..df2e5fe7503 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/dummy.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/dummy.h @@ -150,7 +150,8 @@ class DummyNodeExtentManager final: public NodeExtentManager { Transaction& t, extent_len_t len) { assert(len % ALIGNMENT == 0); auto r = ceph::buffer::create_aligned(len, ALIGNMENT); - auto addr = laddr_t(reinterpret_cast<laddr_t::Unsigned>(r->get_data())); + auto addr = laddr_t::from_byte_offset( + reinterpret_cast<laddr_t::Unsigned>(r->get_data())); auto bp = ceph::bufferptr(std::move(r)); auto extent = Ref<DummyNodeExtent>(new DummyNodeExtent(std::move(bp))); extent->set_laddr(addr); diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h index 18ebb039f89..b40f7a061a8 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h @@ -46,9 +46,9 @@ static laddr_t get_lba_hint(shard_t shard, pool_t pool, crush_hash_t crush) { // FIXME: It is possible that PGs from different pools share the same prefix // if the mask 0xFF is not long enough, result in unexpected transaction // conflicts. - return laddr_t((uint64_t)(shard & 0xFF)<<56 | - (uint64_t)(pool & 0xFF)<<48 | - (uint64_t)(crush )<<16); + return laddr_t::from_raw_uint((uint64_t)(shard & 0xFF)<<56 | + (uint64_t)(pool & 0xFF)<<48 | + (uint64_t)(crush )<<16); } struct node_offset_packed_t { diff --git a/src/crimson/tools/store_nbd/tm_driver.cc b/src/crimson/tools/store_nbd/tm_driver.cc index 860ce517db8..44c62fe8b22 100644 --- a/src/crimson/tools/store_nbd/tm_driver.cc +++ b/src/crimson/tools/store_nbd/tm_driver.cc @@ -27,20 +27,20 @@ seastar::future<> TMDriver::write( "write", [this, offset, &ptr](auto& t) { - return tm->remove(t, laddr_t(offset) + return tm->remove(t, laddr_t::from_byte_offset(offset) ).discard_result().handle_error_interruptible( crimson::ct_error::enoent::handle([](auto) { return seastar::now(); }), crimson::ct_error::pass_further_all{} ).si_then([this, offset, &t, &ptr] { logger().debug("dec_ref complete"); - return tm->alloc_data_extents<TestBlock>(t, laddr_t(offset), ptr.length()); + return tm->alloc_data_extents<TestBlock>(t, laddr_t::from_byte_offset(offset), ptr.length()); }).si_then([this, offset, &t, &ptr](auto extents) mutable { boost::ignore_unused(offset); // avoid clang warning; auto off = offset; auto left = ptr.length(); size_t written = 0; for (auto &ext : extents) { - assert(ext->get_laddr() == laddr_t(off)); + assert(ext->get_laddr() == laddr_t::from_byte_offset(off)); assert(ext->get_bptr().length() <= left); ptr.copy_out(written, ext->get_length(), ext->get_bptr().c_str()); off += ext->get_length(); @@ -111,9 +111,9 @@ seastar::future<bufferlist> TMDriver::read( "read", [=, &blret, this](auto& t) { - return read_extents(t, laddr_t(offset), size + return read_extents(t, laddr_t::from_byte_offset(offset), size ).si_then([=, &blret](auto ext_list) { - laddr_t cur(offset); + auto cur = laddr_t::from_byte_offset(offset); for (auto &i: ext_list) { if (cur != i.first) { assert(cur < i.first); diff --git a/src/test/crimson/seastore/onode_tree/test_fltree_onode_manager.cc b/src/test/crimson/seastore/onode_tree/test_fltree_onode_manager.cc index 2365f3a0da4..b3a915565af 100644 --- a/src/test/crimson/seastore/onode_tree/test_fltree_onode_manager.cc +++ b/src/test/crimson/seastore/onode_tree/test_fltree_onode_manager.cc @@ -32,7 +32,7 @@ struct onode_item_t { void initialize(Transaction& t, Onode& value) const { auto &ftvalue = static_cast<FLTreeOnode&>(value); ftvalue.update_onode_size(t, size); - auto oroot = omap_root_t(laddr_t(id), cnt_modify, + auto oroot = omap_root_t(laddr_t::from_raw_uint(id), cnt_modify, value.get_metadata_hint(block_size)); ftvalue.update_omap_root(t, oroot); validate(value); @@ -40,8 +40,8 @@ struct onode_item_t { void validate(Onode& value) const { auto& layout = value.get_layout(); - ceph_assert(laddr_t(layout.size) == laddr_t{size}); - ceph_assert(layout.omap_root.get(value.get_metadata_hint(block_size)).addr == laddr_t(id)); + ceph_assert(uint64_t(layout.size) == uint64_t{size}); + ceph_assert(layout.omap_root.get(value.get_metadata_hint(block_size)).addr == laddr_t::from_raw_uint(id)); ceph_assert(layout.omap_root.get(value.get_metadata_hint(block_size)).depth == cnt_modify); } diff --git a/src/test/crimson/seastore/onode_tree/test_staged_fltree.cc b/src/test/crimson/seastore/onode_tree/test_staged_fltree.cc index 349fcfa14e2..fb38f8e6ca6 100644 --- a/src/test/crimson/seastore/onode_tree/test_staged_fltree.cc +++ b/src/test/crimson/seastore/onode_tree/test_staged_fltree.cc @@ -1048,7 +1048,7 @@ class DummyChildPool { static Ref<DummyChild> create_new( const std::set<ghobject_t>& keys, bool is_level_tail, DummyChildPool& pool) { static uint64_t seed = 0; - return create(keys, is_level_tail, laddr_t(seed++), pool); + return create(keys, is_level_tail, laddr_t::from_raw_uint(seed++), pool); } static eagain_ifuture<Ref<DummyChild>> create_initial( diff --git a/src/test/crimson/seastore/test_btree_lba_manager.cc b/src/test/crimson/seastore/test_btree_lba_manager.cc index 67204023a75..b8c6b1d6e30 100644 --- a/src/test/crimson/seastore/test_btree_lba_manager.cc +++ b/src/test/crimson/seastore/test_btree_lba_manager.cc @@ -378,14 +378,14 @@ TEST_F(lba_btree_test, basic) run_async([this] { constexpr unsigned total = 16<<10; for (unsigned i = 0; i < total; i += 16) { - insert(laddr_t(i), 8); + insert(laddr_t::from_raw_uint(i), 8); } for (unsigned i = 0; i < total; i += 16) { - check_lower_bound(laddr_t(i)); - check_lower_bound(laddr_t(i + 4)); - check_lower_bound(laddr_t(i + 8)); - check_lower_bound(laddr_t(i + 12)); + check_lower_bound(laddr_t::from_raw_uint(i)); + check_lower_bound(laddr_t::from_raw_uint(i + 4)); + check_lower_bound(laddr_t::from_raw_uint(i + 8)); + check_lower_bound(laddr_t::from_raw_uint(i + 12)); } }); } @@ -681,7 +681,7 @@ struct btree_lba_manager_test : btree_test_base { TEST_F(btree_lba_manager_test, basic) { run_async([this] { - laddr_t laddr = laddr_t(0x12345678 * block_size); + laddr_t laddr = laddr_t::from_byte_offset(0x12345678 * block_size); { // write initial mapping auto t = create_transaction(); @@ -831,23 +831,23 @@ TEST_F(btree_lba_manager_test, split_merge_multi) } }; iterate([&](auto &t, auto idx) { - alloc_mappings(t, laddr_t(idx * block_size), block_size); + alloc_mappings(t, laddr_t::from_byte_offset(idx * block_size), block_size); }); check_mappings(); iterate([&](auto &t, auto idx) { if ((idx % 32) > 0) { - decref_mapping(t, laddr_t(idx * block_size)); + decref_mapping(t, laddr_t::from_byte_offset(idx * block_size)); } }); check_mappings(); iterate([&](auto &t, auto idx) { if ((idx % 32) > 0) { - alloc_mappings(t, laddr_t(idx * block_size), block_size); + alloc_mappings(t, laddr_t::from_byte_offset(idx * block_size), block_size); } }); check_mappings(); iterate([&](auto &t, auto idx) { - decref_mapping(t, laddr_t(idx * block_size)); + decref_mapping(t, laddr_t::from_byte_offset(idx * block_size)); }); check_mappings(); }); diff --git a/src/test/crimson/seastore/test_object_data_handler.cc b/src/test/crimson/seastore/test_object_data_handler.cc index fe47d46a912..7417d700020 100644 --- a/src/test/crimson/seastore/test_object_data_handler.cc +++ b/src/test/crimson/seastore/test_object_data_handler.cc @@ -218,14 +218,14 @@ struct object_data_handler_test_t: objaddr_t offset, extent_len_t length) { auto ret = with_trans_intr(t, [&](auto &t) { - return tm->get_pins(t, laddr_t(offset), length); + return tm->get_pins(t, laddr_t::from_byte_offset(offset), length); }).unsafe_get(); return ret; } std::list<LBAMappingRef> get_mappings(objaddr_t offset, extent_len_t length) { auto t = create_mutate_transaction(); auto ret = with_trans_intr(*t, [&](auto &t) { - return tm->get_pins(t, laddr_t(offset), length); + return tm->get_pins(t, laddr_t::from_byte_offset(offset), length); }).unsafe_get(); return ret; } @@ -798,7 +798,7 @@ TEST_P(object_data_handler_test_t, overwrite_then_read_within_transaction) { auto pins = get_mappings(*t, base, len); assert(pins.size() == 1); auto pin1 = remap_pin(*t, std::move(pins.front()), 4096, 8192); - auto ext = get_extent(*t, laddr_t(base + 4096), 4096 * 2); + auto ext = get_extent(*t, laddr_t::from_byte_offset(base + 4096), 4096 * 2); ASSERT_TRUE(ext->is_exist_clean()); write(*t, base + 4096, 4096, 'y'); ASSERT_TRUE(ext->is_exist_mutation_pending()); diff --git a/src/test/crimson/seastore/test_transaction_manager.cc b/src/test/crimson/seastore/test_transaction_manager.cc index f2c8c3ccab3..70dec30f0ec 100644 --- a/src/test/crimson/seastore/test_transaction_manager.cc +++ b/src/test/crimson/seastore/test_transaction_manager.cc @@ -67,7 +67,7 @@ struct transaction_manager_test_t : } laddr_t get_random_laddr(size_t block_size, size_t limit) { - return laddr_t(block_size * + return laddr_t::from_byte_offset(block_size * std::uniform_int_distribution<>(0, (limit / block_size) - 1)(gen)); } @@ -830,9 +830,9 @@ struct transaction_manager_test_t : auto t = create_transaction(); auto extent = alloc_extent( t, - laddr_t(i * BSIZE), + laddr_t::from_byte_offset(i * BSIZE), BSIZE); - ASSERT_EQ(laddr_t(i * BSIZE), extent->get_laddr()); + ASSERT_EQ(laddr_t::from_byte_offset(i * BSIZE), extent->get_laddr()); submit_transaction(std::move(t)); } @@ -844,7 +844,7 @@ struct transaction_manager_test_t : boost::make_counting_iterator(0lu), boost::make_counting_iterator(BLOCKS), [this, &t](auto i) { - return tm->read_extent<TestBlock>(t, laddr_t(i * BSIZE), BSIZE + return tm->read_extent<TestBlock>(t, laddr_t::from_byte_offset(i * BSIZE), BSIZE ).si_then([](auto) { return seastar::now(); }); @@ -870,9 +870,9 @@ struct transaction_manager_test_t : auto t = create_transaction(); auto extent = alloc_extent( t, - laddr_t(i * BSIZE), + laddr_t::from_byte_offset(i * BSIZE), BSIZE); - ASSERT_EQ(laddr_t(i * BSIZE), extent->get_laddr()); + ASSERT_EQ(laddr_t::from_byte_offset(i * BSIZE), extent->get_laddr()); if (try_submit_transaction(std::move(t))) break; } @@ -1346,10 +1346,10 @@ struct transaction_manager_test_t : void test_remap_pin() { run_async([this] { disable_max_extent_size(); - constexpr laddr_t l_offset = laddr_t(32 << 10); - constexpr size_t l_len = 32 << 10; - constexpr laddr_t r_offset = laddr_t(64 << 10); - constexpr size_t r_len = 32 << 10; + laddr_t l_offset = laddr_t::from_byte_offset(32 << 10); + size_t l_len = 32 << 10; + laddr_t r_offset = laddr_t::from_byte_offset(64 << 10); + size_t r_len = 32 << 10; { auto t = create_transaction(); auto lext = alloc_extent(t, l_offset, l_len); @@ -1400,12 +1400,12 @@ struct transaction_manager_test_t : void test_clone_and_remap_pin() { run_async([this] { disable_max_extent_size(); - constexpr laddr_t l_offset = laddr_t(32 << 10); - constexpr size_t l_len = 32 << 10; - constexpr laddr_t r_offset = laddr_t(64 << 10); - constexpr size_t r_len = 32 << 10; - constexpr laddr_t l_clone_offset = laddr_t(96 << 10); - constexpr laddr_t r_clone_offset = laddr_t(128 << 10); + laddr_t l_offset = laddr_t::from_byte_offset(32 << 10); + size_t l_len = 32 << 10; + laddr_t r_offset = laddr_t::from_byte_offset(64 << 10); + size_t r_len = 32 << 10; + laddr_t l_clone_offset = laddr_t::from_byte_offset(96 << 10); + laddr_t r_clone_offset = laddr_t::from_byte_offset(128 << 10); { auto t = create_transaction(); auto lext = alloc_extent(t, l_offset, l_len); @@ -1455,12 +1455,12 @@ struct transaction_manager_test_t : void test_overwrite_pin() { run_async([this] { disable_max_extent_size(); - constexpr laddr_t m_offset = laddr_t(8 << 10); - constexpr size_t m_len = 56 << 10; - constexpr laddr_t l_offset = laddr_t(64 << 10); - constexpr size_t l_len = 64 << 10; - constexpr laddr_t r_offset = laddr_t(128 << 10); - constexpr size_t r_len = 64 << 10; + laddr_t m_offset = laddr_t::from_byte_offset(8 << 10); + size_t m_len = 56 << 10; + laddr_t l_offset = laddr_t::from_byte_offset(64 << 10); + size_t l_len = 64 << 10; + laddr_t r_offset = laddr_t::from_byte_offset(128 << 10); + size_t r_len = 64 << 10; { auto t = create_transaction(); auto m_ext = alloc_extent(t, m_offset, m_len); @@ -1665,7 +1665,7 @@ struct transaction_manager_test_t : auto end_off = split_points.front(); split_points.pop_front(); ASSERT_TRUE(start_off <= end_off); - if ((laddr_t(end_off << 10) == pin0->get_key() + pin0->get_length()) + if ((laddr_t::from_byte_offset(end_off << 10) == pin0->get_key() + pin0->get_length()) || (start_off == end_off)) { if (split_points.empty() && empty_transaction) { early_exit++; @@ -1766,7 +1766,7 @@ struct tm_random_block_device_test_t : TEST_P(tm_random_block_device_test_t, scatter_allocation) { run_async([this] { - constexpr laddr_t ADDR = laddr_t(0xFF * 4096); + laddr_t ADDR = laddr_t::from_byte_offset(0xFF * 4096); epm->prefill_fragmented_devices(); auto t = create_transaction(); for (int i = 0; i < 1991; i++) { @@ -1784,7 +1784,7 @@ TEST_P(tm_single_device_test_t, basic) { constexpr size_t SIZE = 4096; run_async([this] { - constexpr laddr_t ADDR = laddr_t(0xFF * SIZE); + laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE); { auto t = create_transaction(); auto extent = alloc_extent( @@ -1805,7 +1805,7 @@ TEST_P(tm_single_device_test_t, mutate) { constexpr size_t SIZE = 4096; run_async([this] { - constexpr laddr_t ADDR = laddr_t(0xFF * SIZE); + laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE); { auto t = create_transaction(); auto extent = alloc_extent( @@ -1843,8 +1843,8 @@ TEST_P(tm_single_device_test_t, allocate_lba_conflict) { constexpr size_t SIZE = 4096; run_async([this] { - constexpr laddr_t ADDR = laddr_t(0xFF * SIZE); - constexpr laddr_t ADDR2 = laddr_t(0xFE * SIZE); + laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE); + laddr_t ADDR2 = laddr_t::from_byte_offset(0xFE * SIZE); auto t = create_transaction(); auto t2 = create_transaction(); @@ -1881,7 +1881,7 @@ TEST_P(tm_single_device_test_t, mutate_lba_conflict) for (unsigned i = 0; i < 300; ++i) { auto extent = alloc_extent( t, - laddr_t(i * SIZE), + laddr_t::from_byte_offset(i * SIZE), SIZE); } check_mappings(t); @@ -1889,7 +1889,7 @@ TEST_P(tm_single_device_test_t, mutate_lba_conflict) check(); } - constexpr laddr_t ADDR = laddr_t(150 * SIZE); + laddr_t ADDR = laddr_t::from_byte_offset(150 * SIZE); { auto t = create_transaction(); auto t2 = create_transaction(); @@ -1915,15 +1915,15 @@ TEST_P(tm_single_device_test_t, concurrent_mutate_lba_no_conflict) { constexpr size_t SIZE = 4096; constexpr size_t NUM = 500; - constexpr laddr_t addr = L_ADDR_MIN; - constexpr laddr_t addr2 = laddr_t(SIZE * (NUM - 1)); + laddr_t addr = L_ADDR_MIN; + laddr_t addr2 = laddr_t::from_byte_offset(SIZE * (NUM - 1)); run_async([this, addr, addr2] { { auto t = create_transaction(); for (unsigned i = 0; i < NUM; ++i) { auto extent = alloc_extent( t, - laddr_t(i * SIZE), + laddr_t::from_byte_offset(i * SIZE), SIZE); } submit_transaction(std::move(t)); @@ -1947,7 +1947,7 @@ TEST_P(tm_single_device_test_t, create_remove_same_transaction) { constexpr size_t SIZE = 4096; run_async([this] { - constexpr laddr_t ADDR = laddr_t(0xFF * SIZE); + laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE); { auto t = create_transaction(); auto extent = alloc_extent( @@ -1983,7 +1983,7 @@ TEST_P(tm_single_device_test_t, split_merge_read_same_transaction) for (unsigned i = 0; i < 300; ++i) { auto extent = alloc_extent( t, - laddr_t(i * SIZE), + laddr_t::from_byte_offset(i * SIZE), SIZE); } check_mappings(t); @@ -1995,7 +1995,7 @@ TEST_P(tm_single_device_test_t, split_merge_read_same_transaction) for (unsigned i = 0; i < 240; ++i) { dec_ref( t, - laddr_t(i * SIZE)); + laddr_t::from_byte_offset(i * SIZE)); } check_mappings(t); submit_transaction(std::move(t)); @@ -2008,7 +2008,7 @@ TEST_P(tm_single_device_test_t, inc_dec_ref) { constexpr size_t SIZE = 4096; run_async([this] { - constexpr laddr_t ADDR = laddr_t(0xFF * SIZE); + laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE); { auto t = create_transaction(); auto extent = alloc_extent( @@ -2059,10 +2059,10 @@ TEST_P(tm_single_device_test_t, cause_lba_split) auto t = create_transaction(); auto extent = alloc_extent( t, - laddr_t(i * SIZE), + laddr_t::from_byte_offset(i * SIZE), SIZE, (char)(i & 0xFF)); - ASSERT_EQ(laddr_t(i * SIZE), extent->get_laddr()); + ASSERT_EQ(laddr_t::from_byte_offset(i * SIZE), extent->get_laddr()); submit_transaction(std::move(t)); } check(); @@ -2080,9 +2080,9 @@ TEST_P(tm_single_device_test_t, random_writes) auto t = create_transaction(); auto extent = alloc_extent( t, - laddr_t(i * BSIZE), + laddr_t::from_byte_offset(i * BSIZE), BSIZE); - ASSERT_EQ(laddr_t(i * BSIZE), extent->get_laddr()); + ASSERT_EQ(laddr_t::from_byte_offset(i * BSIZE), extent->get_laddr()); submit_transaction(std::move(t)); } @@ -2098,7 +2098,7 @@ TEST_P(tm_single_device_test_t, random_writes) // pad out transaction auto paddings = alloc_extents( t, - laddr_t(TOTAL + (k * PADDING_SIZE)), + laddr_t::from_byte_offset(TOTAL + (k * PADDING_SIZE)), PADDING_SIZE); for (auto &padding : paddings) { dec_ref(t, padding->get_laddr()); @@ -2184,7 +2184,7 @@ TEST_P(tm_single_device_test_t, invalid_lba_mapping_detect) for (int i = 0; i < LEAF_NODE_CAPACITY; i++) { auto extent = alloc_extent( t, - laddr_t(i * 4096), + laddr_t::from_byte_offset(i * 4096), 4096, 'a'); } @@ -2193,12 +2193,12 @@ TEST_P(tm_single_device_test_t, invalid_lba_mapping_detect) { auto t = create_transaction(); - auto pin = get_pin(t, laddr_t((LEAF_NODE_CAPACITY - 1) * 4096)); + auto pin = get_pin(t, laddr_t::from_byte_offset((LEAF_NODE_CAPACITY - 1) * 4096)); assert(pin->is_parent_viewable()); - auto extent = alloc_extent(t, laddr_t(LEAF_NODE_CAPACITY * 4096), 4096, 'a'); + auto extent = alloc_extent(t, laddr_t::from_byte_offset(LEAF_NODE_CAPACITY * 4096), 4096, 'a'); assert(!pin->is_parent_viewable()); - pin = get_pin(t, laddr_t(LEAF_NODE_CAPACITY * 4096)); - std::ignore = alloc_extent(t, laddr_t((LEAF_NODE_CAPACITY + 1) * 4096), 4096, 'a'); + pin = get_pin(t, laddr_t::from_byte_offset(LEAF_NODE_CAPACITY * 4096)); + std::ignore = alloc_extent(t, laddr_t::from_byte_offset((LEAF_NODE_CAPACITY + 1) * 4096), 4096, 'a'); assert(pin->is_parent_viewable()); assert(pin->parent_modified()); pin->maybe_fix_pos(); |