Compare commits
No commits in common. "44692d148a3bc3beab388da09bd92fdb4e6dcb61" and "23a9aa93b51510a10ca7a508cc5e2277779eb122" have entirely different histories.
44692d148a
...
23a9aa93b5
|
@ -196,8 +196,8 @@ endif (HAVE_NBD_NETLINK_H AND NL3_LIBRARIES)
|
||||||
# libvitastor_kv.so
|
# libvitastor_kv.so
|
||||||
add_library(vitastor_kv SHARED
|
add_library(vitastor_kv SHARED
|
||||||
kv_db.cpp
|
kv_db.cpp
|
||||||
|
kv_db.h
|
||||||
)
|
)
|
||||||
set_target_properties(vitastor_kv PROPERTIES PUBLIC_HEADER "vitastor_kv.h")
|
|
||||||
target_link_libraries(vitastor_kv
|
target_link_libraries(vitastor_kv
|
||||||
vitastor_client
|
vitastor_client
|
||||||
)
|
)
|
||||||
|
|
|
@ -83,8 +83,8 @@ std::string validate_pool_config(json11::Json::object & new_cfg, json11::Json ol
|
||||||
}
|
}
|
||||||
else if (key == "block_size")
|
else if (key == "block_size")
|
||||||
{
|
{
|
||||||
uint64_t block_size = value.is_string() ? parse_size(value.string_value()) : value.uint64_value();
|
value = value.is_string() ? parse_size(value.string_value()) : value.uint64_value();
|
||||||
if (!block_size)
|
if (!value)
|
||||||
{
|
{
|
||||||
return key+" must be an integer with or without size suffix (K/M/G/T)";
|
return key+" must be an integer with or without size suffix (K/M/G/T)";
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,17 +12,16 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
//#include <signal.h>
|
//#include <signal.h>
|
||||||
|
|
||||||
#include "cluster_client.h"
|
|
||||||
#include "epoll_manager.h"
|
#include "epoll_manager.h"
|
||||||
#include "str_util.h"
|
#include "str_util.h"
|
||||||
#include "vitastor_kv.h"
|
#include "kv_db.h"
|
||||||
|
|
||||||
const char *exe_name = NULL;
|
const char *exe_name = NULL;
|
||||||
|
|
||||||
class kv_cli_t
|
class kv_cli_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::map<std::string, std::string> cfg;
|
json11::Json::object cfg;
|
||||||
std::vector<std::string> cli_cmd;
|
std::vector<std::string> cli_cmd;
|
||||||
|
|
||||||
kv_dbw_t *db = NULL;
|
kv_dbw_t *db = NULL;
|
||||||
|
@ -157,7 +156,7 @@ void kv_cli_t::run()
|
||||||
if (cfg.find("db") != cfg.end())
|
if (cfg.find("db") != cfg.end())
|
||||||
{
|
{
|
||||||
bool done = false;
|
bool done = false;
|
||||||
handle_cmd({ "open", cfg.at("db") }, [&done](int res) { if (res != 0) exit(1); done = true; });
|
handle_cmd({ "open", cfg.at("db").string_value() }, [&done](int res) { if (res != 0) exit(1); done = true; });
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
ringloop->loop();
|
ringloop->loop();
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "cluster_client.h"
|
#include "cluster_client.h"
|
||||||
#include "str_util.h"
|
#include "str_util.h"
|
||||||
#include "vitastor_kv.h"
|
#include "kv_db.h"
|
||||||
|
|
||||||
// 0x VITASTOR OPTBTREE
|
// 0x VITASTOR OPTBTREE
|
||||||
#define KV_BLOCK_MAGIC 0x761A5106097B18EE
|
#define KV_BLOCK_MAGIC 0x761A5106097B18EE
|
||||||
|
@ -1969,12 +1969,12 @@ kv_dbw_t::~kv_dbw_t()
|
||||||
delete db;
|
delete db;
|
||||||
}
|
}
|
||||||
|
|
||||||
void kv_dbw_t::open(uint64_t inode_id, std::map<std::string, std::string> cfg, std::function<void(int)> cb)
|
void kv_dbw_t::open(inode_t inode_id, json11::Json cfg, std::function<void(int)> cb)
|
||||||
{
|
{
|
||||||
db->open(inode_id, cfg, cb);
|
db->open(inode_id, cfg, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void kv_dbw_t::set_config(std::map<std::string, std::string> cfg)
|
void kv_dbw_t::set_config(json11::Json cfg)
|
||||||
{
|
{
|
||||||
db->set_config(cfg);
|
db->set_config(cfg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,27 +6,17 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include "cluster_client.h"
|
||||||
#include <sys/uio.h>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
#define VITASTOR_KV_API_VERSION 1
|
|
||||||
|
|
||||||
class cluster_client_t;
|
|
||||||
|
|
||||||
struct kv_db_t;
|
struct kv_db_t;
|
||||||
|
|
||||||
struct kv_dbw_t
|
struct kv_dbw_t
|
||||||
{
|
{
|
||||||
// cli = vitastor_c_get_internal_client(client)
|
|
||||||
kv_dbw_t(cluster_client_t *cli);
|
kv_dbw_t(cluster_client_t *cli);
|
||||||
~kv_dbw_t();
|
~kv_dbw_t();
|
||||||
|
|
||||||
void open(uint64_t inode_id, std::map<std::string, std::string> cfg, std::function<void(int)> cb);
|
void open(inode_t inode_id, json11::Json cfg, std::function<void(int)> cb);
|
||||||
void set_config(std::map<std::string, std::string> cfg);
|
void set_config(json11::Json cfg);
|
||||||
void close(std::function<void()> cb);
|
void close(std::function<void()> cb);
|
||||||
|
|
||||||
uint64_t get_size();
|
uint64_t get_size();
|
|
@ -12,10 +12,9 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
//#include <signal.h>
|
//#include <signal.h>
|
||||||
|
|
||||||
#include "cluster_client.h"
|
|
||||||
#include "epoll_manager.h"
|
#include "epoll_manager.h"
|
||||||
#include "str_util.h"
|
#include "str_util.h"
|
||||||
#include "vitastor_kv.h"
|
#include "kv_db.h"
|
||||||
|
|
||||||
const char *exe_name = NULL;
|
const char *exe_name = NULL;
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ class kv_test_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Config
|
// Config
|
||||||
std::map<std::string, std::string> kv_cfg;
|
json11::Json::object kv_cfg;
|
||||||
std::string key_prefix, key_suffix;
|
std::string key_prefix, key_suffix;
|
||||||
uint64_t inode_id = 0;
|
uint64_t inode_id = 0;
|
||||||
uint64_t op_count = 1000000;
|
uint64_t op_count = 1000000;
|
||||||
|
@ -239,22 +238,22 @@ void kv_test_t::parse_config(json11::Json cfg)
|
||||||
if (!cfg["stop_on_error"].is_null())
|
if (!cfg["stop_on_error"].is_null())
|
||||||
stop_on_error = cfg["stop_on_error"].bool_value();
|
stop_on_error = cfg["stop_on_error"].bool_value();
|
||||||
if (!cfg["kv_block_size"].is_null())
|
if (!cfg["kv_block_size"].is_null())
|
||||||
kv_cfg["kv_block_size"] = cfg["kv_block_size"].as_string();
|
kv_cfg["kv_block_size"] = cfg["kv_block_size"];
|
||||||
if (!cfg["kv_memory_limit"].is_null())
|
if (!cfg["kv_memory_limit"].is_null())
|
||||||
kv_cfg["kv_memory_limit"] = cfg["kv_memory_limit"].as_string();
|
kv_cfg["kv_memory_limit"] = cfg["kv_memory_limit"];
|
||||||
if (!cfg["kv_allocate_blocks"].is_null())
|
if (!cfg["kv_allocate_blocks"].is_null())
|
||||||
kv_cfg["kv_allocate_blocks"] = cfg["kv_allocate_blocks"].as_string();
|
kv_cfg["kv_allocate_blocks"] = cfg["kv_allocate_blocks"];
|
||||||
if (!cfg["kv_evict_max_misses"].is_null())
|
if (!cfg["kv_evict_max_misses"].is_null())
|
||||||
kv_cfg["kv_evict_max_misses"] = cfg["kv_evict_max_misses"].as_string();
|
kv_cfg["kv_evict_max_misses"] = cfg["kv_evict_max_misses"];
|
||||||
if (!cfg["kv_evict_attempts_per_level"].is_null())
|
if (!cfg["kv_evict_attempts_per_level"].is_null())
|
||||||
kv_cfg["kv_evict_attempts_per_level"] = cfg["kv_evict_attempts_per_level"].as_string();
|
kv_cfg["kv_evict_attempts_per_level"] = cfg["kv_evict_attempts_per_level"];
|
||||||
if (!cfg["kv_evict_unused_age"].is_null())
|
if (!cfg["kv_evict_unused_age"].is_null())
|
||||||
kv_cfg["kv_evict_unused_age"] = cfg["kv_evict_unused_age"].as_string();
|
kv_cfg["kv_evict_unused_age"] = cfg["kv_evict_unused_age"];
|
||||||
if (!cfg["kv_log_level"].is_null())
|
if (!cfg["kv_log_level"].is_null())
|
||||||
{
|
{
|
||||||
log_level = cfg["kv_log_level"].uint64_value();
|
log_level = cfg["kv_log_level"].uint64_value();
|
||||||
trace = log_level >= 10;
|
trace = log_level >= 10;
|
||||||
kv_cfg["kv_log_level"] = std::to_string(log_level);
|
kv_cfg["kv_log_level"] = cfg["kv_log_level"];
|
||||||
}
|
}
|
||||||
total_prob = reopen_prob+get_prob+add_prob+update_prob+del_prob+list_prob;
|
total_prob = reopen_prob+get_prob+add_prob+update_prob+del_prob+list_prob;
|
||||||
stat.get.name = "get";
|
stat.get.name = "get";
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
// License: VNPL-1.1 (see README.md for details)
|
// License: VNPL-1.1 (see README.md for details)
|
||||||
//
|
//
|
||||||
// NFS proxy over Vitastor block images
|
// NFS proxy over Vitastor block images
|
||||||
// Presents all images as files
|
|
||||||
// Keeps image/file list in memory and is thus unsuitable for a large number of files
|
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
// License: VNPL-1.1 (see README.md for details)
|
// License: VNPL-1.1 (see README.md for details)
|
||||||
//
|
//
|
||||||
// NFS proxy over Vitastor block images - header
|
// NFS proxy over Vitastor block images - header
|
||||||
// Presents all images as files
|
|
||||||
// Keeps image/file list in memory and is thus unsuitable for a large number of files
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
|
@ -256,12 +256,7 @@ void kv_fs_state_t::init(nfs_proxy_t *proxy, json11::Json cfg)
|
||||||
int open_res = 0;
|
int open_res = 0;
|
||||||
bool open_done = false;
|
bool open_done = false;
|
||||||
proxy->db = new kv_dbw_t(proxy->cli);
|
proxy->db = new kv_dbw_t(proxy->cli);
|
||||||
std::map<std::string, std::string> kv_cfg;
|
proxy->db->open(fs_kv_inode, cfg, [&](int res)
|
||||||
for (auto & kv: cfg.object_items())
|
|
||||||
{
|
|
||||||
kv_cfg[kv.first] = kv.second.as_string();
|
|
||||||
}
|
|
||||||
proxy->db->open(fs_kv_inode, kv_cfg, [&](int res)
|
|
||||||
{
|
{
|
||||||
open_done = true;
|
open_done = true;
|
||||||
open_res = res;
|
open_res = res;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
// Copyright (c) Vitaliy Filippov, 2019+
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
// License: VNPL-1.1 (see README.md for details)
|
// License: VNPL-1.1 (see README.md for details)
|
||||||
//
|
//
|
||||||
// NFS proxy entrypoint, common for both pseudo-FS and Vitastor-KV based FS
|
// Simplified NFS proxy
|
||||||
|
// Presents all images as files
|
||||||
|
// Keeps image/file list in memory and is thus unsuitable for a large number of files
|
||||||
|
|
||||||
#define _XOPEN_SOURCE
|
#define _XOPEN_SOURCE
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
// Copyright (c) Vitaliy Filippov, 2019+
|
|
||||||
// License: VNPL-1.1 (see README.md for details)
|
|
||||||
//
|
|
||||||
// Simplified NFS proxy - main entrypoint header
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cluster_client.h"
|
#include "cluster_client.h"
|
||||||
#include "epoll_manager.h"
|
#include "epoll_manager.h"
|
||||||
#include "nfs_portmap.h"
|
#include "nfs_portmap.h"
|
||||||
#include "nfs/xdr_impl.h"
|
#include "nfs/xdr_impl.h"
|
||||||
#include "vitastor_kv.h"
|
#include "kv_db.h"
|
||||||
|
|
||||||
#define NFS_ROOT_HANDLE "R"
|
#define NFS_ROOT_HANDLE "R"
|
||||||
#define RPC_INIT_BUF_SIZE 32768
|
#define RPC_INIT_BUF_SIZE 32768
|
||||||
|
|
|
@ -200,11 +200,6 @@ vitastor_c *vitastor_c_create_epoll_json(const char **options, int options_len)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* vitastor_c_get_internal_client(vitastor_c *client)
|
|
||||||
{
|
|
||||||
return client->cli;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vitastor_c_destroy(vitastor_c *client)
|
void vitastor_c_destroy(vitastor_c *client)
|
||||||
{
|
{
|
||||||
delete client->cli;
|
delete client->cli;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#define VITASTOR_QEMU_PROXY_H
|
#define VITASTOR_QEMU_PROXY_H
|
||||||
|
|
||||||
// C API wrapper version
|
// C API wrapper version
|
||||||
#define VITASTOR_C_API_VERSION 4
|
#define VITASTOR_C_API_VERSION 3
|
||||||
|
|
||||||
#ifndef POOL_ID_BITS
|
#ifndef POOL_ID_BITS
|
||||||
#define POOL_ID_BITS 16
|
#define POOL_ID_BITS 16
|
||||||
|
@ -41,7 +41,6 @@ vitastor_c *vitastor_c_create_uring(const char *config_path, const char *etcd_ho
|
||||||
int use_rdma, const char *rdma_device, int rdma_port_num, int rdma_gid_index, int rdma_mtu, int log_level);
|
int use_rdma, const char *rdma_device, int rdma_port_num, int rdma_gid_index, int rdma_mtu, int log_level);
|
||||||
vitastor_c *vitastor_c_create_uring_json(const char **options, int options_len);
|
vitastor_c *vitastor_c_create_uring_json(const char **options, int options_len);
|
||||||
vitastor_c *vitastor_c_create_epoll_json(const char **options, int options_len);
|
vitastor_c *vitastor_c_create_epoll_json(const char **options, int options_len);
|
||||||
void* vitastor_c_get_internal_client(vitastor_c *client);
|
|
||||||
void vitastor_c_destroy(vitastor_c *client);
|
void vitastor_c_destroy(vitastor_c *client);
|
||||||
int vitastor_c_is_ready(vitastor_c *client);
|
int vitastor_c_is_ready(vitastor_c *client);
|
||||||
int vitastor_c_uring_register_eventfd(vitastor_c *client);
|
int vitastor_c_uring_register_eventfd(vitastor_c *client);
|
||||||
|
|
Loading…
Reference in New Issue