Loading include/daemon/ops/metadentry.hpp +13 −8 Original line number Diff line number Diff line Loading @@ -18,20 +18,25 @@ #include <daemon/main.hpp> #include <global/metadata.hpp> void create_metadentry(const std::string& path, Metadata& md); namespace gkfs { namespace metadentry { std::string get_metadentry_str(const std::string& path); Metadata get(const std::string& path); Metadata get_metadentry(const std::string& path); std::string get_str(const std::string& path); void remove_node(const std::string& path); size_t get_size(const std::string& path); size_t get_metadentry_size(const std::string& path); std::vector<std::pair<std::string, bool>> get_dirents(const std::string& dir); void update_metadentry_size(const std::string& path, size_t io_size, off_t offset, bool append); void create(const std::string& path, Metadata& md); void update_metadentry(const std::string& path, Metadata& md); void update(const std::string& path, Metadata& md); std::vector<std::pair<std::string, bool>> get_dirents(const std::string& dir); void update_size(const std::string& path, size_t io_size, off_t offset, bool append); void remove_node(const std::string& path); } } #endif //GEKKOFS_METADENTRY_HPP src/client/gkfs_functions.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -681,5 +681,3 @@ int gkfs::func::readlink(const std::string& path, char* buf, int bufsize) { } #endif No newline at end of file #pragma clang diagnostic pop No newline at end of file src/client/rpc/ld_rpc_metadentry.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,7 @@ using namespace std; int rpc_send::mk_node(const std::string& path, const mode_t mode) { int err = EUNKNOWN; auto endp = CTX->hosts().at( CTX->distributor()->locate_file_metadata(path)); auto endp = CTX->hosts().at(CTX->distributor()->locate_file_metadata(path)); try { LOG(DEBUG, "Sending RPC ..."); Loading src/daemon/handler/h_metadentry.cpp +9 −9 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ static hg_return_t rpc_srv_mk_node(hg_handle_t handle) { Metadata md(in.mode); try { // create metadentry create_metadentry(in.path, md); gkfs::metadentry::create(in.path, md); out.err = 0; } catch (const std::exception& e) { GKFS_DATA->spdlogger()->error("{}() Failed to create metadentry: '{}'", __func__, e.what()); Loading Loading @@ -65,7 +65,7 @@ static hg_return_t rpc_srv_stat(hg_handle_t handle) { try { // get the metadata val = get_metadentry_str(in.path); val = gkfs::metadentry::get_str(in.path); out.db_val = val.c_str(); out.err = 0; GKFS_DATA->spdlogger()->debug("{}() Sending output mode '{}'", __func__, out.db_val); Loading Loading @@ -137,7 +137,7 @@ static hg_return_t rpc_srv_rm_node(hg_handle_t handle) { try { // Remove metadentry if exists on the node // and remove all chunks for that file remove_node(in.path); gkfs::metadentry::remove_node(in.path); out.err = 0; } catch (const NotFoundException& e) { /* The metadentry was not found on this node, Loading Loading @@ -180,7 +180,7 @@ static hg_return_t rpc_srv_update_metadentry(hg_handle_t handle) { // do update try { Metadata md = get_metadentry(in.path); Metadata md = gkfs::metadentry::get(in.path); if (in.block_flag == HG_TRUE) md.blocks(in.blocks); if (in.nlink_flag == HG_TRUE) Loading @@ -193,7 +193,7 @@ static hg_return_t rpc_srv_update_metadentry(hg_handle_t handle) { md.mtime(in.mtime); if (in.ctime_flag == HG_TRUE) md.ctime(in.ctime); update_metadentry(in.path, md); gkfs::metadentry::update(in.path, md); out.err = 0; } catch (const std::exception& e) { //TODO handle NotFoundException Loading Loading @@ -228,7 +228,7 @@ static hg_return_t rpc_srv_update_metadentry_size(hg_handle_t handle) { in.offset, in.append); try { update_metadentry_size(in.path, in.size, in.offset, (in.append == HG_TRUE)); gkfs::metadentry::update_size(in.path, in.size, in.offset, (in.append == HG_TRUE)); out.err = 0; //TODO the actual size of the file could be different after the size update // do to concurrency on size Loading Loading @@ -268,7 +268,7 @@ static hg_return_t rpc_srv_get_metadentry_size(hg_handle_t handle) { // do update try { out.ret_size = get_metadentry_size(in.path); out.ret_size = gkfs::metadentry::get_size(in.path); out.err = 0; } catch (const NotFoundException& e) { GKFS_DATA->spdlogger()->debug("{}() Entry not found: '{}'", __func__, in.path); Loading Loading @@ -313,7 +313,7 @@ static hg_return_t rpc_srv_get_dirents(hg_handle_t handle) { auto bulk_size = margo_bulk_get_size(in.bulk_handle); //Get directory entries from local DB std::vector<std::pair<std::string, bool>> entries = get_dirents(in.path); std::vector<std::pair<std::string, bool>> entries = gkfs::metadentry::get_dirents(in.path); out.dirents_size = entries.size(); Loading Loading @@ -396,7 +396,7 @@ static hg_return_t rpc_srv_mk_symlink(hg_handle_t handle) { try { Metadata md = {LINK_MODE, in.target_path}; // create metadentry create_metadentry(in.path, md); gkfs::metadentry::create(in.path, md); out.err = 0; } catch (const std::exception& e) { GKFS_DATA->spdlogger()->error("{}() Failed to create metadentry: {}", __func__, e.what()); Loading src/daemon/main.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ void init_environment() { // Create metadentry for root directory Metadata root_md{S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO}; try { create_metadentry("/", root_md); gkfs::metadentry::create("/", root_md); } catch (const std::exception& e) { throw runtime_error("Failed to write root metadentry to KV store: "s + e.what()); } Loading Loading
include/daemon/ops/metadentry.hpp +13 −8 Original line number Diff line number Diff line Loading @@ -18,20 +18,25 @@ #include <daemon/main.hpp> #include <global/metadata.hpp> void create_metadentry(const std::string& path, Metadata& md); namespace gkfs { namespace metadentry { std::string get_metadentry_str(const std::string& path); Metadata get(const std::string& path); Metadata get_metadentry(const std::string& path); std::string get_str(const std::string& path); void remove_node(const std::string& path); size_t get_size(const std::string& path); size_t get_metadentry_size(const std::string& path); std::vector<std::pair<std::string, bool>> get_dirents(const std::string& dir); void update_metadentry_size(const std::string& path, size_t io_size, off_t offset, bool append); void create(const std::string& path, Metadata& md); void update_metadentry(const std::string& path, Metadata& md); void update(const std::string& path, Metadata& md); std::vector<std::pair<std::string, bool>> get_dirents(const std::string& dir); void update_size(const std::string& path, size_t io_size, off_t offset, bool append); void remove_node(const std::string& path); } } #endif //GEKKOFS_METADENTRY_HPP
src/client/gkfs_functions.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -681,5 +681,3 @@ int gkfs::func::readlink(const std::string& path, char* buf, int bufsize) { } #endif No newline at end of file #pragma clang diagnostic pop No newline at end of file
src/client/rpc/ld_rpc_metadentry.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,7 @@ using namespace std; int rpc_send::mk_node(const std::string& path, const mode_t mode) { int err = EUNKNOWN; auto endp = CTX->hosts().at( CTX->distributor()->locate_file_metadata(path)); auto endp = CTX->hosts().at(CTX->distributor()->locate_file_metadata(path)); try { LOG(DEBUG, "Sending RPC ..."); Loading
src/daemon/handler/h_metadentry.cpp +9 −9 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ static hg_return_t rpc_srv_mk_node(hg_handle_t handle) { Metadata md(in.mode); try { // create metadentry create_metadentry(in.path, md); gkfs::metadentry::create(in.path, md); out.err = 0; } catch (const std::exception& e) { GKFS_DATA->spdlogger()->error("{}() Failed to create metadentry: '{}'", __func__, e.what()); Loading Loading @@ -65,7 +65,7 @@ static hg_return_t rpc_srv_stat(hg_handle_t handle) { try { // get the metadata val = get_metadentry_str(in.path); val = gkfs::metadentry::get_str(in.path); out.db_val = val.c_str(); out.err = 0; GKFS_DATA->spdlogger()->debug("{}() Sending output mode '{}'", __func__, out.db_val); Loading Loading @@ -137,7 +137,7 @@ static hg_return_t rpc_srv_rm_node(hg_handle_t handle) { try { // Remove metadentry if exists on the node // and remove all chunks for that file remove_node(in.path); gkfs::metadentry::remove_node(in.path); out.err = 0; } catch (const NotFoundException& e) { /* The metadentry was not found on this node, Loading Loading @@ -180,7 +180,7 @@ static hg_return_t rpc_srv_update_metadentry(hg_handle_t handle) { // do update try { Metadata md = get_metadentry(in.path); Metadata md = gkfs::metadentry::get(in.path); if (in.block_flag == HG_TRUE) md.blocks(in.blocks); if (in.nlink_flag == HG_TRUE) Loading @@ -193,7 +193,7 @@ static hg_return_t rpc_srv_update_metadentry(hg_handle_t handle) { md.mtime(in.mtime); if (in.ctime_flag == HG_TRUE) md.ctime(in.ctime); update_metadentry(in.path, md); gkfs::metadentry::update(in.path, md); out.err = 0; } catch (const std::exception& e) { //TODO handle NotFoundException Loading Loading @@ -228,7 +228,7 @@ static hg_return_t rpc_srv_update_metadentry_size(hg_handle_t handle) { in.offset, in.append); try { update_metadentry_size(in.path, in.size, in.offset, (in.append == HG_TRUE)); gkfs::metadentry::update_size(in.path, in.size, in.offset, (in.append == HG_TRUE)); out.err = 0; //TODO the actual size of the file could be different after the size update // do to concurrency on size Loading Loading @@ -268,7 +268,7 @@ static hg_return_t rpc_srv_get_metadentry_size(hg_handle_t handle) { // do update try { out.ret_size = get_metadentry_size(in.path); out.ret_size = gkfs::metadentry::get_size(in.path); out.err = 0; } catch (const NotFoundException& e) { GKFS_DATA->spdlogger()->debug("{}() Entry not found: '{}'", __func__, in.path); Loading Loading @@ -313,7 +313,7 @@ static hg_return_t rpc_srv_get_dirents(hg_handle_t handle) { auto bulk_size = margo_bulk_get_size(in.bulk_handle); //Get directory entries from local DB std::vector<std::pair<std::string, bool>> entries = get_dirents(in.path); std::vector<std::pair<std::string, bool>> entries = gkfs::metadentry::get_dirents(in.path); out.dirents_size = entries.size(); Loading Loading @@ -396,7 +396,7 @@ static hg_return_t rpc_srv_mk_symlink(hg_handle_t handle) { try { Metadata md = {LINK_MODE, in.target_path}; // create metadentry create_metadentry(in.path, md); gkfs::metadentry::create(in.path, md); out.err = 0; } catch (const std::exception& e) { GKFS_DATA->spdlogger()->error("{}() Failed to create metadentry: {}", __func__, e.what()); Loading
src/daemon/main.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ void init_environment() { // Create metadentry for root directory Metadata root_md{S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO}; try { create_metadentry("/", root_md); gkfs::metadentry::create("/", root_md); } catch (const std::exception& e) { throw runtime_error("Failed to write root metadentry to KV store: "s + e.what()); } Loading