return crimson::get_logger(ceph_subsys_seastore_tm);
}
}
+
namespace crimson::os::seastore::random_block_device {
#include "crimson/os/seastore/logging.h"
SET_SUBSYS(seastore_device);
RBMDevice::mkfs_ret RBMDevice::mkfs(device_config_t config) {
LOG_PREFIX(RBMDevice::mkfs);
super.start = 0;
+ // TODO: improve mkfs() based on a file descriptor
super.block_size = get_block_size();
super.size = get_available_size();
seastar::open_flags mode) {
return seastar::do_with(in_path, [this, mode](auto& in_path) {
return seastar::file_stat(in_path).then([this, mode, in_path](auto stat) {
- size = stat.size;
+ super.size = stat.size;
+ super.block_size = stat.block_size;
return seastar::open_file_dma(in_path, mode).then([=, this](auto file) {
device = file;
logger().debug("open");
auto id_namespace_data) {
// LBA format provides LBA size which is power of 2. LBA is the
// minimum size of read and write.
- block_size = (1 << id_namespace_data.lbaf0.lbads);
- atomic_write_unit = awupf * block_size;
+ super.block_size = (1 << id_namespace_data.lbaf0.lbads);
+ atomic_write_unit = awupf * super.block_size;
data_protection_type = id_namespace_data.dps.protection_type;
data_protection_enabled = (data_protection_type > 0);
if (id_namespace_data.nsfeat.opterf == 1){
// NPWG and NPWA is 0'based value
- write_granularity = block_size * (id_namespace_data.npwg + 1);
- write_alignment = block_size * (id_namespace_data.npwa + 1);
+ write_granularity = super.block_size * (id_namespace_data.npwg + 1);
+ write_alignment = super.block_size * (id_namespace_data.npwa + 1);
}
return open_for_io(in_path, mode);
});
bptr.length());
auto length = bptr.length();
- assert((length % block_size) == 0);
+ assert((length % super.block_size) == 0);
uint16_t supported_stream = stream;
if (stream >= stream_id_count) {
supported_stream = WRITE_LIFE_NOT_SET;
bptr.length());
auto length = bptr.length();
- assert((length % block_size) == 0);
+ assert((length % super.block_size) == 0);
return device.dma_read(offset, bptr.c_str(), length).handle_exception(
[](auto e) -> read_ertr::future<size_t> {
if (stream >= stream_id_count) {
supported_stream = WRITE_LIFE_NOT_SET;
}
- bl.rebuild_aligned(block_size);
+ bl.rebuild_aligned(super.block_size);
return seastar::do_with(
bl.prepare_iovs(),
return read(rbm_addr, out);
}
protected:
- uint64_t size = 0;
-
- // LBA Size
- uint64_t block_size = 4096;
-
rbm_metadata_header_t super;
public:
RBMDevice() {}
device_id_t get_device_id() const {
return super.config.spec.id;
}
+ // for test
void set_device_id(device_id_t id) {
super.config.spec.id = id;
}
- void set_block_size(uint64_t bs) {
- block_size = bs;
- }
-
magic_t get_magic() const final {
return super.config.spec.magic;
}
secondary_device_set_t& get_secondary_devices() final {
return super.config.secondary_devices;
}
- std::size_t get_available_size() const final { return size; }
- extent_len_t get_block_size() const final { return block_size; }
+ std::size_t get_available_size() const { return super.size; }
+ extent_len_t get_block_size() const { return super.block_size; }
virtual read_ertr::future<> read(
uint64_t offset,
class TestMemory : public RBMDevice {
public:
+ uint64_t size = 0;
+ uint64_t block_size = 0;
- TestMemory(size_t size) : buf(nullptr) {
- RBMDevice::size = size;
+ TestMemory(size_t size, uint64_t block_size) :
+ size(size), block_size(block_size), buf(nullptr) {
}
~TestMemory() {
if (buf) {
}
}
+ std::size_t get_available_size() const final { return size; }
+ extent_len_t get_block_size() const final { return block_size; }
+
mount_ret mount() final {
return open("", seastar::open_flags::rw
).safe_then([]() {
WritePipeline pipeline;
cbjournal_test_t() {
- device = new random_block_device::TestMemory(CBTEST_DEFAULT_TEST_SIZE + CBTEST_DEFAULT_BLOCK_SIZE);
+ device = new random_block_device::TestMemory(
+ CBTEST_DEFAULT_TEST_SIZE + CBTEST_DEFAULT_BLOCK_SIZE,
+ CBTEST_DEFAULT_BLOCK_SIZE);
cbj.reset(new CircularBoundedJournal(*this, device, std::string()));
device_id_t d_id = 1 << (std::numeric_limits<device_id_t>::digits - 1);
config.block_size = CBTEST_DEFAULT_BLOCK_SIZE;
rbm_test_t() = default;
seastar::future<> set_up_fut() final {
- device.reset(new random_block_device::TestMemory(DEFAULT_TEST_SIZE));
+ device.reset(new random_block_device::TestMemory(DEFAULT_TEST_SIZE, DEFAULT_BLOCK_SIZE));
rbm_manager.reset(new BlockRBManager(device.get(), std::string()));
config = get_rbm_ephemeral_device_config(0, 1);
return device->mount().handle_error(crimson::ct_error::assert_all{}
super.block_size == DEFAULT_BLOCK_SIZE &&
super.size == DEFAULT_TEST_SIZE
);
- device->set_block_size(8196);
+ config.spec.id = DEVICE_ID_NULL;
mkfs();
super = read_rbm_header();
ASSERT_TRUE(
- super.block_size == 8196 &&
+ super.config.spec.id == DEVICE_ID_NULL &&
super.size == DEFAULT_TEST_SIZE
);
});
auto config =
journal::CircularBoundedJournal::mkfs_config_t::get_default();
rb_device.reset(new random_block_device::TestMemory(
- config.total_size + config.block_size));
+ config.total_size + config.block_size, config.block_size));
rb_device->set_device_id(
1 << (std::numeric_limits<device_id_t>::digits - 1));
return rb_device->mount().handle_error(crimson::ct_error::assert_all{}