crimson::ct_error::input_output_error,
crimson::ct_error::invarg,
crimson::ct_error::enoent>;
- virtual open_ertr::future<> open(const std::string &path, paddr_t start) = 0;
+ virtual open_ertr::future<> open() = 0;
using close_ertr = crimson::errorator<
crimson::ct_error::input_output_error,
{
LOG_PREFIX(BlockRBManager::mkfs);
DEBUG("path {}", path);
- return _open_device(path).safe_then([this, &config, FNAME]() {
+ return _open_device(path).safe_then([this, config, FNAME]() {
rbm_abs_addr addr = convert_paddr_to_abs_addr(
config.start);
return read_rbm_header(addr).safe_then([FNAME](auto super) {
DEBUG("already exists ");
return mkfs_ertr::now();
}).handle_error(
- crimson::ct_error::enoent::handle([this, &config, FNAME](auto) {
+ crimson::ct_error::enoent::handle([this, config, FNAME](auto) {
super.uuid = uuid_d(); // TODO
super.magic = 0xFF; // TODO
super.start = convert_paddr_to_abs_addr(
});
}
-BlockRBManager::open_ertr::future<> BlockRBManager::open(
- const std::string &path, paddr_t paddr)
+BlockRBManager::open_ertr::future<> BlockRBManager::open()
{
- LOG_PREFIX(BlockRBManager::open);
- DEBUG("open: path{}", path);
- rbm_abs_addr addr = convert_paddr_to_abs_addr(paddr);
- return _open_device(path
- ).safe_then([this, addr]() {
- return read_rbm_header(addr).safe_then([&](auto s)
- -> open_ertr::future<> {
- if (s.magic != 0xFF) {
- return crimson::ct_error::enoent::make();
- }
- super = s;
- return check_bitmap_blocks().safe_then([]() {
- return open_ertr::now();
- });
- }).handle_error(
- open_ertr::pass_further{},
- crimson::ct_error::assert_all{
- "Invalid error read_rbm_header in BlockRBManager::open"
- }
- );
- });
+ return read_rbm_header(RBM_START_ADDRESS
+ ).safe_then([&](auto s)
+ -> open_ertr::future<> {
+ if (s.magic != 0xFF) {
+ return crimson::ct_error::enoent::make();
+ }
+ super = s;
+ return check_bitmap_blocks().safe_then([]() {
+ return open_ertr::now();
+ });
+ }).handle_error(
+ open_ertr::pass_further{},
+ crimson::ct_error::assert_all{
+ "Invalid error read_rbm_header in BlockRBManager::open"
+ }
+ );
}
BlockRBManager::write_ertr::future<> BlockRBManager::write(
namespace crimson::os::seastore {
+constexpr rbm_abs_addr RBM_START_ADDRESS = 0;
constexpr uint32_t RBM_SUPERBLOCK_SIZE = 4096;
using RBMDevice = random_block_device::RBMDevice;
mkfs_ertr::future<> mkfs(mkfs_config_t) final;
read_ertr::future<> read(paddr_t addr, bufferptr &buffer) final;
write_ertr::future<> write(paddr_t addr, bufferptr &buf) final;
- open_ertr::future<> open(const std::string &path, paddr_t start) final;
+ open_ertr::future<> open() final;
close_ertr::future<> close() final;
/*
seastar::future<> set_up_fut() final {
device.reset(new random_block_device::TestMemory(DEFAULT_TEST_SIZE));
- rbm_manager.reset(new BlockRBManager(device.get(), std::string()));
device_id_t d_id = 1 << (std::numeric_limits<device_id_t>::digits - 1);
+ device->set_device_id(d_id);
+ rbm_manager.reset(new BlockRBManager(device.get(), std::string()));
config.start = paddr_t::make_blk_paddr(d_id, 0);
config.end = paddr_t::make_blk_paddr(d_id, DEFAULT_TEST_SIZE);
config.block_size = DEFAULT_BLOCK_SIZE;
config.total_size = DEFAULT_TEST_SIZE;
config.device_id = d_id;
- return seastar::now();
+ return device->mount().handle_error(crimson::ct_error::assert_all{}
+ ).then([this] {
+ return rbm_manager->mkfs(config).handle_error(crimson::ct_error::assert_all{}
+ ).then([this] {
+ return rbm_manager->open().handle_error(crimson::ct_error::assert_all{});
+ });
+ });
}
seastar::future<> tear_down_fut() final {
+ rbm_manager->close().unsafe_get0();
+ device->close().unsafe_get0();
rbm_manager.reset();
device.reset();
return seastar::now();
}
auto open() {
- return rbm_manager->open("", config.start).unsafe_get0();
+ return rbm_manager->open().unsafe_get0();
}
auto write(uint64_t addr, bufferptr &ptr) {
TEST_F(rbm_test_t, mkfs_test)
{
run_async([this] {
- mkfs();
- open();
auto super = read_rbm_header();
ASSERT_TRUE(
super.block_size == DEFAULT_BLOCK_SIZE &&
TEST_F(rbm_test_t, open_test)
{
run_async([this] {
- mkfs();
- open();
auto content = generate_extent(1);
write(
DEFAULT_BLOCK_SIZE,
TEST_F(rbm_test_t, block_alloc_test)
{
run_async([this] {
- mkfs();
- open();
auto t = create_rbm_transaction();
alloc_extent(*t, DEFAULT_BLOCK_SIZE);
auto alloc_ids = get_allocated_blk_ids(*t);
TEST_F(rbm_test_t, block_alloc_free_test)
{
run_async([this] {
- mkfs();
- open();
auto t = create_rbm_transaction();
alloc_extent(*t, DEFAULT_BLOCK_SIZE);
auto alloc_ids = get_allocated_blk_ids(*t);
config.end = paddr_t::make_blk_paddr(d_id, (DEFAULT_TEST_SIZE * 1024));
config.block_size = DEFAULT_BLOCK_SIZE;
config.total_size = DEFAULT_TEST_SIZE * 1024;
+ rbm_manager->close().unsafe_get0();
mkfs();
open();
auto max = rbm_manager->max_block_by_bitmap_block();
TEST_F(rbm_test_t, check_free_blocks)
{
run_async([this] {
- mkfs();
- open();
rbm_manager->rbm_sync_block_bitmap_by_range(10, 12, bitmap_op_types_t::ALL_SET).unsafe_get0();
rbm_manager->close().unsafe_get0();
open();