summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYingxin <yingxin.cheng@intel.com>2024-11-15 09:51:05 +0100
committerGitHub <noreply@github.com>2024-11-15 09:51:05 +0100
commit3a35aeb3a95af5dfbe9bf22299ff51e7e5bc6ac2 (patch)
tree0e3ac80d21aebaa7c8e8f3f744a5f243298c92e7
parentMerge pull request #60209 from myoungwon/wip-init-onode-layout (diff)
parenttest/crimson/seastore/test_object_data_handler: always access object (diff)
downloadceph-3a35aeb3a95af5dfbe9bf22299ff51e7e5bc6ac2.tar.xz
ceph-3a35aeb3a95af5dfbe9bf22299ff51e7e5bc6ac2.zip
Merge pull request #60655 from xxhdx1985126/wip-seastore-move-out-root-meta
crimson/os/seastore: move the root meta out of the root block Reviewed-by: Yingxin Cheng <yingxin.cheng@intel.com>
Diffstat (limited to '')
-rw-r--r--src/crimson/os/seastore/cache.cc10
-rw-r--r--src/crimson/os/seastore/cache.h7
-rw-r--r--src/crimson/os/seastore/random_block_manager/block_rb_manager.cc6
-rw-r--r--src/crimson/os/seastore/root_meta.h76
-rw-r--r--src/crimson/os/seastore/seastore_types.cc2
-rw-r--r--src/crimson/os/seastore/seastore_types.h61
-rw-r--r--src/crimson/os/seastore/transaction_manager.cc2
-rw-r--r--src/crimson/os/seastore/transaction_manager.h61
-rw-r--r--src/test/crimson/seastore/test_object_data_handler.cc24
-rw-r--r--src/test/crimson/seastore/test_transaction_manager.cc104
10 files changed, 234 insertions, 119 deletions
diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc
index 5dcb7514ee1..70fec7caca4 100644
--- a/src/crimson/os/seastore/cache.cc
+++ b/src/crimson/os/seastore/cache.cc
@@ -172,6 +172,7 @@ void Cache::register_metrics()
{extent_types_t::LADDR_INTERNAL, sm::label_instance("ext", "LADDR_INTERNAL")},
{extent_types_t::LADDR_LEAF, sm::label_instance("ext", "LADDR_LEAF")},
{extent_types_t::DINK_LADDR_LEAF, sm::label_instance("ext", "DINK_LADDR_LEAF")},
+ {extent_types_t::ROOT_META, sm::label_instance("ext", "ROOT_META")},
{extent_types_t::OMAP_INNER, sm::label_instance("ext", "OMAP_INNER")},
{extent_types_t::OMAP_LEAF, sm::label_instance("ext", "OMAP_LEAF")},
{extent_types_t::ONODE_BLOCK_STAGED, sm::label_instance("ext", "ONODE_BLOCK_STAGED")},
@@ -1093,6 +1094,9 @@ CachedExtentRef Cache::alloc_new_extent_by_type(
case extent_types_t::LADDR_LEAF:
return alloc_new_non_data_extent<lba_manager::btree::LBALeafNode>(
t, length, hint, gen);
+ case extent_types_t::ROOT_META:
+ return alloc_new_non_data_extent<RootMetaBlock>(
+ t, length, hint, gen);
case extent_types_t::ONODE_BLOCK_STAGED:
return alloc_new_non_data_extent<onode::SeastoreNodeExtent>(
t, length, hint, gen);
@@ -2193,6 +2197,12 @@ Cache::do_get_caching_extent_by_type(
).safe_then([](auto extent) {
return CachedExtentRef(extent.detach(), false /* add_ref */);
});
+ case extent_types_t::ROOT_META:
+ return do_get_caching_extent<RootMetaBlock>(
+ offset, length, std::move(extent_init_func), std::move(on_cache)
+ ).safe_then([](auto extent) {
+ return CachedExtentRef(extent.detach(), false /* add_ref */);
+ });
case extent_types_t::OMAP_INNER:
return do_get_caching_extent<omap_manager::OMapInnerNode>(
offset, length, std::move(extent_init_func), std::move(on_cache)
diff --git a/src/crimson/os/seastore/cache.h b/src/crimson/os/seastore/cache.h
index dba3610e95f..c37d9c5c7cd 100644
--- a/src/crimson/os/seastore/cache.h
+++ b/src/crimson/os/seastore/cache.h
@@ -978,7 +978,8 @@ public:
auto result = epm.alloc_new_non_data_extent(t, T::TYPE, length, hint, gen);
#endif
if (!result) {
- return nullptr;
+ SUBERRORT(seastore_cache, "insufficient space", t);
+ std::rethrow_exception(crimson::ct_error::enospc::exception_ptr());
}
auto ret = CachedExtent::make_cached_extent_ref<T>(std::move(result->bp));
ret->init(CachedExtent::extent_state_t::INITIAL_WRITE_PENDING,
@@ -1019,6 +1020,10 @@ public:
#else
auto results = epm.alloc_new_data_extents(t, T::TYPE, length, hint, gen);
#endif
+ if (results.empty()) {
+ SUBERRORT(seastore_cache, "insufficient space", t);
+ std::rethrow_exception(crimson::ct_error::enospc::exception_ptr());
+ }
std::vector<TCachedExtentRef<T>> extents;
for (auto &result : results) {
auto ret = CachedExtent::make_cached_extent_ref<T>(std::move(result.bp));
diff --git a/src/crimson/os/seastore/random_block_manager/block_rb_manager.cc b/src/crimson/os/seastore/random_block_manager/block_rb_manager.cc
index 9f6a566d15c..97b7902edf5 100644
--- a/src/crimson/os/seastore/random_block_manager/block_rb_manager.cc
+++ b/src/crimson/os/seastore/random_block_manager/block_rb_manager.cc
@@ -188,10 +188,10 @@ BlockRBManager::write_ertr::future<> BlockRBManager::write(
void BlockRBManager::prefill_fragmented_device()
{
LOG_PREFIX(BlockRBManager::prefill_fragmented_device);
- // the first 2 blocks must be allocated to lba root
+ // the first 3 blocks must be allocated to lba root
// and backref root during mkfs
- for (size_t block = get_block_size() * 2;
- block <= get_size() - get_block_size() * 2;
+ for (size_t block = get_block_size() * 3;
+ block <= get_size() - get_block_size() * 3;
block += get_block_size() * 2) {
DEBUG("marking {}~{} used",
get_start_rbm_addr() + block,
diff --git a/src/crimson/os/seastore/root_meta.h b/src/crimson/os/seastore/root_meta.h
new file mode 100644
index 00000000000..edf082f1e38
--- /dev/null
+++ b/src/crimson/os/seastore/root_meta.h
@@ -0,0 +1,76 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include "crimson/os/seastore/cached_extent.h"
+
+namespace crimson::os::seastore {
+
+struct RootMetaBlock : LogicalCachedExtent {
+ using meta_t = std::map<std::string, std::string>;
+ using Ref = TCachedExtentRef<RootMetaBlock>;
+ static constexpr size_t SIZE = 4096;
+ static constexpr int MAX_META_LENGTH = 1024;
+
+ explicit RootMetaBlock(ceph::bufferptr &&ptr)
+ : LogicalCachedExtent(std::move(ptr)) {}
+ explicit RootMetaBlock(extent_len_t length)
+ : LogicalCachedExtent(length) {}
+ RootMetaBlock(const RootMetaBlock &rhs)
+ : LogicalCachedExtent(rhs) {}
+
+ CachedExtentRef duplicate_for_write(Transaction&) final {
+ return CachedExtentRef(new RootMetaBlock(*this));
+ }
+
+ static constexpr extent_types_t TYPE = extent_types_t::ROOT_META;
+ extent_types_t get_type() const final {
+ return extent_types_t::ROOT_META;
+ }
+
+ /// dumps root meta as delta
+ ceph::bufferlist get_delta() final {
+ ceph::bufferlist bl;
+ ceph::buffer::ptr bptr(get_bptr(), 0, MAX_META_LENGTH);
+ bl.append(bptr);
+ return bl;
+ }
+
+ /// overwrites root
+ void apply_delta(const ceph::bufferlist &_bl) final
+ {
+ assert(_bl.length() == MAX_META_LENGTH);
+ ceph::bufferlist bl = _bl;
+ bl.rebuild();
+ get_bptr().copy_in(0, MAX_META_LENGTH, bl.front().c_str());
+ }
+
+ meta_t get_meta() const {
+ bufferlist bl;
+ bl.append(get_bptr());
+ meta_t ret;
+ auto iter = bl.cbegin();
+ decode(ret, iter);
+ return ret;
+ }
+
+ void set_meta(const meta_t &m) {
+ ceph::bufferlist bl;
+ encode(m, bl);
+ ceph_assert(bl.length() <= MAX_META_LENGTH);
+ bl.rebuild();
+ get_bptr().zero(0, MAX_META_LENGTH);
+ get_bptr().copy_in(0, bl.length(), bl.front().c_str());
+ }
+
+};
+using RootMetaBlockRef = RootMetaBlock::Ref;
+
+} // crimson::os::seastore
+
+
+#if FMT_VERSION >= 90000
+template <> struct fmt::formatter<crimson::os::seastore::RootMetaBlock>
+ : fmt::ostream_formatter {};
+#endif
diff --git a/src/crimson/os/seastore/seastore_types.cc b/src/crimson/os/seastore/seastore_types.cc
index f379dd0117c..450118e5e75 100644
--- a/src/crimson/os/seastore/seastore_types.cc
+++ b/src/crimson/os/seastore/seastore_types.cc
@@ -246,6 +246,8 @@ std::ostream &operator<<(std::ostream &out, extent_types_t t)
return out << "LADDR_LEAF";
case extent_types_t::ONODE_BLOCK_STAGED:
return out << "ONODE_BLOCK_STAGED";
+ case extent_types_t::ROOT_META:
+ return out << "ROOT_META";
case extent_types_t::OMAP_INNER:
return out << "OMAP_INNER";
case extent_types_t::OMAP_LEAF:
diff --git a/src/crimson/os/seastore/seastore_types.h b/src/crimson/os/seastore/seastore_types.h
index df5c184e7ab..65cad878fba 100644
--- a/src/crimson/os/seastore/seastore_types.h
+++ b/src/crimson/os/seastore/seastore_types.h
@@ -1378,23 +1378,24 @@ enum class extent_types_t : uint8_t {
LADDR_INTERNAL = 1,
LADDR_LEAF = 2,
DINK_LADDR_LEAF = 3, // should only be used for unitttests
- OMAP_INNER = 4,
- OMAP_LEAF = 5,
- ONODE_BLOCK_STAGED = 6,
- COLL_BLOCK = 7,
- OBJECT_DATA_BLOCK = 8,
- RETIRED_PLACEHOLDER = 9,
+ ROOT_META = 4,
+ OMAP_INNER = 5,
+ OMAP_LEAF = 6,
+ ONODE_BLOCK_STAGED = 7,
+ COLL_BLOCK = 8,
+ OBJECT_DATA_BLOCK = 9,
+ RETIRED_PLACEHOLDER = 10,
// the following two types are not extent types,
// they are just used to indicates paddr allocation deltas
- ALLOC_INFO = 10,
- JOURNAL_TAIL = 11,
+ ALLOC_INFO = 11,
+ JOURNAL_TAIL = 12,
// Test Block Types
- TEST_BLOCK = 12,
- TEST_BLOCK_PHYSICAL = 13,
- BACKREF_INTERNAL = 14,
- BACKREF_LEAF = 15,
+ TEST_BLOCK = 13,
+ TEST_BLOCK_PHYSICAL = 14,
+ BACKREF_INTERNAL = 15,
+ BACKREF_LEAF = 16,
// None and the number of valid extent_types_t
- NONE = 16,
+ NONE = 17,
};
using extent_types_le_t = uint8_t;
constexpr auto EXTENT_TYPES_MAX = static_cast<uint8_t>(extent_types_t::NONE);
@@ -1409,12 +1410,12 @@ constexpr bool is_data_type(extent_types_t type) {
}
constexpr bool is_logical_metadata_type(extent_types_t type) {
- return type >= extent_types_t::OMAP_INNER &&
+ return type >= extent_types_t::ROOT_META &&
type <= extent_types_t::COLL_BLOCK;
}
constexpr bool is_logical_type(extent_types_t type) {
- if ((type >= extent_types_t::OMAP_INNER &&
+ if ((type >= extent_types_t::ROOT_META &&
type <= extent_types_t::OBJECT_DATA_BLOCK) ||
type == extent_types_t::TEST_BLOCK) {
assert(is_logical_metadata_type(type) ||
@@ -1926,44 +1927,18 @@ using backref_root_t = phy_tree_root_t;
* TODO: generalize this to permit more than one lba_manager implementation
*/
struct __attribute__((packed)) root_t {
- using meta_t = std::map<std::string, std::string>;
-
- static constexpr int MAX_META_LENGTH = 1024;
-
backref_root_t backref_root;
lba_root_t lba_root;
laddr_le_t onode_root;
coll_root_le_t collection_root;
+ laddr_le_t meta;
- char meta[MAX_META_LENGTH];
-
- root_t() {
- set_meta(meta_t{});
- }
+ root_t() = default;
void adjust_addrs_from_base(paddr_t base) {
lba_root.adjust_addrs_from_base(base);
backref_root.adjust_addrs_from_base(base);
}
-
- meta_t get_meta() {
- bufferlist bl;
- bl.append(ceph::buffer::create_static(MAX_META_LENGTH, meta));
- meta_t ret;
- auto iter = bl.cbegin();
- decode(ret, iter);
- return ret;
- }
-
- void set_meta(const meta_t &m) {
- ceph::bufferlist bl;
- encode(m, bl);
- ceph_assert(bl.length() < MAX_META_LENGTH);
- bl.rebuild();
- auto &bptr = bl.front();
- ::memset(meta, 0, MAX_META_LENGTH);
- ::memcpy(meta, bptr.c_str(), bl.length());
- }
};
struct alloc_blk_t {
diff --git a/src/crimson/os/seastore/transaction_manager.cc b/src/crimson/os/seastore/transaction_manager.cc
index f4e3b0858f2..717c3822db9 100644
--- a/src/crimson/os/seastore/transaction_manager.cc
+++ b/src/crimson/os/seastore/transaction_manager.cc
@@ -74,6 +74,8 @@ TransactionManager::mkfs_ertr::future<> TransactionManager::mkfs()
return lba_manager->mkfs(t);
}).si_then([this, &t] {
return backref_manager->mkfs(t);
+ }).si_then([this, &t] {
+ return init_root_meta(t);
}).si_then([this, FNAME, &t] {
INFOT("submitting mkfs transaction", t);
return submit_transaction_direct(t);
diff --git a/src/crimson/os/seastore/transaction_manager.h b/src/crimson/os/seastore/transaction_manager.h
index c7a94a9ef11..841c5638abc 100644
--- a/src/crimson/os/seastore/transaction_manager.h
+++ b/src/crimson/os/seastore/transaction_manager.h
@@ -23,6 +23,7 @@
#include "crimson/os/seastore/logging.h"
#include "crimson/os/seastore/seastore_types.h"
#include "crimson/os/seastore/cache.h"
+#include "crimson/os/seastore/root_meta.h"
#include "crimson/os/seastore/lba_manager.h"
#include "crimson/os/seastore/backref_manager.h"
#include "crimson/os/seastore/journal.h"
@@ -303,10 +304,6 @@ public:
len,
placement_hint,
INIT_GENERATION);
- if (!ext) {
- SUBERRORT(seastore_tm, "insufficient space!", t);
- return crimson::ct_error::enospc::make();
- }
return lba_manager->alloc_extent(
t,
laddr_hint,
@@ -342,10 +339,6 @@ public:
len,
placement_hint,
INIT_GENERATION);
- if (exts.empty()) {
- SUBERRORT(seastore_tm, "insufficient space!", t);
- return crimson::ct_error::enospc::make();
- }
return lba_manager->alloc_extents(
t,
laddr_hint,
@@ -690,9 +683,11 @@ public:
const std::string &key) {
return cache->get_root(
t
- ).si_then([&key, &t](auto root) {
+ ).si_then([&t, this](auto root) {
+ return read_extent<RootMetaBlock>(t, root->root.meta);
+ }).si_then([key, &t](auto mblock) {
LOG_PREFIX(TransactionManager::read_root_meta);
- auto meta = root->root.get_meta();
+ auto meta = mblock->get_meta();
auto iter = meta.find(key);
if (iter == meta.end()) {
SUBDEBUGT(seastore_tm, "{} -> nullopt", t, key);
@@ -701,7 +696,35 @@ public:
SUBDEBUGT(seastore_tm, "{} -> {}", t, key, iter->second);
return seastar::make_ready_future<read_root_meta_bare>(iter->second);
}
- });
+ }).handle_error_interruptible(
+ crimson::ct_error::input_output_error::pass_further{},
+ crimson::ct_error::assert_all{"unexpected error!"}
+ );
+ }
+
+ /**
+ * init_root_meta
+ *
+ * create the root meta block
+ */
+ using init_root_meta_iertr = base_iertr;
+ using init_root_meta_ret = init_root_meta_iertr::future<>;
+ init_root_meta_ret init_root_meta(Transaction &t) {
+ return alloc_non_data_extent<RootMetaBlock>(
+ t, L_ADDR_MIN, RootMetaBlock::SIZE
+ ).si_then([this, &t](auto meta) {
+ meta->set_meta(RootMetaBlock::meta_t{});
+ return cache->get_root(t
+ ).si_then([this, &t, meta](auto root) {
+ auto mroot = cache->duplicate_for_write(
+ t, root)->template cast<RootBlock>();
+ mroot->root.meta = meta->get_laddr();
+ return seastar::now();
+ });
+ }).handle_error_interruptible(
+ crimson::ct_error::input_output_error::pass_further{},
+ crimson::ct_error::assert_all{"unexpected error!"}
+ );
}
/**
@@ -719,15 +742,21 @@ public:
SUBDEBUGT(seastore_tm, "seastore_tm, {} -> {} ...", t, key, value);
return cache->get_root(
t
- ).si_then([this, &t, &key, &value](RootBlockRef root) {
- root = cache->duplicate_for_write(t, root)->cast<RootBlock>();
+ ).si_then([this, &t](RootBlockRef root) {
+ return read_extent<RootMetaBlock>(t, root->root.meta);
+ }).si_then([this, key, value, &t](auto mblock) {
+ mblock = get_mutable_extent(t, mblock
+ )->template cast<RootMetaBlock>();
- auto meta = root->root.get_meta();
+ auto meta = mblock->get_meta();
meta[key] = value;
- root->root.set_meta(meta);
+ mblock->set_meta(meta);
return seastar::now();
- });
+ }).handle_error_interruptible(
+ crimson::ct_error::input_output_error::pass_further{},
+ crimson::ct_error::assert_all{"unexpected error!"}
+ );
}
/**
diff --git a/src/test/crimson/seastore/test_object_data_handler.cc b/src/test/crimson/seastore/test_object_data_handler.cc
index e7aabf2c8af..5dbc3748e5b 100644
--- a/src/test/crimson/seastore/test_object_data_handler.cc
+++ b/src/test/crimson/seastore/test_object_data_handler.cc
@@ -218,14 +218,20 @@ 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::from_byte_offset(offset), length);
+ auto &layout = onode->get_layout();
+ auto odata = layout.object_data.get();
+ auto obase = odata.get_reserved_data_base();
+ return tm->get_pins(t, (obase + offset).checked_to_laddr(), 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::from_byte_offset(offset), length);
+ auto &layout = onode->get_layout();
+ auto odata = layout.object_data.get();
+ auto obase = odata.get_reserved_data_base();
+ return tm->get_pins(t, (obase + offset).checked_to_laddr(), length);
}).unsafe_get();
return ret;
}
@@ -253,12 +259,16 @@ struct object_data_handler_test_t:
ObjectDataBlockRef get_extent(
Transaction &t,
- laddr_t addr,
+ loffset_t addr,
extent_len_t len) {
+ auto &layout = onode->get_layout();
+ auto odata = layout.object_data.get();
+ auto obase = odata.get_reserved_data_base();
auto ext = with_trans_intr(t, [&](auto& trans) {
- return tm->read_extent<ObjectDataBlock>(trans, addr, len);
- }).unsafe_get();
- EXPECT_EQ(addr, ext->get_laddr());
+ return tm->read_extent<ObjectDataBlock>(
+ trans, (obase + addr).checked_to_laddr(), len);
+ }).unsafe_get();
+ EXPECT_EQ((obase + addr).checked_to_laddr(), ext->get_laddr());
return ext;
}
@@ -798,7 +808,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::from_byte_offset(base + 4096), 4096 * 2);
+ auto ext = get_extent(*t, 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 6ad111dca5b..2d20c5fff94 100644
--- a/src/test/crimson/seastore/test_transaction_manager.cc
+++ b/src/test/crimson/seastore/test_transaction_manager.cc
@@ -26,6 +26,10 @@ namespace {
}
}
+laddr_t get_laddr_hint(uint64_t offset) {
+ return laddr_t::from_byte_offset(RootMetaBlock::SIZE + offset);
+}
+
struct test_extent_record_t {
test_extent_desc_t desc;
unsigned refcount = 0;
@@ -67,8 +71,9 @@ struct transaction_manager_test_t :
}
laddr_t get_random_laddr(size_t block_size, size_t limit) {
- return laddr_t::from_byte_offset(block_size *
- std::uniform_int_distribution<>(0, (limit / block_size) - 1)(gen));
+ auto offset = block_size *
+ std::uniform_int_distribution<>(0, (limit / block_size) - 1)(gen);
+ return get_laddr_hint(offset);
}
char get_random_contents() {
@@ -719,7 +724,7 @@ struct transaction_manager_test_t :
[this, &overlay](auto &t) {
return lba_manager->scan_mappings(
t,
- L_ADDR_MIN,
+ get_laddr_hint(0),
L_ADDR_MAX,
[iter=overlay.begin(), &overlay](auto l, auto p, auto len) mutable {
EXPECT_NE(iter, overlay.end());
@@ -830,9 +835,9 @@ struct transaction_manager_test_t :
auto t = create_transaction();
auto extent = alloc_extent(
t,
- laddr_t::from_byte_offset(i * BSIZE),
+ get_laddr_hint(i * BSIZE),
BSIZE);
- ASSERT_EQ(laddr_t::from_byte_offset(i * BSIZE), extent->get_laddr());
+ ASSERT_EQ(get_laddr_hint(i * BSIZE), extent->get_laddr());
submit_transaction(std::move(t));
}
@@ -844,7 +849,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::from_byte_offset(i * BSIZE), BSIZE
+ return tm->read_extent<TestBlock>(t, get_laddr_hint(i * BSIZE), BSIZE
).si_then([](auto) {
return seastar::now();
});
@@ -870,9 +875,9 @@ struct transaction_manager_test_t :
auto t = create_transaction();
auto extent = alloc_extent(
t,
- laddr_t::from_byte_offset(i * BSIZE),
+ get_laddr_hint(i * BSIZE),
BSIZE);
- ASSERT_EQ(laddr_t::from_byte_offset(i * BSIZE), extent->get_laddr());
+ ASSERT_EQ(get_laddr_hint(i * BSIZE), extent->get_laddr());
if (try_submit_transaction(std::move(t)))
break;
}
@@ -973,6 +978,7 @@ struct transaction_manager_test_t :
extent_types_t::ROOT,
extent_types_t::LADDR_INTERNAL,
extent_types_t::LADDR_LEAF,
+ extent_types_t::ROOT_META,
extent_types_t::OMAP_INNER,
extent_types_t::OMAP_LEAF,
extent_types_t::ONODE_BLOCK_STAGED,
@@ -1346,9 +1352,9 @@ struct transaction_manager_test_t :
void test_remap_pin() {
run_async([this] {
disable_max_extent_size();
- laddr_t l_offset = laddr_t::from_byte_offset(32 << 10);
+ laddr_t l_offset = get_laddr_hint(32 << 10);
size_t l_len = 32 << 10;
- laddr_t r_offset = laddr_t::from_byte_offset(64 << 10);
+ laddr_t r_offset = get_laddr_hint(64 << 10);
size_t r_len = 32 << 10;
{
auto t = create_transaction();
@@ -1400,12 +1406,12 @@ struct transaction_manager_test_t :
void test_clone_and_remap_pin() {
run_async([this] {
disable_max_extent_size();
- laddr_t l_offset = laddr_t::from_byte_offset(32 << 10);
+ laddr_t l_offset = get_laddr_hint(32 << 10);
size_t l_len = 32 << 10;
- laddr_t r_offset = laddr_t::from_byte_offset(64 << 10);
+ laddr_t r_offset = get_laddr_hint(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);
+ laddr_t l_clone_offset = get_laddr_hint(96 << 10);
+ laddr_t r_clone_offset = get_laddr_hint(128 << 10);
{
auto t = create_transaction();
auto lext = alloc_extent(t, l_offset, l_len);
@@ -1455,11 +1461,11 @@ struct transaction_manager_test_t :
void test_overwrite_pin() {
run_async([this] {
disable_max_extent_size();
- laddr_t m_offset = laddr_t::from_byte_offset(8 << 10);
+ laddr_t m_offset = get_laddr_hint(8 << 10);
size_t m_len = 56 << 10;
- laddr_t l_offset = laddr_t::from_byte_offset(64 << 10);
+ laddr_t l_offset = get_laddr_hint(64 << 10);
size_t l_len = 64 << 10;
- laddr_t r_offset = laddr_t::from_byte_offset(128 << 10);
+ laddr_t r_offset = get_laddr_hint(128 << 10);
size_t r_len = 64 << 10;
{
auto t = create_transaction();
@@ -1538,7 +1544,7 @@ struct transaction_manager_test_t :
run_async([this] {
disable_max_extent_size();
constexpr unsigned REMAP_NUM = 32;
- constexpr laddr_t offset = L_ADDR_MIN;
+ laddr_t offset = get_laddr_hint(0);
constexpr size_t length = 256 << 10;
{
auto t = create_transaction();
@@ -1575,7 +1581,7 @@ struct transaction_manager_test_t :
if (off == 0 || off >= 255) {
continue;
}
- auto new_off = laddr_t::from_byte_offset(off << 10)
+ auto new_off = get_laddr_hint(off << 10)
.get_byte_distance<extent_len_t>(last_pin->get_key());
auto new_len = last_pin->get_length() - new_off;
//always remap right extent at new split_point
@@ -1621,7 +1627,7 @@ struct transaction_manager_test_t :
run_async([this] {
disable_max_extent_size();
constexpr unsigned REMAP_NUM = 32;
- constexpr laddr_t offset = L_ADDR_MIN;
+ laddr_t offset = get_laddr_hint(0);
constexpr size_t length = 256 << 10;
{
auto t = create_transaction();
@@ -1661,12 +1667,12 @@ struct transaction_manager_test_t :
ASSERT_TRUE(!split_points.empty());
while(!split_points.empty()) {
// new overwrite area: start_off ~ end_off
- auto start_off = split_points.front();
+ auto start_off = split_points.front() + 4 /*RootMetaBlock*/;
split_points.pop_front();
- auto end_off = split_points.front();
+ auto end_off = split_points.front() + 4 /*RootMetaBlock*/;
split_points.pop_front();
ASSERT_TRUE(start_off <= end_off);
- if ((laddr_t::from_byte_offset(end_off << 10) == pin0->get_key() + pin0->get_length())
+ if ((get_laddr_hint(end_off << 10) == pin0->get_key() + pin0->get_length())
|| (start_off == end_off)) {
if (split_points.empty() && empty_transaction) {
early_exit++;
@@ -1675,7 +1681,7 @@ struct transaction_manager_test_t :
continue;
}
empty_transaction = false;
- auto new_off = laddr_t::from_byte_offset(start_off << 10)
+ auto new_off = get_laddr_hint(start_off << 10)
.get_byte_distance<extent_len_t>(last_rpin->get_key());
auto new_len = (end_off - start_off) << 10;
bufferlist bl;
@@ -1768,7 +1774,7 @@ struct tm_random_block_device_test_t :
TEST_P(tm_random_block_device_test_t, scatter_allocation)
{
run_async([this] {
- laddr_t ADDR = laddr_t::from_byte_offset(0xFF * 4096);
+ laddr_t ADDR = get_laddr_hint(0xFF * 4096);
epm->prefill_fragmented_devices();
auto t = create_transaction();
for (int i = 0; i < 1991; i++) {
@@ -1786,7 +1792,7 @@ TEST_P(tm_single_device_test_t, basic)
{
constexpr size_t SIZE = 4096;
run_async([this] {
- laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE);
+ laddr_t ADDR = get_laddr_hint(0xFF * SIZE);
{
auto t = create_transaction();
auto extent = alloc_extent(
@@ -1807,7 +1813,7 @@ TEST_P(tm_single_device_test_t, mutate)
{
constexpr size_t SIZE = 4096;
run_async([this] {
- laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE);
+ laddr_t ADDR = get_laddr_hint(0xFF * SIZE);
{
auto t = create_transaction();
auto extent = alloc_extent(
@@ -1845,8 +1851,8 @@ TEST_P(tm_single_device_test_t, allocate_lba_conflict)
{
constexpr size_t SIZE = 4096;
run_async([this] {
- laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE);
- laddr_t ADDR2 = laddr_t::from_byte_offset(0xFE * SIZE);
+ laddr_t ADDR = get_laddr_hint(0xFF * SIZE);
+ laddr_t ADDR2 = get_laddr_hint(0xFE * SIZE);
auto t = create_transaction();
auto t2 = create_transaction();
@@ -1883,7 +1889,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::from_byte_offset(i * SIZE),
+ get_laddr_hint(i * SIZE),
SIZE);
}
check_mappings(t);
@@ -1891,7 +1897,7 @@ TEST_P(tm_single_device_test_t, mutate_lba_conflict)
check();
}
- laddr_t ADDR = laddr_t::from_byte_offset(150 * SIZE);
+ laddr_t ADDR = get_laddr_hint(150 * SIZE);
{
auto t = create_transaction();
auto t2 = create_transaction();
@@ -1917,15 +1923,15 @@ TEST_P(tm_single_device_test_t, concurrent_mutate_lba_no_conflict)
{
constexpr size_t SIZE = 4096;
constexpr size_t NUM = 500;
- laddr_t addr = L_ADDR_MIN;
- laddr_t addr2 = laddr_t::from_byte_offset(SIZE * (NUM - 1));
+ laddr_t addr = get_laddr_hint(0);
+ laddr_t addr2 = get_laddr_hint(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::from_byte_offset(i * SIZE),
+ get_laddr_hint(i * SIZE),
SIZE);
}
submit_transaction(std::move(t));
@@ -1949,7 +1955,7 @@ TEST_P(tm_single_device_test_t, create_remove_same_transaction)
{
constexpr size_t SIZE = 4096;
run_async([this] {
- laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE);
+ laddr_t ADDR = get_laddr_hint(0xFF * SIZE);
{
auto t = create_transaction();
auto extent = alloc_extent(
@@ -1985,7 +1991,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::from_byte_offset(i * SIZE),
+ get_laddr_hint(i * SIZE),
SIZE);
}
check_mappings(t);
@@ -1997,7 +2003,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::from_byte_offset(i * SIZE));
+ get_laddr_hint(i * SIZE));
}
check_mappings(t);
submit_transaction(std::move(t));
@@ -2010,7 +2016,7 @@ TEST_P(tm_single_device_test_t, inc_dec_ref)
{
constexpr size_t SIZE = 4096;
run_async([this] {
- laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE);
+ laddr_t ADDR = get_laddr_hint(0xFF * SIZE);
{
auto t = create_transaction();
auto extent = alloc_extent(
@@ -2061,10 +2067,10 @@ TEST_P(tm_single_device_test_t, cause_lba_split)
auto t = create_transaction();
auto extent = alloc_extent(
t,
- laddr_t::from_byte_offset(i * SIZE),
+ get_laddr_hint(i * SIZE),
SIZE,
(char)(i & 0xFF));
- ASSERT_EQ(laddr_t::from_byte_offset(i * SIZE), extent->get_laddr());
+ ASSERT_EQ(get_laddr_hint(i * SIZE), extent->get_laddr());
submit_transaction(std::move(t));
}
check();
@@ -2082,9 +2088,9 @@ TEST_P(tm_single_device_test_t, random_writes)
auto t = create_transaction();
auto extent = alloc_extent(
t,
- laddr_t::from_byte_offset(i * BSIZE),
+ get_laddr_hint(i * BSIZE),
BSIZE);
- ASSERT_EQ(laddr_t::from_byte_offset(i * BSIZE), extent->get_laddr());
+ ASSERT_EQ(get_laddr_hint(i * BSIZE), extent->get_laddr());
submit_transaction(std::move(t));
}
@@ -2100,7 +2106,7 @@ TEST_P(tm_single_device_test_t, random_writes)
// pad out transaction
auto paddings = alloc_extents(
t,
- laddr_t::from_byte_offset(TOTAL + (k * PADDING_SIZE)),
+ get_laddr_hint(TOTAL + (k * PADDING_SIZE)),
PADDING_SIZE);
for (auto &padding : paddings) {
dec_ref(t, padding->get_laddr());
@@ -2133,7 +2139,7 @@ TEST_P(tm_single_device_test_t, find_hole_assert_trigger)
TEST_P(tm_single_device_intergrity_check_test_t, remap_lazy_read)
{
- constexpr laddr_t offset = L_ADDR_MIN;
+ laddr_t offset = get_laddr_hint(0);
constexpr size_t length = 256 << 10;
run_async([this, offset] {
disable_max_extent_size();
@@ -2186,7 +2192,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::from_byte_offset(i * 4096),
+ get_laddr_hint(i * 4096),
4096,
'a');
}
@@ -2195,12 +2201,12 @@ TEST_P(tm_single_device_test_t, invalid_lba_mapping_detect)
{
auto t = create_transaction();
- auto pin = get_pin(t, laddr_t::from_byte_offset((LEAF_NODE_CAPACITY - 1) * 4096));
+ auto pin = get_pin(t, get_laddr_hint((LEAF_NODE_CAPACITY - 1) * 4096));
assert(pin->is_parent_viewable());
- auto extent = alloc_extent(t, laddr_t::from_byte_offset(LEAF_NODE_CAPACITY * 4096), 4096, 'a');
+ auto extent = alloc_extent(t, get_laddr_hint(LEAF_NODE_CAPACITY * 4096), 4096, 'a');
assert(!pin->is_parent_viewable());
- 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');
+ pin = get_pin(t, get_laddr_hint(LEAF_NODE_CAPACITY * 4096));
+ std::ignore = alloc_extent(t, get_laddr_hint((LEAF_NODE_CAPACITY + 1) * 4096), 4096, 'a');
assert(pin->is_parent_viewable());
assert(pin->parent_modified());
pin->maybe_fix_pos();