namespace crimson::os::seastore {
-/**
- * coll_root_t
- *
- * Information for locating CollectionManager information, addr should be
- * embedded into the TransactionManager root.
- */
- class coll_root_t {
- laddr_t coll_root_laddr;
- segment_off_t size = 0;
-
- enum state_t : uint8_t {
- CLEAN = 0, /// No pending mutations
- MUTATED = 1, /// coll_root_laddr state must be written back to persistence
- NONE = 0xFF /// Not yet mounted, should not be exposed to user
- } state = NONE;
-
- public:
- coll_root_t() : state(state_t::NONE) {}
-
- coll_root_t(laddr_t laddr, size_t size)
- : coll_root_laddr(laddr), size(size), state(state_t::CLEAN) {}
-
- bool must_update() const {
- return state == MUTATED;
- }
-
- void update(laddr_t addr, segment_off_t s) {
- state = state_t::MUTATED;
- coll_root_laddr = addr;
- size = s;
- }
-
- laddr_t get_location() const {
- return coll_root_laddr;
- }
- auto get_size() const {
- return size;
- }
- };
-
- struct coll_info_t {
- unsigned split_bits;
-
- coll_info_t(unsigned bits)
+struct coll_info_t {
+ unsigned split_bits;
+
+ coll_info_t(unsigned bits)
: split_bits(bits) {}
-
- bool operator==(const coll_info_t &rhs) const {
- return split_bits == rhs.split_bits;
- }
- };
+
+ bool operator==(const coll_info_t &rhs) const {
+ return split_bits == rhs.split_bits;
+ }
+};
/// Interface for maintaining set of collections
class CollectionManager {
paddr_t segment_root;
laddr_t onode_root = L_ADDR_NULL;
laddr_t collection_root = L_ADDR_NULL;
+ segment_off_t collection_root_size = 0;
void adjust_addrs_from_base(paddr_t base) {
if (lba_root_addr.is_relative()) {
std::vector<delta_info_t> deltas;
};
+/**
+ * coll_root_t
+ *
+ * Information for locating CollectionManager information, addr should be
+ * embedded into the TransactionManager root.
+ */
+class coll_root_t {
+ laddr_t coll_root_laddr;
+ segment_off_t size = 0;
+
+ enum state_t : uint8_t {
+ CLEAN = 0, /// No pending mutations
+ MUTATED = 1, /// coll_root_laddr state must be written back to persistence
+ NONE = 0xFF /// Not yet mounted, should not be exposed to user
+ } state = NONE;
+
+public:
+ coll_root_t() : state(state_t::NONE) {}
+
+ coll_root_t(laddr_t laddr, segment_off_t size)
+ : coll_root_laddr(laddr), size(size), state(state_t::CLEAN) {}
+
+ bool must_update() const {
+ return state == MUTATED;
+ }
+
+ void update(laddr_t addr, segment_off_t s) {
+ state = state_t::MUTATED;
+ coll_root_laddr = addr;
+ size = s;
+ }
+
+ laddr_t get_location() const {
+ return coll_root_laddr;
+ }
+ auto get_size() const {
+ return size;
+ }
+};
+
}
WRITE_CLASS_DENC_BOUNDED(crimson::os::seastore::seastore_meta_t)
* Get collection root addr
*/
using read_collection_root_ertr = base_ertr;
- using read_collection_root_ret = read_collection_root_ertr::future<laddr_t>;
+ using read_collection_root_ret = read_collection_root_ertr::future<
+ coll_root_t>;
read_collection_root_ret read_collection_root(Transaction &t) {
- return cache.get_root(t).safe_then([](auto croot) {
- return croot->get_root().collection_root;
+ return cache->get_root(t).safe_then([](auto croot) {
+ return coll_root_t{
+ croot->get_root().collection_root,
+ croot->get_root().collection_root_size
+ };
});
}
*
* Update collection root addr
*/
- void write_collection_root(Transaction &t, laddr_t addr) {
- auto croot = cache.get_root_fast(t);
- croot = cache.duplicate_for_write(t, croot)->cast<RootBlock>();
- croot->get_root().collection_root = addr;
+ void write_collection_root(Transaction &t, coll_root_t cmroot) {
+ auto croot = cache->get_root_fast(t);
+ croot = cache->duplicate_for_write(t, croot)->cast<RootBlock>();
+ croot->get_root().collection_root = cmroot.get_location();
+ croot->get_root().collection_root_size = cmroot.get_size();
}
~TransactionManager();