diff --git a/src/librmb/rados-cluster.cpp b/src/librmb/rados-cluster.cpp index 3bff0342..8d289b91 100644 --- a/src/librmb/rados-cluster.cpp +++ b/src/librmb/rados-cluster.cpp @@ -16,6 +16,7 @@ using namespace librmb; // NOLINT librados::Rados RadosCluster::cluster; int RadosCluster::cluster_ref_count = 0; +const std::string RadosCluster::CFG_OSD_MAX_WRITE_SIZE = "osd_max_write_size"; RadosCluster::RadosCluster() {} @@ -108,6 +109,8 @@ int RadosCluster::storage_create(const string &pool, const string &username, Rad break; } } + + if (pool_found != true) { err = cluster.pool_create(pool.c_str()); if (err < 0) { @@ -122,6 +125,15 @@ int RadosCluster::storage_create(const string &pool, const string &username, Rad return err; } - *storage = new RadosStorage(&io_ctx, username); + std::string max_write_size; + err = cluster.conf_get(RadosCluster::CFG_OSD_MAX_WRITE_SIZE.c_str(), max_write_size); + if (err < 0) { + // *error_r = t_strdup_printf("Cannot open RADOS pool %s: %s", pool.c_str(), strerror(-err)); + return err; + } + + //"found: max write size " << max_write_size.c_str() << "\n"; + + *storage = new RadosStorage(&io_ctx, username, std::stoi(max_write_size)); return 0; } diff --git a/src/librmb/rados-cluster.h b/src/librmb/rados-cluster.h index 0b4acb91..8e441f28 100644 --- a/src/librmb/rados-cluster.h +++ b/src/librmb/rados-cluster.h @@ -27,6 +27,9 @@ class RadosCluster { private: static librados::Rados cluster; static int cluster_ref_count; + + public: + static const std::string CFG_OSD_MAX_WRITE_SIZE; }; } // namespace librmb diff --git a/src/librmb/rados-storage.cpp b/src/librmb/rados-storage.cpp index 22ff857a..8c5f08d2 100644 --- a/src/librmb/rados-storage.cpp +++ b/src/librmb/rados-storage.cpp @@ -13,7 +13,7 @@ using std::string; #define DICT_USERNAME_SEPARATOR '/' -RadosStorage::RadosStorage(librados::IoCtx *ctx, const string &username) : io_ctx(*ctx), username(username) { -} +RadosStorage::RadosStorage(librados::IoCtx *ctx, const string &username, const int max_write_size) + : io_ctx(*ctx), username(username), max_write_size(max_write_size) {} RadosStorage::~RadosStorage() { get_io_ctx().close(); } diff --git a/src/librmb/rados-storage.h b/src/librmb/rados-storage.h index cae0e704..150730c3 100644 --- a/src/librmb/rados-storage.h +++ b/src/librmb/rados-storage.h @@ -13,16 +13,19 @@ namespace librmb { class RadosStorage { public: - RadosStorage(librados::IoCtx* ctx, const std::string& username); + RadosStorage(librados::IoCtx* ctx, const std::string& username, const int max_write_size); virtual ~RadosStorage(); librados::IoCtx& get_io_ctx() { return io_ctx; } const std::string& get_username() const { return username; } + const int get_max_write_size() const { return max_write_size; } + private: librados::IoCtx io_ctx; std::string username; + int max_write_size; }; } // namespace librmb