From 7a589d40b8131109f0ab203710b38b9b15c6b209 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Tue, 18 Sep 2018 14:58:21 +0200 Subject: [PATCH] Add a 'tracked' field to namespaces Clients can now provide a 'track' flag when defining a namespace to let urd know that it must keep track of the namespace contents. The flag is currently propagated by the messaging system and stored in the internal backend metadata. Tracking not implemented yet. --- .gitlab-ci.yml | 6 +---- include/norns/nornsctl.h | 10 ++++--- lib/libnornsctl.c | 16 +++++++---- lib/requests.c | 1 + rpc/messages.proto | 5 ++-- src/api/request.cpp | 18 ++++++++----- src/api/request.hpp | 2 ++ src/backends/backend-base.cpp | 43 ++++++++++++++++-------------- src/backends/backend-base.hpp | 8 ++++-- src/backends/lustre-fs.cpp | 11 ++++++-- src/backends/lustre-fs.hpp | 6 +++-- src/backends/nvml-dax.cpp | 11 ++++++-- src/backends/nvml-dax.hpp | 8 +++--- src/backends/posix-fs.cpp | 12 +++++++-- src/backends/posix-fs.hpp | 4 ++- src/backends/process-memory.cpp | 6 +++++ src/backends/process-memory.hpp | 1 + src/backends/remote-backend.cpp | 5 ++++ src/backends/remote-backend.hpp | 1 + src/config/config-schema.hpp | 4 +++ src/config/keywords.hpp | 1 + src/config/settings.cpp | 1 + src/config/settings.hpp | 12 ++++++--- src/urd.cpp | 43 +++++++++++++++++------------- src/urd.hpp | 3 ++- tests/api-namespace-register.cpp | 18 ++++++------- tests/api-namespace-unregister.cpp | 2 +- tests/test-env.cpp | 2 +- 28 files changed, 172 insertions(+), 88 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6d7b6e8..9281846 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -135,7 +135,7 @@ test:ubuntu:latest: - make -j4 core - ./core -as - make -j4 api - - NORNS_DEBUG_OUTPUT_TO_STDERR=1 NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api +# - NORNS_DEBUG_OUTPUT_TO_STDERR=1 NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api - NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api -as "[api::nornsctl_register_namespace]" - NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api -as "[api::nornsctl_unregister_namespace]" - NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api -as "[api::norns_submit_copy_local_posix_files]" @@ -148,10 +148,6 @@ test:ubuntu:latest: - NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api -as "[api::norns_resource_init]" - NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api -as "[api::norns_iotask_init]" - NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api -as "[api::NORNS_TASK]" -## - valgrind -## --leak-check=full -## -v -## env NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 - NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api -as "[api::norns_submit]" - NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api -as "[api::norns_status]" - NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api -as "[api::nornsctl_status]" diff --git a/include/norns/nornsctl.h b/include/norns/nornsctl.h index 2d4bb87..552ff97 100644 --- a/include/norns/nornsctl.h +++ b/include/norns/nornsctl.h @@ -33,6 +33,7 @@ #endif #include +#include #include "nornsctl_types.h" #include "norns_error.h" @@ -53,6 +54,7 @@ extern "C" { /* Descriptor for a storage namespace */ typedef struct { int b_type; /* namespace type */ + bool b_track; /* should the service track its contents? */ const char* b_mount; /* mount point */ uint32_t b_capacity; /* namespace capacity (in megabytes) for writing data */ } nornsctl_backend_t; @@ -89,13 +91,15 @@ typedef struct { nornsctl_backend_t NORNSCTL_BACKEND(nornsctl_backend_flags_t flags, + bool track, const char* mount_point, uint32_t capacity) __THROW; void -nornsctl_backend_init(nornsctl_backend_t* backend, - nornsctl_backend_flags_t flags, - const char* mount_point, +nornsctl_backend_init(nornsctl_backend_t* backend, + nornsctl_backend_flags_t flags, + bool track, + const char* mount_point, uint32_t capacity) __THROW; nornsctl_job_limit_t diff --git a/lib/libnornsctl.c b/lib/libnornsctl.c index cccbbc9..d2bd5e1 100644 --- a/lib/libnornsctl.c +++ b/lib/libnornsctl.c @@ -251,25 +251,31 @@ nornsctl_unregister_namespace(const char* nsid) { } nornsctl_backend_t -NORNSCTL_BACKEND(norns_flags_t flags, const char* mount_point, - uint32_t capacity) { +NORNSCTL_BACKEND(norns_flags_t flags, + bool track, + const char* mount_point, + uint32_t capacity) { nornsctl_backend_t b; - nornsctl_backend_init(&b, flags, mount_point, capacity); + nornsctl_backend_init(&b, flags, track, mount_point, capacity); return b; } void -nornsctl_backend_init(nornsctl_backend_t* backend, norns_flags_t flags, - const char* mount_point, uint32_t capacity) { +nornsctl_backend_init(nornsctl_backend_t* backend, + norns_flags_t flags, + bool track, + const char* mount_point, + uint32_t capacity) { if(backend == NULL) { return; } backend->b_type = flags; + backend->b_track = track; backend->b_mount = mount_point; backend->b_capacity = capacity; } diff --git a/lib/requests.c b/lib/requests.c index 65e9220..3085178 100644 --- a/lib/requests.c +++ b/lib/requests.c @@ -389,6 +389,7 @@ build_backend_message(const nornsctl_backend_t* backend) { norns__rpc__request__namespace__backend__init(backendmsg); backendmsg->type = backend->b_type; + backendmsg->track = backend->b_track; // n_mount might be NULL for some namespaces // (e.g. NORNS_NS_PROCESS_MEMORY) diff --git a/rpc/messages.proto b/rpc/messages.proto index f0b93da..2d754c6 100644 --- a/rpc/messages.proto +++ b/rpc/messages.proto @@ -68,8 +68,9 @@ message Request { // backend descriptor message Backend { required int32 type = 1; - required string mount = 2; - required int32 capacity = 3; + required bool track = 2; + required string mount = 3; + required int32 capacity = 4; } required string nsid = 1; diff --git a/src/api/request.cpp b/src/api/request.cpp index 49ed912..ead5918 100644 --- a/src/api/request.cpp +++ b/src/api/request.cpp @@ -360,13 +360,15 @@ request_ptr request::create_from_buffer(const std::vector& buffer, int if(rpc_req.type() == norns::rpc::Request::NAMESPACE_REGISTER) { return std::make_unique(nspace.nsid(), type, + b.track(), b.mount(), b.capacity()); } else { // rpc_req.type() == norns::rpc::Request::NAMESPACE_UPDATE return std::make_unique(nspace.nsid(), - type, - b.mount(), + type, + b.track(), + b.mount(), b.capacity()); } } @@ -514,8 +516,9 @@ std::string backend_register_request::to_string() const { const auto& nsid = this->get<0>(); const auto& type = this->get<1>(); - const auto& mount = this->get<2>(); - const auto& quota = this->get<3>(); + const auto& track = this->get<2>(); + const auto& mount = this->get<3>(); + const auto& quota = this->get<4>(); #if 0 // verbose return "nsid: \"" + nsid + "\", " @@ -525,6 +528,7 @@ std::string backend_register_request::to_string() const { #else return "\"" + nsid + "\", " + utils::to_string(type) + ", " + + (track ? "tracked" : "untracked") + ", " + (mount != "" ? "\"" + mount + "\", " : "") + (quota != 0 ? std::to_string(quota) : "unlimited"); #endif @@ -535,8 +539,9 @@ std::string backend_update_request::to_string() const { const auto& nsid = this->get<0>(); const auto& type = this->get<1>(); - const auto& mount = this->get<2>(); - const auto& quota = this->get<3>(); + const auto& track = this->get<2>(); + const auto& mount = this->get<3>(); + const auto& quota = this->get<4>(); #if 0 // verbose return "nsid: \"" + nsid + "\", " @@ -546,6 +551,7 @@ std::string backend_update_request::to_string() const { #else return "\"" + nsid + "\", " + utils::to_string(type) + ", " + + (track ? "tracked" : "untracked") + ", " + (mount != "" ? "\"" + mount + "\", " : "") + (quota != 0 ? std::to_string(quota) : "unlimited"); #endif diff --git a/src/api/request.hpp b/src/api/request.hpp index bc067fc..e60b830 100644 --- a/src/api/request.hpp +++ b/src/api/request.hpp @@ -239,6 +239,7 @@ using backend_register_request = detail::request_impl< request_type::backend_register, std::string, // nsid backend_type, // type + bool, // track?, std::string, // mount int32_t // quota >; @@ -247,6 +248,7 @@ using backend_update_request = detail::request_impl< request_type::backend_update, std::string, // nsid backend_type, // type + bool, // track?, std::string, // mount int32_t // quota >; diff --git a/src/backends/backend-base.cpp b/src/backends/backend-base.cpp index 4c44a78..88b7d1a 100644 --- a/src/backends/backend-base.cpp +++ b/src/backends/backend-base.cpp @@ -34,33 +34,36 @@ namespace bfs = boost::filesystem; namespace norns { namespace storage { - backend_factory& backend_factory::get() { - static backend_factory _; - return _; - } +backend_factory& +backend_factory::get() { + static backend_factory _; + return _; +} - std::shared_ptr backend_factory::create(const backend_type type, const bfs::path& mount, uint32_t quota) const { +std::shared_ptr +backend_factory::create(const backend_type type, bool track, + const bfs::path& mount, uint32_t quota) const { - boost::system::error_code ec; + boost::system::error_code ec; - bfs::path canonical_mount = bfs::canonical(mount, ec); + bfs::path canonical_mount = bfs::canonical(mount, ec); - if(ec) { - LOGGER_ERROR("Invalid mount point: {}", ec.message()); - throw std::invalid_argument(""); - } + if(ec) { + LOGGER_ERROR("Invalid mount point: {}", ec.message()); + throw std::invalid_argument(""); + } - const int32_t id = static_cast(type); + const int32_t id = static_cast(type); - const auto& it = m_registrar.find(id); + const auto& it = m_registrar.find(id); - if(it != m_registrar.end()){ - return std::shared_ptr(it->second(canonical_mount, quota)); - } - else{ - throw std::invalid_argument("Unrecognized backend type!"); - } - }; + if(it != m_registrar.end()){ + return std::shared_ptr(it->second(track, canonical_mount, quota)); + } + else{ + throw std::invalid_argument("Unrecognized backend type!"); + } +} } // namespace storage } // namespace norns diff --git a/src/backends/backend-base.hpp b/src/backends/backend-base.hpp index 3e5395f..b6a2ab7 100644 --- a/src/backends/backend-base.hpp +++ b/src/backends/backend-base.hpp @@ -59,6 +59,7 @@ protected: public: virtual ~backend() {}; + virtual bool is_tracked() const = 0; virtual bfs::path mount() const = 0; virtual uint32_t quota() const = 0; @@ -83,7 +84,8 @@ public: class backend_factory { - using creator_function = std::function(const bfs::path&, uint32_t)>; + using creator_function = std::function< + std::shared_ptr(bool track, const bfs::path&, uint32_t)>; public: @@ -136,7 +138,9 @@ public: } private: - std::shared_ptr create(const backend_type type, const bfs::path& mount, uint32_t quota) const; + std::shared_ptr + create(const backend_type type, bool track, const bfs::path& mount, + uint32_t quota) const; protected: backend_factory() {} diff --git a/src/backends/lustre-fs.cpp b/src/backends/lustre-fs.cpp index ad149f8..97e5554 100644 --- a/src/backends/lustre-fs.cpp +++ b/src/backends/lustre-fs.cpp @@ -33,8 +33,15 @@ namespace norns { namespace storage { -lustre::lustre(const bfs::path& mount, uint32_t quota) - : m_mount(mount), m_quota(quota) { } +lustre::lustre(bool track, const bfs::path& mount, uint32_t quota) + : m_track(track), + m_mount(mount), + m_quota(quota) { } + +bool +lustre::is_tracked() const { + return m_track; +} bfs::path lustre::mount() const { return m_mount; diff --git a/src/backends/lustre-fs.hpp b/src/backends/lustre-fs.hpp index ff9b91a..2c0b7c3 100644 --- a/src/backends/lustre-fs.hpp +++ b/src/backends/lustre-fs.hpp @@ -41,8 +41,9 @@ namespace storage { class lustre final : public storage::backend { public: - lustre(const bfs::path& mount, uint32_t quota); + lustre(bool track, const bfs::path& mount, uint32_t quota); + bool is_tracked() const override final; bfs::path mount() const override final; uint32_t quota() const override final; @@ -55,8 +56,9 @@ public: std::string to_string() const override final; protected: + bool m_track; bfs::path m_mount; - uint32_t m_quota; + uint32_t m_quota; }; //NORNS_REGISTER_BACKEND(backend_type::lustre, lustre); diff --git a/src/backends/nvml-dax.cpp b/src/backends/nvml-dax.cpp index 43ed839..461bcf8 100644 --- a/src/backends/nvml-dax.cpp +++ b/src/backends/nvml-dax.cpp @@ -33,8 +33,15 @@ namespace norns { namespace storage { -nvml_dax::nvml_dax(const bfs::path& mount, uint32_t quota) - : m_mount(mount), m_quota(quota) { } +nvml_dax::nvml_dax(bool track, const bfs::path& mount, uint32_t quota) + : m_track(track), + m_mount(mount), + m_quota(quota) { } + +bool +nvml_dax::is_tracked() const { + return m_track; +} bfs::path nvml_dax::mount() const { return m_mount; diff --git a/src/backends/nvml-dax.hpp b/src/backends/nvml-dax.hpp index 89ba863..6ccf3cd 100644 --- a/src/backends/nvml-dax.hpp +++ b/src/backends/nvml-dax.hpp @@ -40,10 +40,11 @@ namespace storage { class nvml_dax final : public storage::backend { public: - nvml_dax(const bfs::path& mount, uint32_t quota); + nvml_dax(bool track, const bfs::path& mount, uint32_t quota); - bfs::path mount() const override; - uint32_t quota() const override; + bool is_tracked() const override final; + bfs::path mount() const override final; + uint32_t quota() const override final; resource_ptr new_resource(const resource_info_ptr& rinfo, bool is_collection, std::error_code& ec) const override final; resource_ptr get_resource(const resource_info_ptr& rinfo, std::error_code& ec) const override final; @@ -54,6 +55,7 @@ public: std::string to_string() const final; private: + bool m_track; bfs::path m_mount; uint32_t m_quota; }; diff --git a/src/backends/posix-fs.cpp b/src/backends/posix-fs.cpp index d1427c9..6e105d3 100644 --- a/src/backends/posix-fs.cpp +++ b/src/backends/posix-fs.cpp @@ -55,8 +55,16 @@ bool contains(const bfs::path& p1, const bfs::path& p2) { namespace norns { namespace storage { -posix_filesystem::posix_filesystem(const bfs::path& mount, uint32_t quota) - : m_mount(mount), m_quota(quota) { } +posix_filesystem::posix_filesystem(bool track, const bfs::path& mount, + uint32_t quota) + : m_track(track), + m_mount(mount), + m_quota(quota) { } + +bool +posix_filesystem::is_tracked() const { + return m_track; +} bfs::path posix_filesystem::mount() const { return m_mount; diff --git a/src/backends/posix-fs.hpp b/src/backends/posix-fs.hpp index 1130095..fe0ea48 100644 --- a/src/backends/posix-fs.hpp +++ b/src/backends/posix-fs.hpp @@ -41,8 +41,9 @@ namespace storage { class posix_filesystem final : public storage::backend { public: - posix_filesystem(const bfs::path& mount, uint32_t quota); + posix_filesystem(bool track, const bfs::path& mount, uint32_t quota); + bool is_tracked() const override final; bfs::path mount() const override final; uint32_t quota() const override final; @@ -55,6 +56,7 @@ public: std::string to_string() const override final; private: + bool m_track; bfs::path m_mount; uint32_t m_quota; }; diff --git a/src/backends/process-memory.cpp b/src/backends/process-memory.cpp index 0a39f5e..2ad5c89 100644 --- a/src/backends/process-memory.cpp +++ b/src/backends/process-memory.cpp @@ -35,6 +35,12 @@ namespace detail { process_memory::process_memory() { } +bool +process_memory::is_tracked() const { + return false; +} + + bfs::path process_memory::mount() const { return ""; } diff --git a/src/backends/process-memory.hpp b/src/backends/process-memory.hpp index 4b46cd9..cd08a8b 100644 --- a/src/backends/process-memory.hpp +++ b/src/backends/process-memory.hpp @@ -44,6 +44,7 @@ class process_memory final : public storage::backend { public: process_memory(); + bool is_tracked() const override final; bfs::path mount() const override final; uint32_t quota() const override final; diff --git a/src/backends/remote-backend.cpp b/src/backends/remote-backend.cpp index 486249c..e5d11ac 100644 --- a/src/backends/remote-backend.cpp +++ b/src/backends/remote-backend.cpp @@ -35,6 +35,11 @@ namespace detail { remote_backend::remote_backend() {} +bool +remote_backend::is_tracked() const { + return false; +} + bfs::path remote_backend::mount() const { return ""; } diff --git a/src/backends/remote-backend.hpp b/src/backends/remote-backend.hpp index 769f862..1f4e52b 100644 --- a/src/backends/remote-backend.hpp +++ b/src/backends/remote-backend.hpp @@ -43,6 +43,7 @@ class remote_backend final : public storage::backend { public: remote_backend(); + bool is_tracked() const override final; bfs::path mount() const override final; uint32_t quota() const override final; diff --git a/src/config/config-schema.hpp b/src/config/config-schema.hpp index 48d6481..81bfb68 100644 --- a/src/config/config-schema.hpp +++ b/src/config/config-schema.hpp @@ -109,6 +109,10 @@ const file_schema valid_options = declare_file({ declare_option( keywords::nsid, opt_type::mandatory), + declare_option( + keywords::track_contents, + opt_type::mandatory, + converter(parsers::parse_bool)), declare_option( keywords::mountpoint, opt_type::mandatory, diff --git a/src/config/keywords.hpp b/src/config/keywords.hpp index cc019d5..e5bf86b 100644 --- a/src/config/keywords.hpp +++ b/src/config/keywords.hpp @@ -54,6 +54,7 @@ constexpr static const auto workers = "workers"; // option names for 'namespaces' section constexpr static const auto nsid = "nsid"; +constexpr static const auto track_contents = "track_contents"; constexpr static const auto mountpoint = "mountpoint"; constexpr static const auto type = "type"; constexpr static const auto capacity = "capacity"; diff --git a/src/config/settings.cpp b/src/config/settings.cpp index 684f4ea..a7af16a 100644 --- a/src/config/settings.cpp +++ b/src/config/settings.cpp @@ -120,6 +120,7 @@ void settings::load_from_file(const bfs::path& filename) { for(const auto& nsdef : namespaces) { m_default_namespaces.emplace_back( nsdef.get_as(keywords::nsid), + nsdef.get_as(keywords::track_contents), nsdef.get_as(keywords::mountpoint), nsdef.get_as(keywords::type), nsdef.get_as(keywords::capacity), diff --git a/src/config/settings.hpp b/src/config/settings.hpp index f0dc5c7..955dc50 100644 --- a/src/config/settings.hpp +++ b/src/config/settings.hpp @@ -39,10 +39,11 @@ namespace config { struct namespace_def { - namespace_def(const std::string& nsid, const bfs::path& mountpoint, - const std::string& alias, const uint64_t capacity, - const std::string& visibility) : + namespace_def(const std::string& nsid, bool track, + const bfs::path& mountpoint, const std::string& alias, + const uint64_t capacity, const std::string& visibility) : m_nsid(nsid), + m_track(track), m_mountpoint(mountpoint), m_alias(alias), m_capacity(capacity), @@ -52,6 +53,10 @@ struct namespace_def { return m_nsid; } + bool track() const { + return m_track; + } + bfs::path mountpoint() const { return m_mountpoint; } @@ -69,6 +74,7 @@ struct namespace_def { } const std::string m_nsid; + const bool m_track; const bfs::path m_mountpoint; const std::string m_alias; const uint64_t m_capacity; diff --git a/src/urd.cpp b/src/urd.cpp index 40d9a9d..ce59755 100644 --- a/src/urd.cpp +++ b/src/urd.cpp @@ -480,12 +480,13 @@ urd_error urd::create_namespace(const config::namespace_def& nsdef) { return urd_error::bad_args; } - return create_namespace(nsdef.nsid(), type, nsdef.mountpoint(), - nsdef.capacity()); + return create_namespace(nsdef.nsid(), type, nsdef.track(), + nsdef.mountpoint(), nsdef.capacity()); } urd_error urd::create_namespace(const std::string& nsid, backend_type type, - const bfs::path& mount, uint32_t quota) { + bool track, const bfs::path& mount, + uint32_t quota) { boost::unique_lock lock(m_namespace_mgr_mutex); @@ -493,7 +494,8 @@ urd_error urd::create_namespace(const std::string& nsid, backend_type type, return urd_error::namespace_exists; } - if(auto bptr = storage::backend_factory::create_from(type, mount, quota)) { + if(auto bptr = storage::backend_factory::create_from( + type, track, mount, quota)) { m_namespace_mgr->add(nsid, bptr); return urd_error::success; } @@ -510,10 +512,11 @@ response_ptr urd::namespace_register_handler(const request_ptr base_request) { std::string nsid = request->get<0>(); backend_type type = request->get<1>(); - std::string mount = request->get<2>(); - int32_t quota = request->get<3>(); + bool track = request->get<2>(); + std::string mount = request->get<3>(); + int32_t quota = request->get<4>(); - resp->set_error_code(create_namespace(nsid, type, mount, quota)); + resp->set_error_code(create_namespace(nsid, type, track, mount, quota)); LOGGER_INFO("REGISTER_NAMESPACE({}) = {}", request->to_string(), resp->to_string()); return resp; @@ -851,10 +854,11 @@ void urd::load_backend_plugins() { // register POSIX filesystem backend plugin storage::backend_factory::get(). - register_backend(backend_type::posix_filesystem, - [](const bfs::path& mount, uint32_t quota) { + register_backend( + backend_type::posix_filesystem, + [](bool track, const bfs::path& mount, uint32_t quota) { return std::shared_ptr( - new storage::posix_filesystem(mount, quota)); + new storage::posix_filesystem(track, mount, quota)); }); storage::backend_factory::get(). @@ -864,10 +868,11 @@ void urd::load_backend_plugins() { // register NVML-DAX filesystem backend plugin storage::backend_factory::get(). - register_backend(backend_type::nvml, - [](const bfs::path& mount, uint32_t quota) { + register_backend( + backend_type::nvml, + [](bool track, const bfs::path& mount, uint32_t quota) { return std::shared_ptr( - new storage::nvml_dax(mount, quota)); + new storage::nvml_dax(track, mount, quota)); }); storage::backend_factory::get(). @@ -875,10 +880,11 @@ void urd::load_backend_plugins() { // register Lustre backend plugin storage::backend_factory::get(). - register_backend(backend_type::lustre, - [](const bfs::path& mount, uint32_t quota) { + register_backend( + backend_type::lustre, + [](bool track, const bfs::path& mount, uint32_t quota) { return std::shared_ptr( - new storage::lustre(mount, quota)); + new storage::lustre(track, mount, quota)); }); storage::backend_factory::get(). register_alias("Lustre", backend_type::lustre); @@ -967,8 +973,9 @@ void urd::load_default_namespaces() { nsdef.mountpoint(), nsdef.alias()); continue; } - LOGGER_INFO(" Loaded namespace \"{}://\" -> {} (type: {})", - nsdef.nsid(), nsdef.mountpoint(), nsdef.alias()); + LOGGER_INFO(" Loaded namespace \"{}://\" -> {} (type: {}, {})", + nsdef.nsid(), nsdef.mountpoint(), nsdef.alias(), + (nsdef.track() ? "tracked" : "untracked")); } } diff --git a/src/urd.hpp b/src/urd.hpp index 9880514..7bd997c 100644 --- a/src/urd.hpp +++ b/src/urd.hpp @@ -119,7 +119,8 @@ private: // TODO: add helpers for remove and update urd_error create_namespace(const config::namespace_def& nsdef); urd_error create_namespace(const std::string& nsid, backend_type type, - const bfs::path& mount, uint32_t quota); + bool track, const bfs::path& mount, + uint32_t quota); private: std::atomic m_is_paused; diff --git a/tests/api-namespace-register.cpp b/tests/api-namespace-register.cpp index 5a58960..1054aa4 100644 --- a/tests/api-namespace-register.cpp +++ b/tests/api-namespace-register.cpp @@ -49,7 +49,7 @@ SCENARIO("register namespace", "[api::nornsctl_register_namespace]") { WHEN("a namespace is registered with an invalid nsid") { nornsctl_backend_t b0 = - NORNSCTL_BACKEND(NORNS_BACKEND_NVML, path_b0.c_str(), 1024); + NORNSCTL_BACKEND(NORNS_BACKEND_NVML, false, path_b0.c_str(), 1024); int rv = nornsctl_register_namespace(NULL, &b0); @@ -61,7 +61,7 @@ SCENARIO("register namespace", "[api::nornsctl_register_namespace]") { WHEN("a namespace is registered with an invalid nsid") { nornsctl_backend_t b0 = - NORNSCTL_BACKEND(NORNS_BACKEND_NVML, path_b0.c_str(), 1024); + NORNSCTL_BACKEND(NORNS_BACKEND_NVML, false, path_b0.c_str(), 1024); int rv = nornsctl_register_namespace("", &b0); @@ -84,7 +84,7 @@ SCENARIO("register namespace", "[api::nornsctl_register_namespace]") { #endif WHEN("a namespace is registered with an invalid mount point") { - nornsctl_backend_t b0 = NORNSCTL_BACKEND(NORNS_BACKEND_NVML, "", 1024); + nornsctl_backend_t b0 = NORNSCTL_BACKEND(NORNS_BACKEND_NVML, false, "", 1024); int rv = nornsctl_register_namespace("b0://", &b0); @@ -94,7 +94,7 @@ SCENARIO("register namespace", "[api::nornsctl_register_namespace]") { } WHEN("a namespace is registered with an invalid mount point") { - nornsctl_backend_t b0 = NORNSCTL_BACKEND(NORNS_BACKEND_NVML, NULL, 1024); + nornsctl_backend_t b0 = NORNSCTL_BACKEND(NORNS_BACKEND_NVML, false, NULL, 1024); int rv = nornsctl_register_namespace("b0://", &b0); @@ -105,7 +105,7 @@ SCENARIO("register namespace", "[api::nornsctl_register_namespace]") { WHEN("a namespace is registered with an invalid quota") { nornsctl_backend_t b0 = - NORNSCTL_BACKEND(NORNS_BACKEND_NVML, path_b0.c_str(), 0); + NORNSCTL_BACKEND(NORNS_BACKEND_NVML, false, path_b0.c_str(), 0); int rv = nornsctl_register_namespace("b0://", &b0); @@ -116,7 +116,7 @@ SCENARIO("register namespace", "[api::nornsctl_register_namespace]") { WHEN("a namespace is registered with valid information") { nornsctl_backend_t b0 = - NORNSCTL_BACKEND(NORNS_BACKEND_NVML, path_b0.c_str(), 4096); + NORNSCTL_BACKEND(NORNS_BACKEND_NVML, false, path_b0.c_str(), 4096); int rv = nornsctl_register_namespace("b0://", &b0); @@ -127,9 +127,9 @@ SCENARIO("register namespace", "[api::nornsctl_register_namespace]") { WHEN("attempting to register a namespace with a duplicate nsid") { nornsctl_backend_t b0 = - NORNSCTL_BACKEND(NORNS_BACKEND_NVML, path_b0.c_str(), 4096); + NORNSCTL_BACKEND(NORNS_BACKEND_NVML, false, path_b0.c_str(), 4096); nornsctl_backend_t b1 = - NORNSCTL_BACKEND(NORNS_BACKEND_NVML, path_b1.c_str(), 4096); + NORNSCTL_BACKEND(NORNS_BACKEND_NVML, false, path_b1.c_str(), 4096); int rv = nornsctl_register_namespace("b0://", &b0); @@ -149,7 +149,7 @@ SCENARIO("register namespace", "[api::nornsctl_register_namespace]") { GIVEN("a non-running urd instance") { WHEN("attempting to register a namespace") { - nornsctl_backend_t b0 = NORNSCTL_BACKEND(NORNS_BACKEND_NVML, "mnt/foo", 1024); + nornsctl_backend_t b0 = NORNSCTL_BACKEND(NORNS_BACKEND_NVML, false, "mnt/foo", 1024); int rv = nornsctl_register_namespace("b0://", &b0); diff --git a/tests/api-namespace-unregister.cpp b/tests/api-namespace-unregister.cpp index 313f5a9..7379aa2 100644 --- a/tests/api-namespace-unregister.cpp +++ b/tests/api-namespace-unregister.cpp @@ -59,7 +59,7 @@ SCENARIO("unregister namespace", "[api::nornsctl_unregister_namespace]") { const char* nsid = "b0://"; nornsctl_backend_t b0 = - NORNSCTL_BACKEND(NORNS_BACKEND_NVML, path_b0.c_str(), 4096); + NORNSCTL_BACKEND(NORNS_BACKEND_NVML, false, path_b0.c_str(), 4096); int rv = nornsctl_register_namespace(nsid, &b0); diff --git a/tests/test-env.cpp b/tests/test-env.cpp index 4de2784..db5fa3f 100644 --- a/tests/test-env.cpp +++ b/tests/test-env.cpp @@ -189,7 +189,7 @@ test_env::create_namespace(const std::string& nsid, const bfs::path& mnt, auto abs_dir = create_directory(mnt, m_base_dir); nornsctl_backend_t ns = NORNSCTL_BACKEND(NORNS_BACKEND_POSIX_FILESYSTEM, - abs_dir.c_str(), quota); + false, abs_dir.c_str(), quota); norns_error_t rv = nornsctl_register_namespace(nsid.c_str(), &ns); REQUIRE(rv == NORNS_SUCCESS); -- GitLab