forked from vitalif/vitastor
Allow to specify device paths in fio options
parent
95396e2c83
commit
cbf5173d1b
|
@ -1,6 +1,6 @@
|
|||
#include "blockstore.h"
|
||||
|
||||
blockstore::blockstore(spp::sparse_hash_map<std::string, std::string> & config, ring_loop_t *ringloop)
|
||||
blockstore::blockstore(blockstore_config_t & config, ring_loop_t *ringloop)
|
||||
{
|
||||
this->ringloop = ringloop;
|
||||
ring_consumer.loop = [this]() { loop(); };
|
||||
|
|
12
blockstore.h
12
blockstore.h
|
@ -246,6 +246,8 @@ private:
|
|||
|
||||
#include "blockstore_flush.h"
|
||||
|
||||
typedef spp::sparse_hash_map<std::string, std::string> blockstore_config_t;
|
||||
|
||||
class blockstore
|
||||
{
|
||||
struct ring_consumer_t ring_consumer;
|
||||
|
@ -284,10 +286,10 @@ class blockstore
|
|||
friend class journal_flusher_t;
|
||||
friend class journal_flusher_co;
|
||||
|
||||
void calc_lengths(spp::sparse_hash_map<std::string, std::string> & config);
|
||||
void open_data(spp::sparse_hash_map<std::string, std::string> & config);
|
||||
void open_meta(spp::sparse_hash_map<std::string, std::string> & config);
|
||||
void open_journal(spp::sparse_hash_map<std::string, std::string> & config);
|
||||
void calc_lengths(blockstore_config_t & config);
|
||||
void open_data(blockstore_config_t & config);
|
||||
void open_meta(blockstore_config_t & config);
|
||||
void open_journal(blockstore_config_t & config);
|
||||
|
||||
// Asynchronous init
|
||||
int initialized;
|
||||
|
@ -324,7 +326,7 @@ class blockstore
|
|||
|
||||
public:
|
||||
|
||||
blockstore(spp::sparse_hash_map<std::string, std::string> & config, ring_loop_t *ringloop);
|
||||
blockstore(blockstore_config_t & config, ring_loop_t *ringloop);
|
||||
~blockstore();
|
||||
|
||||
// Event loop
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "blockstore.h"
|
||||
|
||||
void blockstore::calc_lengths(spp::sparse_hash_map<std::string, std::string> & config)
|
||||
void blockstore::calc_lengths(blockstore_config_t & config)
|
||||
{
|
||||
// data
|
||||
data_len = data_size - data_offset;
|
||||
|
@ -90,7 +90,7 @@ void check_size(int fd, uint64_t *size, std::string name)
|
|||
}
|
||||
}
|
||||
|
||||
void blockstore::open_data(spp::sparse_hash_map<std::string, std::string> & config)
|
||||
void blockstore::open_data(blockstore_config_t & config)
|
||||
{
|
||||
data_offset = strtoull(config["data_offset"].c_str(), NULL, 10);
|
||||
if (data_offset % DISK_ALIGNMENT)
|
||||
|
@ -109,7 +109,7 @@ void blockstore::open_data(spp::sparse_hash_map<std::string, std::string> & conf
|
|||
}
|
||||
}
|
||||
|
||||
void blockstore::open_meta(spp::sparse_hash_map<std::string, std::string> & config)
|
||||
void blockstore::open_meta(blockstore_config_t & config)
|
||||
{
|
||||
meta_offset = strtoull(config["meta_offset"].c_str(), NULL, 10);
|
||||
if (meta_offset % DISK_ALIGNMENT)
|
||||
|
@ -141,7 +141,7 @@ void blockstore::open_meta(spp::sparse_hash_map<std::string, std::string> & conf
|
|||
}
|
||||
}
|
||||
|
||||
void blockstore::open_journal(spp::sparse_hash_map<std::string, std::string> & config)
|
||||
void blockstore::open_journal(blockstore_config_t & config)
|
||||
{
|
||||
journal.offset = strtoull(config["journal_offset"].c_str(), NULL, 10);
|
||||
if (journal.offset % DISK_ALIGNMENT)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// FIO engine to test Blockstore
|
||||
// fio -thread -ioengine=./libfio_blockstore.so -name=test -bs=4k -direct=1 -fsync=16 -iodepth=16 -rw=randwrite -size=1G
|
||||
// fio -thread -ioengine=./libfio_blockstore.so -name=test -bs=4k -direct=1 -fsync=16 -iodepth=16 -rw=randwrite \
|
||||
// -data_device=./test_data.bin -meta_device=./test_meta.bin -journal_device=./test_journal.bin -size=1G
|
||||
|
||||
#include "blockstore.h"
|
||||
extern "C" {
|
||||
|
@ -19,6 +20,7 @@ struct bs_data
|
|||
|
||||
struct bs_options
|
||||
{
|
||||
int __pad;
|
||||
char *data_device, *meta_device, *journal_device;
|
||||
};
|
||||
|
||||
|
@ -28,7 +30,25 @@ static struct fio_option options[] = {
|
|||
.lname = "Data device",
|
||||
.type = FIO_OPT_STR_STORE,
|
||||
.off1 = offsetof(struct bs_options, data_device),
|
||||
.help = "Name of the data device",
|
||||
.help = "Name of the data device/file",
|
||||
.category = FIO_OPT_C_ENGINE,
|
||||
.group = FIO_OPT_G_FILENAME,
|
||||
},
|
||||
{
|
||||
.name = "meta_device",
|
||||
.lname = "Metadata device",
|
||||
.type = FIO_OPT_STR_STORE,
|
||||
.off1 = offsetof(struct bs_options, meta_device),
|
||||
.help = "Name of the metadata device/file",
|
||||
.category = FIO_OPT_C_ENGINE,
|
||||
.group = FIO_OPT_G_FILENAME,
|
||||
},
|
||||
{
|
||||
.name = "journal_device",
|
||||
.lname = "Journal device",
|
||||
.type = FIO_OPT_STR_STORE,
|
||||
.off1 = offsetof(struct bs_options, journal_device),
|
||||
.help = "Name of the journal device/file",
|
||||
.category = FIO_OPT_C_ENGINE,
|
||||
.group = FIO_OPT_G_FILENAME,
|
||||
},
|
||||
|
@ -40,7 +60,6 @@ static struct fio_option options[] = {
|
|||
static int bs_setup(struct thread_data *td)
|
||||
{
|
||||
bs_data *bsd;
|
||||
bs_options *o = (bs_options*)td->eo;
|
||||
fio_file *f;
|
||||
int r;
|
||||
//int64_t size;
|
||||
|
@ -62,17 +81,20 @@ static int bs_setup(struct thread_data *td)
|
|||
f = td->files[0];
|
||||
|
||||
//f->real_file_size = size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bs_cleanup(struct thread_data *td)
|
||||
{
|
||||
bs_data *bsd = (bs_data*)td->io_ops_data;
|
||||
|
||||
if (bsd)
|
||||
{
|
||||
|
||||
while (!bsd->bs->is_safe_to_stop())
|
||||
{
|
||||
bsd->ringloop->loop();
|
||||
bsd->ringloop->wait();
|
||||
}
|
||||
delete bsd->bs;
|
||||
delete bsd;
|
||||
}
|
||||
}
|
||||
|
@ -84,10 +106,10 @@ static int bs_init(struct thread_data *td)
|
|||
bs_data *bsd = (bs_data*)td->io_ops_data;
|
||||
int r;
|
||||
|
||||
spp::sparse_hash_map<std::string, std::string> config;
|
||||
config["meta_device"] = "./test_meta.bin";
|
||||
config["journal_device"] = "./test_journal.bin";
|
||||
config["data_device"] = "./test_data.bin";
|
||||
blockstore_config_t config;
|
||||
config["journal_device"] = o->journal_device;
|
||||
config["meta_device"] = o->meta_device;
|
||||
config["data_device"] = o->data_device;
|
||||
bsd->ringloop = new ring_loop_t(512);
|
||||
bsd->bs = new blockstore(config, bsd->ringloop);
|
||||
while (1)
|
||||
|
@ -282,6 +304,8 @@ struct ioengine_ops ioengine = {
|
|||
.invalidate = bs_invalidate,
|
||||
.io_u_init = bs_io_u_init,
|
||||
.io_u_free = bs_io_u_free,
|
||||
.option_struct_size = sizeof(struct bs_options),
|
||||
.options = options,
|
||||
};
|
||||
|
||||
static void fio_init fio_bs_register(void)
|
||||
|
|
Loading…
Reference in New Issue