Browse Source

Use bitmap granularity for alignment checks

tags/v0.5.11
Vitaliy Filippov 4 months ago
parent
commit
54f2353f24
10 changed files with 24 additions and 29 deletions
  1. +2
    -2
      src/blockstore.cpp
  2. +1
    -1
      src/blockstore.h
  3. +1
    -1
      src/blockstore_impl.cpp
  4. +1
    -1
      src/blockstore_impl.h
  5. +1
    -6
      src/cluster_client.cpp
  6. +0
    -1
      src/cluster_client.h
  7. +13
    -9
      src/osd.cpp
  8. +2
    -2
      src/osd.h
  9. +1
    -4
      src/osd_main.cpp
  10. +2
    -2
      src/osd_primary.cpp

+ 2
- 2
src/blockstore.cpp View File

@@ -58,7 +58,7 @@ uint64_t blockstore_t::get_free_block_count()
return impl->get_free_block_count();
}

uint32_t blockstore_t::get_disk_alignment()
uint32_t blockstore_t::get_bitmap_granularity()
{
return impl->get_disk_alignment();
return impl->get_bitmap_granularity();
}

+ 1
- 1
src/blockstore.h View File

@@ -183,5 +183,5 @@ public:
uint64_t get_block_count();
uint64_t get_free_block_count();

uint32_t get_disk_alignment();
uint32_t get_bitmap_granularity();
};

+ 1
- 1
src/blockstore_impl.cpp View File

@@ -10,9 +10,9 @@ blockstore_impl_t::blockstore_impl_t(blockstore_config_t & config, ring_loop_t *
ring_consumer.loop = [this]() { loop(); };
ringloop->register_consumer(&ring_consumer);
initialized = 0;
zero_object = (uint8_t*)memalign_or_die(MEM_ALIGNMENT, block_size);
data_fd = meta_fd = journal.fd = -1;
parse_config(config);
zero_object = (uint8_t*)memalign_or_die(MEM_ALIGNMENT, block_size);
try
{
open_data();


+ 1
- 1
src/blockstore_impl.h View File

@@ -327,5 +327,5 @@ public:
inline uint32_t get_block_size() { return block_size; }
inline uint64_t get_block_count() { return block_count; }
inline uint64_t get_free_block_count() { return data_alloc->get_free_count(); }
inline uint32_t get_disk_alignment() { return disk_alignment; }
inline uint32_t get_bitmap_granularity() { return disk_alignment; }
};

+ 1
- 6
src/cluster_client.cpp View File

@@ -133,16 +133,11 @@ static uint32_t is_power_of_two(uint64_t value)
void cluster_client_t::on_load_config_hook(json11::Json::object & config)
{
bs_block_size = config["block_size"].uint64_value();
bs_disk_alignment = config["disk_alignment"].uint64_value();
bs_bitmap_granularity = config["bitmap_granularity"].uint64_value();
if (!bs_block_size)
{
bs_block_size = DEFAULT_BLOCK_SIZE;
}
if (!bs_disk_alignment)
{
bs_disk_alignment = DEFAULT_DISK_ALIGNMENT;
}
if (!bs_bitmap_granularity)
{
bs_bitmap_granularity = DEFAULT_BITMAP_GRANULARITY;
@@ -298,7 +293,7 @@ void cluster_client_t::execute(cluster_op_t *op)
op->retval = 0;
if (op->opcode != OSD_OP_SYNC && op->opcode != OSD_OP_READ && op->opcode != OSD_OP_WRITE ||
(op->opcode == OSD_OP_READ || op->opcode == OSD_OP_WRITE) && (!op->inode || !op->len ||
op->offset % bs_disk_alignment || op->len % bs_disk_alignment))
op->offset % bs_bitmap_granularity || op->len % bs_bitmap_granularity))
{
op->retval = -EINVAL;
std::function<void(cluster_op_t*)>(op->callback)(op);


+ 0
- 1
src/cluster_client.h View File

@@ -53,7 +53,6 @@ class cluster_client_t
ring_loop_t *ringloop;

uint64_t bs_block_size = 0;
uint64_t bs_disk_alignment = 0;
uint64_t bs_bitmap_granularity = 0;
std::map<pool_id_t, uint64_t> pg_counts;
bool immediate_commit = false;


+ 13
- 9
src/osd.cpp View File

@@ -9,15 +9,18 @@

#include "osd.h"

osd_t::osd_t(blockstore_config_t & config, blockstore_t *bs, ring_loop_t *ringloop)
osd_t::osd_t(blockstore_config_t & config, ring_loop_t *ringloop)
{
config["entry_attr_size"] = "0";

this->config = config;
this->bs = bs;
this->ringloop = ringloop;

// FIXME: Create Blockstore from on-disk superblock config and check it against the OSD cluster config
this->bs = new blockstore_t(config, ringloop);

this->bs_block_size = bs->get_block_size();
// FIXME: use bitmap granularity instead
this->bs_disk_alignment = bs->get_disk_alignment();
this->bs_bitmap_granularity = bs->get_bitmap_granularity();

parse_config(config);

@@ -49,6 +52,7 @@ osd_t::~osd_t()
{
ringloop->unregister_consumer(&consumer);
delete epmgr;
delete bs;
close(listen_fd);
}

@@ -171,7 +175,7 @@ bool osd_t::shutdown()
{
return false;
}
return bs->is_safe_to_stop();
return !bs || bs->is_safe_to_stop();
}

void osd_t::loop()
@@ -200,14 +204,14 @@ void osd_t::exec_op(osd_op_t *cur_op)
cur_op->req.hdr.opcode == OSD_OP_SEC_WRITE ||
cur_op->req.hdr.opcode == OSD_OP_SEC_WRITE_STABLE) &&
(cur_op->req.sec_rw.len > OSD_RW_MAX ||
cur_op->req.sec_rw.len % bs_disk_alignment ||
cur_op->req.sec_rw.offset % bs_disk_alignment)) ||
cur_op->req.sec_rw.len % bs_bitmap_granularity ||
cur_op->req.sec_rw.offset % bs_bitmap_granularity)) ||
((cur_op->req.hdr.opcode == OSD_OP_READ ||
cur_op->req.hdr.opcode == OSD_OP_WRITE ||
cur_op->req.hdr.opcode == OSD_OP_DELETE) &&
(cur_op->req.rw.len > OSD_RW_MAX ||
cur_op->req.rw.len % bs_disk_alignment ||
cur_op->req.rw.offset % bs_disk_alignment)))
cur_op->req.rw.len % bs_bitmap_granularity ||
cur_op->req.rw.offset % bs_bitmap_granularity)))
{
// Bad command
finish_op(cur_op, -EINVAL);


+ 2
- 2
src/osd.h View File

@@ -115,7 +115,7 @@ class osd_t
bool stopping = false;
int inflight_ops = 0;
blockstore_t *bs;
uint32_t bs_block_size, bs_disk_alignment;
uint32_t bs_block_size, bs_bitmap_granularity;
ring_loop_t *ringloop;
timerfd_manager_t *tfd = NULL;
epoll_manager_t *epmgr = NULL;
@@ -221,7 +221,7 @@ class osd_t
}

public:
osd_t(blockstore_config_t & config, blockstore_t *bs, ring_loop_t *ringloop);
osd_t(blockstore_config_t & config, ring_loop_t *ringloop);
~osd_t();
void force_stop(int exitcode);
bool shutdown();


+ 1
- 4
src/osd_main.cpp View File

@@ -41,16 +41,13 @@ int main(int narg, char *args[])
signal(SIGINT, handle_sigint);
signal(SIGTERM, handle_sigint);
ring_loop_t *ringloop = new ring_loop_t(512);
// FIXME: Create Blockstore from on-disk superblock config and check it against the OSD cluster config
blockstore_t *bs = new blockstore_t(config, ringloop);
osd = new osd_t(config, bs, ringloop);
osd = new osd_t(config, ringloop);
while (1)
{
ringloop->loop();
ringloop->wait();
}
delete osd;
delete bs;
delete ringloop;
return 0;
}

+ 2
- 2
src/osd_primary.cpp View File

@@ -44,8 +44,8 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
return false;
}
if ((cur_op->req.rw.offset + cur_op->req.rw.len) > (oid.stripe + pg_block_size) ||
(cur_op->req.rw.offset % bs_disk_alignment) != 0 ||
(cur_op->req.rw.len % bs_disk_alignment) != 0)
(cur_op->req.rw.offset % bs_bitmap_granularity) != 0 ||
(cur_op->req.rw.len % bs_bitmap_granularity) != 0)
{
finish_op(cur_op, -EINVAL);
return false;


Loading…
Cancel
Save