auto ret = i->duplicate_for_write();
if (ret->get_type() == extent_types_t::ROOT) {
+ // root must be loaded before mutate
+ assert(t.root == i);
t.root = ret->cast<RootBlock>();
} else {
ret->last_committed_crc = i->last_committed_crc;
Cache::mkfs_ertr::future<> Cache::mkfs(Transaction &t)
{
- duplicate_for_write(t, root);
- return mkfs_ertr::now();
+ return get_root(t).safe_then([this, &t](auto croot) {
+ duplicate_for_write(t, croot);
+ return mkfs_ertr::now();
+ });
}
Cache::close_ertr::future<> Cache::close()
t.root);
} else {
auto ret = root;
- return ret->wait_io().then([ret] {
+ return ret->wait_io().then([ret, &t] {
+ t.root = ret;
return get_root_ret(
get_root_ertr::ready_future_marker{},
ret);