Final name is Vitastor

Vitaliy Filippov 2020-08-03 23:50:50 +03:00
parent 6022f28dc9
commit 95ebfad283
9 changed files with 109 additions and 104 deletions

View File

@ -81,7 +81,7 @@ void etcd_state_client_t::parse_config(json11::Json & config)
this->etcd_prefix = config["etcd_prefix"].string_value();
if (this->etcd_prefix == "")
{
this->etcd_prefix = "/microceph";
this->etcd_prefix = "/vitastor";
}
else if (this->etcd_prefix[0] != '/')
{

View File

@ -3,17 +3,17 @@
// Random write:
//
// fio -thread -ioengine=./libfio_cluster.so -name=test -bs=4k -direct=1 -fsync=16 -iodepth=16 -rw=randwrite \
// -etcd=127.0.0.1:2379 [-etcd_prefix=/microceph] -inode=1 -size=1000M
// -etcd=127.0.0.1:2379 [-etcd_prefix=/vitastor] -inode=1 -size=1000M
//
// Linear write:
//
// fio -thread -ioengine=./libfio_cluster.so -name=test -bs=128k -direct=1 -fsync=32 -iodepth=32 -rw=write \
// -etcd=127.0.0.1:2379 [-etcd_prefix=/microceph] -inode=1 -size=1000M
// -etcd=127.0.0.1:2379 [-etcd_prefix=/vitastor] -inode=1 -size=1000M
//
// Random read (run with -iodepth=32 or -iodepth=1):
//
// fio -thread -ioengine=./libfio_cluster.so -name=test -bs=4k -direct=1 -iodepth=32 -rw=randread \
// -etcd=127.0.0.1:2379 [-etcd_prefix=/microceph] -inode=1 -size=1000M
// -etcd=127.0.0.1:2379 [-etcd_prefix=/vitastor] -inode=1 -size=1000M
#include <sys/types.h>
#include <sys/socket.h>
@ -68,7 +68,7 @@ static struct fio_option options[] = {
.lname = "etcd key prefix",
.type = FIO_OPT_STR_STORE,
.off1 = offsetof(struct sec_options, etcd_prefix),
.help = "etcd key prefix, by default /microceph",
.help = "etcd key prefix, by default /vitastor",
.category = FIO_OPT_C_ENGINE,
.group = FIO_OPT_G_FILENAME,
},
@ -140,7 +140,7 @@ static int sec_init(struct thread_data *td)
json11::Json cfg = json11::Json::object {
{ "etcd_address", std::string(o->etcd_host) },
{ "etcd_prefix", std::string(o->etcd_prefix ? o->etcd_prefix : "/microceph") },
{ "etcd_prefix", std::string(o->etcd_prefix ? o->etcd_prefix : "/vitastor") },
};
bsd->ringloop = new ring_loop_t(512);
@ -278,7 +278,7 @@ static int sec_invalidate(struct thread_data *td, struct fio_file *f)
}
struct ioengine_ops ioengine = {
.name = "microceph_cluster",
.name = "vitastor_cluster",
.version = FIO_IOOPS_VERSION,
.flags = FIO_MEMALIGN | FIO_DISKLESSIO | FIO_NOEXTEND,
.setup = sec_setup,

View File

@ -290,7 +290,7 @@ static int bs_invalidate(struct thread_data *td, struct fio_file *f)
}
struct ioengine_ops ioengine = {
.name = "microceph_blockstore",
.name = "vitastor_blockstore",
.version = FIO_IOOPS_VERSION,
.flags = FIO_MEMALIGN | FIO_DISKLESSIO | FIO_NOEXTEND,
.setup = bs_setup,

View File

@ -381,7 +381,7 @@ static int sec_invalidate(struct thread_data *td, struct fio_file *f)
}
struct ioengine_ops ioengine = {
.name = "microceph_secondary_osd",
.name = "vitastor_secondary_osd",
.version = FIO_IOOPS_VERSION,
.flags = FIO_MEMALIGN | FIO_DISKLESSIO | FIO_NOEXTEND,
.setup = sec_setup,

View File

@ -45,7 +45,7 @@ class Mon
url += '/v3';
this.etcd_urls.push(scheme+'://'+url);
}
this.etcd_prefix = config.etcd_prefix || '/microceph';
this.etcd_prefix = config.etcd_prefix || '/vitastor';
this.etcd_prefix = this.etcd_prefix.replace(/\/\/+/g, '/').replace(/^\/?(.*[^\/])\/?$/, '/$1');
this.etcd_start_timeout = (config.etcd_start_timeout || 5) * 1000;
this.state = JSON.parse(JSON.stringify(Mon.etcd_tree));
@ -763,6 +763,11 @@ class Mon
{
const base = this.etcd_urls[Math.floor(Math.random()*this.etcd_urls.length)];
const res = await POST(base+path, body, timeout);
if (res.error)
{
console.log('etcd returned error: '+res.error);
break;
}
if (res.json)
{
if (res.json.error)
@ -816,7 +821,7 @@ function POST(url, body, timeout)
}, timeout) : null;
let req = http.request(url, { method: 'POST', headers: {
'Content-Type': 'application/json',
'Content-Length': body_text,
'Content-Length': body_text.length,
} }, (res) =>
{
if (!req)
@ -824,16 +829,16 @@ function POST(url, body, timeout)
return;
}
clearTimeout(timer_id);
if (res.statusCode != 200)
{
ok({ error: res.statusCode, response: res });
return;
}
let res_body = '';
res.setEncoding('utf8');
res.on('data', chunk => { res_body += chunk });
res.on('end', () =>
{
if (res.statusCode != 200)
{
ok({ error: res_body, code: res.statusCode });
return;
}
try
{
res_body = JSON.parse(res_body);

View File

@ -1,7 +1,7 @@
{
"name": "falcon-mon",
"name": "vitastor-mon",
"version": "1.0.0",
"description": "Falcon storage monitor service",
"description": "Vitastor SDS monitor service",
"main": "mon-main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"

View File

@ -16,7 +16,7 @@
#include "qemu_proxy.h"
typedef struct FalconClient
typedef struct VitastorClient
{
void *proxy;
char *etcd_host;
@ -25,16 +25,16 @@ typedef struct FalconClient
uint64_t size;
int readonly;
QemuMutex mutex;
} FalconClient;
} VitastorClient;
typedef struct FalconRPC
typedef struct VitastorRPC
{
BlockDriverState *bs;
Coroutine *co;
QEMUIOVector *iov;
int ret;
int complete;
} FalconRPC;
} VitastorRPC;
static char *qemu_rbd_next_tok(char *src, char delim, char **p)
{
@ -67,16 +67,16 @@ static void qemu_rbd_unescape(char *src)
*p = '\0';
}
// falcon[:key=value]*
// falcon:etcd_host=127.0.0.1:inode=1
static void falcon_parse_filename(const char *filename, QDict *options, Error **errp)
// vitastor[:key=value]*
// vitastor:etcd_host=127.0.0.1:inode=1
static void vitastor_parse_filename(const char *filename, QDict *options, Error **errp)
{
const char *start;
char *p, *buf;
if (!strstart(filename, "falcon:", &start))
if (!strstart(filename, "vitastor:", &start))
{
error_setg(errp, "File name must start with 'falcon:'");
error_setg(errp, "File name must start with 'vitastor:'");
return;
}
@ -132,16 +132,16 @@ out:
return;
}
static int falcon_file_open(BlockDriverState *bs, QDict *options, int flags, Error **errp)
static int vitastor_file_open(BlockDriverState *bs, QDict *options, int flags, Error **errp)
{
FalconClient *client = bs->opaque;
VitastorClient *client = bs->opaque;
int64_t ret = 0;
client->etcd_host = g_strdup(qdict_get_try_str(options, "etcd_host"));
client->etcd_prefix = g_strdup(qdict_get_try_str(options, "etcd_prefix"));
client->inode = qdict_get_int(options, "inode");
client->size = qdict_get_int(options, "size");
client->readonly = (flags & BDRV_O_RDWR) ? 1 : 0;
client->proxy = falcon_proxy_create(bdrv_get_aio_context(bs), client->etcd_host, client->etcd_prefix);
client->proxy = vitastor_proxy_create(bdrv_get_aio_context(bs), client->etcd_host, client->etcd_prefix);
//client->aio_context = bdrv_get_aio_context(bs);
bs->total_sectors = client->size / BDRV_SECTOR_SIZE;
qdict_del(options, "etcd_host");
@ -152,37 +152,37 @@ static int falcon_file_open(BlockDriverState *bs, QDict *options, int flags, Err
return ret;
}
static void falcon_close(BlockDriverState *bs)
static void vitastor_close(BlockDriverState *bs)
{
FalconClient *client = bs->opaque;
falcon_proxy_destroy(client->proxy);
VitastorClient *client = bs->opaque;
vitastor_proxy_destroy(client->proxy);
qemu_mutex_destroy(&client->mutex);
g_free(client->etcd_host);
if (client->etcd_prefix)
g_free(client->etcd_prefix);
}
static int falcon_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
static int vitastor_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
{
bsz->phys = 4096;
bsz->log = 4096;
return 0;
}
static int coroutine_fn falcon_co_create_opts(BlockDriver *drv, const char *url, QemuOpts *opts, Error **errp)
static int coroutine_fn vitastor_co_create_opts(BlockDriver *drv, const char *url, QemuOpts *opts, Error **errp)
{
QDict *options;
int ret;
options = qdict_new();
falcon_parse_filename(url, options, errp);
vitastor_parse_filename(url, options, errp);
if (*errp)
{
ret = -1;
goto out;
}
// inodes don't require creation in Falcon. FIXME: They will when there will be some metadata
// inodes don't require creation in Vitastor. FIXME: They will when there will be some metadata
ret = 0;
out:
@ -190,9 +190,9 @@ out:
return ret;
}
static int coroutine_fn falcon_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, PreallocMode prealloc, Error **errp)
static int coroutine_fn vitastor_co_truncate(BlockDriverState *bs, int64_t offset, bool exact, PreallocMode prealloc, Error **errp)
{
FalconClient *client = bs->opaque;
VitastorClient *client = bs->opaque;
if (prealloc != PREALLOC_MODE_OFF)
{
@ -206,41 +206,41 @@ static int coroutine_fn falcon_co_truncate(BlockDriverState *bs, int64_t offset,
return 0;
}
static int falcon_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
static int vitastor_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
bdi->cluster_size = 4096;
return 0;
}
static int64_t falcon_getlength(BlockDriverState *bs)
static int64_t vitastor_getlength(BlockDriverState *bs)
{
FalconClient *client = bs->opaque;
VitastorClient *client = bs->opaque;
return client->size;
}
static void falcon_refresh_limits(BlockDriverState *bs, Error **errp)
static void vitastor_refresh_limits(BlockDriverState *bs, Error **errp)
{
bs->bl.request_alignment = 4096;
bs->bl.min_mem_alignment = 4096;
bs->bl.opt_mem_alignment = 4096;
}
static int64_t falcon_get_allocated_file_size(BlockDriverState *bs)
static int64_t vitastor_get_allocated_file_size(BlockDriverState *bs)
{
return 0;
}
static void falcon_co_init_task(BlockDriverState *bs, FalconRPC *task)
static void vitastor_co_init_task(BlockDriverState *bs, VitastorRPC *task)
{
*task = (FalconRPC) {
*task = (VitastorRPC) {
.co = qemu_coroutine_self(),
.bs = bs,
};
}
static void falcon_co_generic_bh_cb(int retval, void *opaque)
static void vitastor_co_generic_bh_cb(int retval, void *opaque)
{
FalconRPC *task = opaque;
VitastorRPC *task = opaque;
task->ret = retval;
task->complete = 1;
if (qemu_coroutine_self() != task->co)
@ -249,15 +249,15 @@ static void falcon_co_generic_bh_cb(int retval, void *opaque)
}
}
static int coroutine_fn falcon_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *iov, int flags)
static int coroutine_fn vitastor_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *iov, int flags)
{
FalconClient *client = bs->opaque;
FalconRPC task;
falcon_co_init_task(bs, &task);
VitastorClient *client = bs->opaque;
VitastorRPC task;
vitastor_co_init_task(bs, &task);
task.iov = iov;
qemu_mutex_lock(&client->mutex);
falcon_proxy_rw(0, client->proxy, client->inode, offset, bytes, iov->iov, iov->niov, falcon_co_generic_bh_cb, &task);
vitastor_proxy_rw(0, client->proxy, client->inode, offset, bytes, iov->iov, iov->niov, vitastor_co_generic_bh_cb, &task);
qemu_mutex_unlock(&client->mutex);
while (!task.complete)
@ -268,15 +268,15 @@ static int coroutine_fn falcon_co_preadv(BlockDriverState *bs, uint64_t offset,
return task.ret;
}
static int coroutine_fn falcon_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *iov, int flags)
static int coroutine_fn vitastor_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *iov, int flags)
{
FalconClient *client = bs->opaque;
FalconRPC task;
falcon_co_init_task(bs, &task);
VitastorClient *client = bs->opaque;
VitastorRPC task;
vitastor_co_init_task(bs, &task);
task.iov = iov;
qemu_mutex_lock(&client->mutex);
falcon_proxy_rw(1, client->proxy, client->inode, offset, bytes, iov->iov, iov->niov, falcon_co_generic_bh_cb, &task);
vitastor_proxy_rw(1, client->proxy, client->inode, offset, bytes, iov->iov, iov->niov, vitastor_co_generic_bh_cb, &task);
qemu_mutex_unlock(&client->mutex);
while (!task.complete)
@ -287,14 +287,14 @@ static int coroutine_fn falcon_co_pwritev(BlockDriverState *bs, uint64_t offset,
return task.ret;
}
static int coroutine_fn falcon_co_flush(BlockDriverState *bs)
static int coroutine_fn vitastor_co_flush(BlockDriverState *bs)
{
FalconClient *client = bs->opaque;
FalconRPC task;
falcon_co_init_task(bs, &task);
VitastorClient *client = bs->opaque;
VitastorRPC task;
vitastor_co_init_task(bs, &task);
qemu_mutex_lock(&client->mutex);
falcon_proxy_sync(client->proxy, falcon_co_generic_bh_cb, &task);
vitastor_proxy_sync(client->proxy, vitastor_co_generic_bh_cb, &task);
qemu_mutex_unlock(&client->mutex);
while (!task.complete)
@ -305,9 +305,9 @@ static int coroutine_fn falcon_co_flush(BlockDriverState *bs)
return task.ret;
}
static QemuOptsList falcon_create_opts = {
.name = "falcon-create-opts",
.head = QTAILQ_HEAD_INITIALIZER(falcon_create_opts.head),
static QemuOptsList vitastor_create_opts = {
.name = "vitastor-create-opts",
.head = QTAILQ_HEAD_INITIALIZER(vitastor_create_opts.head),
.desc = {
{
.name = BLOCK_OPT_SIZE,
@ -318,7 +318,7 @@ static QemuOptsList falcon_create_opts = {
}
};
static const char *falcon_strong_runtime_opts[] = {
static const char *vitastor_strong_runtime_opts[] = {
"inode",
"etcd_host",
"etcd_prefix",
@ -326,48 +326,48 @@ static const char *falcon_strong_runtime_opts[] = {
NULL
};
static BlockDriver bdrv_falcon = {
.format_name = "falcon",
.protocol_name = "falcon",
static BlockDriver bdrv_vitastor = {
.format_name = "vitastor",
.protocol_name = "vitastor",
.instance_size = sizeof(FalconClient),
.bdrv_parse_filename = falcon_parse_filename,
.instance_size = sizeof(VitastorClient),
.bdrv_parse_filename = vitastor_parse_filename,
.bdrv_has_zero_init = bdrv_has_zero_init_1,
.bdrv_has_zero_init_truncate = bdrv_has_zero_init_1,
.bdrv_get_info = falcon_get_info,
.bdrv_getlength = falcon_getlength,
.bdrv_probe_blocksizes = falcon_probe_blocksizes,
.bdrv_refresh_limits = falcon_refresh_limits,
.bdrv_get_info = vitastor_get_info,
.bdrv_getlength = vitastor_getlength,
.bdrv_probe_blocksizes = vitastor_probe_blocksizes,
.bdrv_refresh_limits = vitastor_refresh_limits,
// FIXME: Implement it along with per-inode statistics
//.bdrv_get_allocated_file_size = falcon_get_allocated_file_size,
//.bdrv_get_allocated_file_size = vitastor_get_allocated_file_size,
.bdrv_file_open = falcon_file_open,
.bdrv_close = falcon_close,
.bdrv_file_open = vitastor_file_open,
.bdrv_close = vitastor_close,
// Option list for the create operation
.create_opts = &falcon_create_opts,
.create_opts = &vitastor_create_opts,
// For qmp_blockdev_create(), used by the qemu monitor / QAPI
// Requires patching QAPI IDL, thus unimplemented
//.bdrv_co_create = falcon_co_create,
//.bdrv_co_create = vitastor_co_create,
// For bdrv_create(), used by qemu-img
.bdrv_co_create_opts = falcon_co_create_opts,
.bdrv_co_create_opts = vitastor_co_create_opts,
.bdrv_co_truncate = falcon_co_truncate,
.bdrv_co_truncate = vitastor_co_truncate,
.bdrv_co_preadv = falcon_co_preadv,
.bdrv_co_pwritev = falcon_co_pwritev,
.bdrv_co_flush_to_disk = falcon_co_flush,
.bdrv_co_preadv = vitastor_co_preadv,
.bdrv_co_pwritev = vitastor_co_pwritev,
.bdrv_co_flush_to_disk = vitastor_co_flush,
.strong_runtime_opts = falcon_strong_runtime_opts,
.strong_runtime_opts = vitastor_strong_runtime_opts,
};
static void falcon_block_init(void)
static void vitastor_block_init(void)
{
bdrv_register(&bdrv_falcon);
bdrv_register(&bdrv_vitastor);
}
block_init(falcon_block_init);
block_init(vitastor_block_init);

View File

@ -36,7 +36,7 @@ public:
this->ctx = ctx;
json11::Json cfg = json11::Json::object {
{ "etcd_address", std::string(etcd_host) },
{ "etcd_prefix", std::string(etcd_prefix ? etcd_prefix : "/microceph") },
{ "etcd_prefix", std::string(etcd_prefix ? etcd_prefix : "/vitastor") },
};
tfd = new timerfd_manager_t([this](int fd, bool wr, std::function<void(int, int)> callback) { set_fd_handler(fd, wr, callback); });
cli = new cluster_client_t(NULL, tfd, cfg);
@ -78,20 +78,20 @@ public:
extern "C" {
void* falcon_proxy_create(AioContext *ctx, const char *etcd_host, const char *etcd_prefix)
void* vitastor_proxy_create(AioContext *ctx, const char *etcd_host, const char *etcd_prefix)
{
QemuProxy *p = new QemuProxy(ctx, etcd_host, etcd_prefix);
return p;
}
void falcon_proxy_destroy(void *client)
void vitastor_proxy_destroy(void *client)
{
QemuProxy *p = (QemuProxy*)client;
delete p;
}
void falcon_proxy_rw(int write, void *client, uint64_t inode, uint64_t offset, uint64_t len,
iovec *iov, int iovcnt, FalconIOHandler cb, void *opaque)
void vitastor_proxy_rw(int write, void *client, uint64_t inode, uint64_t offset, uint64_t len,
iovec *iov, int iovcnt, VitastorIOHandler cb, void *opaque)
{
QemuProxy *p = (QemuProxy*)client;
cluster_op_t *op = new cluster_op_t;
@ -111,7 +111,7 @@ void falcon_proxy_rw(int write, void *client, uint64_t inode, uint64_t offset, u
p->cli->execute(op);
}
void falcon_proxy_sync(void *client, FalconIOHandler cb, void *opaque)
void vitastor_proxy_sync(void *client, VitastorIOHandler cb, void *opaque)
{
QemuProxy *p = (QemuProxy*)client;
cluster_op_t *op = new cluster_op_t;

View File

@ -1,5 +1,5 @@
#ifndef FALCON_QEMU_PROXY_H
#define FALCON_QEMU_PROXY_H
#ifndef VITASTOR_QEMU_PROXY_H
#define VITASTOR_QEMU_PROXY_H
#include <stdint.h>
#include <sys/uio.h>
@ -9,12 +9,12 @@ extern "C" {
#endif
// Our exports
typedef void FalconIOHandler(int retval, void *opaque);
void* falcon_proxy_create(AioContext *ctx, const char *etcd_host, const char *etcd_prefix);
void falcon_proxy_destroy(void *client);
void falcon_proxy_rw(int write, void *client, uint64_t inode, uint64_t offset, uint64_t len,
struct iovec *iov, int iovcnt, FalconIOHandler cb, void *opaque);
void falcon_proxy_sync(void *client, FalconIOHandler cb, void *opaque);
typedef void VitastorIOHandler(int retval, void *opaque);
void* vitastor_proxy_create(AioContext *ctx, const char *etcd_host, const char *etcd_prefix);
void vitastor_proxy_destroy(void *client);
void vitastor_proxy_rw(int write, void *client, uint64_t inode, uint64_t offset, uint64_t len,
struct iovec *iov, int iovcnt, VitastorIOHandler cb, void *opaque);
void vitastor_proxy_sync(void *client, VitastorIOHandler cb, void *opaque);
#ifdef __cplusplus
}