Skip to content

Commit b2d604e

Browse files
committed
crimson/os/seastore: construct laddr_t explicitly
Signed-off-by: Zhang Song <[email protected]>
1 parent 1469feb commit b2d604e

File tree

8 files changed

+74
-73
lines changed

8 files changed

+74
-73
lines changed

src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/dummy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ class DummyNodeExtentManager final: public NodeExtentManager {
150150
Transaction& t, extent_len_t len) {
151151
assert(len % ALIGNMENT == 0);
152152
auto r = ceph::buffer::create_aligned(len, ALIGNMENT);
153-
auto addr = laddr_t(reinterpret_cast<laddr_t::Unsigned>(r->get_data()));
153+
auto addr = laddr_t::from_byte_offset(
154+
reinterpret_cast<laddr_t::Unsigned>(r->get_data()));
154155
auto bp = ceph::bufferptr(std::move(r));
155156
auto extent = Ref<DummyNodeExtent>(new DummyNodeExtent(std::move(bp)));
156157
extent->set_laddr(addr);

src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ static laddr_t get_lba_hint(shard_t shard, pool_t pool, crush_hash_t crush) {
4646
// FIXME: It is possible that PGs from different pools share the same prefix
4747
// if the mask 0xFF is not long enough, result in unexpected transaction
4848
// conflicts.
49-
return laddr_t((uint64_t)(shard & 0xFF)<<56 |
50-
(uint64_t)(pool & 0xFF)<<48 |
51-
(uint64_t)(crush )<<16);
49+
return laddr_t::from_raw_uint((uint64_t)(shard & 0xFF)<<56 |
50+
(uint64_t)(pool & 0xFF)<<48 |
51+
(uint64_t)(crush )<<16);
5252
}
5353

5454
struct node_offset_packed_t {

src/crimson/tools/store_nbd/tm_driver.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ seastar::future<> TMDriver::write(
2727
"write",
2828
[this, offset, &ptr](auto& t)
2929
{
30-
return tm->remove(t, laddr_t(offset)
30+
return tm->remove(t, laddr_t::from_byte_offset(offset)
3131
).discard_result().handle_error_interruptible(
3232
crimson::ct_error::enoent::handle([](auto) { return seastar::now(); }),
3333
crimson::ct_error::pass_further_all{}
3434
).si_then([this, offset, &t, &ptr] {
3535
logger().debug("dec_ref complete");
36-
return tm->alloc_data_extents<TestBlock>(t, laddr_t(offset), ptr.length());
36+
return tm->alloc_data_extents<TestBlock>(t, laddr_t::from_byte_offset(offset), ptr.length());
3737
}).si_then([this, offset, &t, &ptr](auto extents) mutable {
3838
boost::ignore_unused(offset); // avoid clang warning;
3939
auto off = offset;
4040
auto left = ptr.length();
4141
size_t written = 0;
4242
for (auto &ext : extents) {
43-
assert(ext->get_laddr() == laddr_t(off));
43+
assert(ext->get_laddr() == laddr_t::from_byte_offset(off));
4444
assert(ext->get_bptr().length() <= left);
4545
ptr.copy_out(written, ext->get_length(), ext->get_bptr().c_str());
4646
off += ext->get_length();
@@ -111,9 +111,9 @@ seastar::future<bufferlist> TMDriver::read(
111111
"read",
112112
[=, &blret, this](auto& t)
113113
{
114-
return read_extents(t, laddr_t(offset), size
114+
return read_extents(t, laddr_t::from_byte_offset(offset), size
115115
).si_then([=, &blret](auto ext_list) {
116-
laddr_t cur(offset);
116+
auto cur = laddr_t::from_byte_offset(offset);
117117
for (auto &i: ext_list) {
118118
if (cur != i.first) {
119119
assert(cur < i.first);

src/test/crimson/seastore/onode_tree/test_fltree_onode_manager.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ struct onode_item_t {
3232
void initialize(Transaction& t, Onode& value) const {
3333
auto &ftvalue = static_cast<FLTreeOnode&>(value);
3434
ftvalue.update_onode_size(t, size);
35-
auto oroot = omap_root_t(laddr_t(id), cnt_modify,
35+
auto oroot = omap_root_t(laddr_t::from_raw_uint(id), cnt_modify,
3636
value.get_metadata_hint(block_size));
3737
ftvalue.update_omap_root(t, oroot);
3838
validate(value);
3939
}
4040

4141
void validate(Onode& value) const {
4242
auto& layout = value.get_layout();
43-
ceph_assert(laddr_t(layout.size) == laddr_t{size});
44-
ceph_assert(layout.omap_root.get(value.get_metadata_hint(block_size)).addr == laddr_t(id));
43+
ceph_assert(uint64_t(layout.size) == uint64_t{size});
44+
ceph_assert(layout.omap_root.get(value.get_metadata_hint(block_size)).addr == laddr_t::from_raw_uint(id));
4545
ceph_assert(layout.omap_root.get(value.get_metadata_hint(block_size)).depth == cnt_modify);
4646
}
4747

src/test/crimson/seastore/onode_tree/test_staged_fltree.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ class DummyChildPool {
10481048
static Ref<DummyChild> create_new(
10491049
const std::set<ghobject_t>& keys, bool is_level_tail, DummyChildPool& pool) {
10501050
static uint64_t seed = 0;
1051-
return create(keys, is_level_tail, laddr_t(seed++), pool);
1051+
return create(keys, is_level_tail, laddr_t::from_raw_uint(seed++), pool);
10521052
}
10531053

10541054
static eagain_ifuture<Ref<DummyChild>> create_initial(

src/test/crimson/seastore/test_btree_lba_manager.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,14 @@ TEST_F(lba_btree_test, basic)
378378
run_async([this] {
379379
constexpr unsigned total = 16<<10;
380380
for (unsigned i = 0; i < total; i += 16) {
381-
insert(laddr_t(i), 8);
381+
insert(laddr_t::from_raw_uint(i), 8);
382382
}
383383

384384
for (unsigned i = 0; i < total; i += 16) {
385-
check_lower_bound(laddr_t(i));
386-
check_lower_bound(laddr_t(i + 4));
387-
check_lower_bound(laddr_t(i + 8));
388-
check_lower_bound(laddr_t(i + 12));
385+
check_lower_bound(laddr_t::from_raw_uint(i));
386+
check_lower_bound(laddr_t::from_raw_uint(i + 4));
387+
check_lower_bound(laddr_t::from_raw_uint(i + 8));
388+
check_lower_bound(laddr_t::from_raw_uint(i + 12));
389389
}
390390
});
391391
}
@@ -681,7 +681,7 @@ struct btree_lba_manager_test : btree_test_base {
681681
TEST_F(btree_lba_manager_test, basic)
682682
{
683683
run_async([this] {
684-
laddr_t laddr = laddr_t(0x12345678 * block_size);
684+
laddr_t laddr = laddr_t::from_byte_offset(0x12345678 * block_size);
685685
{
686686
// write initial mapping
687687
auto t = create_transaction();
@@ -831,23 +831,23 @@ TEST_F(btree_lba_manager_test, split_merge_multi)
831831
}
832832
};
833833
iterate([&](auto &t, auto idx) {
834-
alloc_mappings(t, laddr_t(idx * block_size), block_size);
834+
alloc_mappings(t, laddr_t::from_byte_offset(idx * block_size), block_size);
835835
});
836836
check_mappings();
837837
iterate([&](auto &t, auto idx) {
838838
if ((idx % 32) > 0) {
839-
decref_mapping(t, laddr_t(idx * block_size));
839+
decref_mapping(t, laddr_t::from_byte_offset(idx * block_size));
840840
}
841841
});
842842
check_mappings();
843843
iterate([&](auto &t, auto idx) {
844844
if ((idx % 32) > 0) {
845-
alloc_mappings(t, laddr_t(idx * block_size), block_size);
845+
alloc_mappings(t, laddr_t::from_byte_offset(idx * block_size), block_size);
846846
}
847847
});
848848
check_mappings();
849849
iterate([&](auto &t, auto idx) {
850-
decref_mapping(t, laddr_t(idx * block_size));
850+
decref_mapping(t, laddr_t::from_byte_offset(idx * block_size));
851851
});
852852
check_mappings();
853853
});

src/test/crimson/seastore/test_object_data_handler.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,14 @@ struct object_data_handler_test_t:
218218
objaddr_t offset,
219219
extent_len_t length) {
220220
auto ret = with_trans_intr(t, [&](auto &t) {
221-
return tm->get_pins(t, laddr_t(offset), length);
221+
return tm->get_pins(t, laddr_t::from_byte_offset(offset), length);
222222
}).unsafe_get();
223223
return ret;
224224
}
225225
std::list<LBAMappingRef> get_mappings(objaddr_t offset, extent_len_t length) {
226226
auto t = create_mutate_transaction();
227227
auto ret = with_trans_intr(*t, [&](auto &t) {
228-
return tm->get_pins(t, laddr_t(offset), length);
228+
return tm->get_pins(t, laddr_t::from_byte_offset(offset), length);
229229
}).unsafe_get();
230230
return ret;
231231
}
@@ -798,7 +798,7 @@ TEST_P(object_data_handler_test_t, overwrite_then_read_within_transaction) {
798798
auto pins = get_mappings(*t, base, len);
799799
assert(pins.size() == 1);
800800
auto pin1 = remap_pin(*t, std::move(pins.front()), 4096, 8192);
801-
auto ext = get_extent(*t, laddr_t(base + 4096), 4096 * 2);
801+
auto ext = get_extent(*t, laddr_t::from_byte_offset(base + 4096), 4096 * 2);
802802
ASSERT_TRUE(ext->is_exist_clean());
803803
write(*t, base + 4096, 4096, 'y');
804804
ASSERT_TRUE(ext->is_exist_mutation_pending());

0 commit comments

Comments
 (0)