BlockRBManager::open_ertr::future<> BlockRBManager::open()
{
assert(device);
- return device->read_rbm_header(RBM_START_ADDRESS
- ).safe_then([this](auto s)
- -> open_ertr::future<> {
- auto ool_start = get_start_rbm_addr();
- allocator->init(
- ool_start,
- device->get_available_size() -
- ool_start,
- device->get_block_size());
- return open_ertr::now();
- }).handle_error(
- open_ertr::pass_further{},
- crimson::ct_error::assert_all{
- "Invalid error read_rbm_header in BlockRBManager::open"
- }
- );
+ assert(device->get_available_size() > 0);
+ assert(device->get_block_size() > 0);
+ auto ool_start = get_start_rbm_addr();
+ allocator->init(
+ ool_start,
+ device->get_available_size() -
+ ool_start,
+ device->get_block_size());
+ return open_ertr::now();
}
BlockRBManager::write_ertr::future<> BlockRBManager::write(
rbm_abs_addr addr)
{
LOG_PREFIX(RBMDevice::read_rbm_header);
+ assert(super.block_size > 0);
return seastar::do_with(
bufferptr(ceph::buffer::create_page_aligned(super.block_size)),
[this, addr, FNAME](auto &bptr) {
logger().debug(" mount ");
return open(device_path, seastar::open_flags::rw | seastar::open_flags::dsync
).safe_then([this] {
- return read_rbm_header(RBM_START_ADDRESS
- ).safe_then([](auto s) {
- return seastar::now();
+ return stat_device(
+ ).handle_error(
+ mount_ertr::pass_further{},
+ crimson::ct_error::assert_all{
+ "Invalid error stat_device in RBMDevice::mount"}
+ ).safe_then([this](auto st) {
+ super.block_size = st.block_size;
+ return read_rbm_header(RBM_START_ADDRESS
+ ).safe_then([](auto s) {
+ return seastar::now();
+ });
});
}).handle_error(
mount_ertr::pass_further{},
mount_ret mount() final {
return open("", seastar::open_flags::rw
- ).safe_then([]() {
- return mount_ertr::now();
+ ).safe_then([this]() {
+ super.block_size = TEST_BLOCK_SIZE;
+ return read_rbm_header(RBM_START_ADDRESS
+ ).safe_then([](auto s) {
+ return seastar::now();
+ });
}).handle_error(
mount_ertr::pass_further{},
crimson::ct_error::assert_all{
}
auto mkfs() {
- return device->mount(
+ device_config_t config = get_rbm_ephemeral_device_config(0, 1);
+ return device->mkfs(config
).safe_then([this]() {
- device_config_t config = get_rbm_ephemeral_device_config(0, 1);
- return device->mkfs(config
+ return device->mount(
).safe_then([this]() {
return cbj->open_for_mkfs(
).safe_then([](auto q) {
seastar::future<> set_up_fut() final {
device = random_block_device::create_test_ephemeral(
- 0, DEFAULT_TEST_SIZE);
+ random_block_device::DEFAULT_TEST_CBJOURNAL_SIZE, DEFAULT_TEST_SIZE);
block_size = device->get_block_size();
size = device->get_available_size();
rbm_manager.reset(new BlockRBManager(device.get(), std::string(), false));
config = get_rbm_ephemeral_device_config(0, 1);
- return device->mount().handle_error(crimson::ct_error::assert_all{}
+ return device->mkfs(config).handle_error(crimson::ct_error::assert_all{}
).then([this] {
- return device->mkfs(config).handle_error(crimson::ct_error::assert_all{}
+ return device->mount().handle_error(crimson::ct_error::assert_all{}
).then([this] {
return rbm_manager->open().handle_error(crimson::ct_error::assert_all{});
});
seastar::future<> setup() final {
rb_device = random_block_device::create_test_ephemeral();
- return rb_device->mount().handle_error(crimson::ct_error::assert_all{}
- ).then([this]() {
- device_config_t config = get_rbm_ephemeral_device_config(0, 1);
- return rb_device->mkfs(config).handle_error(crimson::ct_error::assert_all{});
- });
+ device_config_t config = get_rbm_ephemeral_device_config(0, 1);
+ return rb_device->mkfs(config).handle_error(crimson::ct_error::assert_all{});
}
void remount() final {}