Loading include/client/rpc/forward_metadata.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ forward_rename(const std::string& oldpath, const std::string& newpath, #endif // HAS_RENAME int forward_remove(const std::string& path, const int8_t num_copies); forward_remove(const std::string& path, bool rm_dir, const int8_t num_copies); int forward_decr_size(const std::string& path, size_t length, const int copy); Loading include/client/rpc/rpc_types.hpp +11 −3 Original line number Diff line number Diff line Loading @@ -520,7 +520,8 @@ struct remove_metadata { hermes::detail::post_to_mercury(ExecutionContext*); public: input(const std::string& path) : m_path(path) {} input(const std::string& path, bool rm_dir) : m_path(path), m_rm_dir(rm_dir) {} input(input&& rhs) = default; Loading @@ -537,14 +538,21 @@ struct remove_metadata { return m_path; } explicit input(const rpc_rm_node_in_t& other) : m_path(other.path) {} bool rm_dir() const { return m_rm_dir; } explicit input(const rpc_rm_node_in_t& other) : m_path(other.path), m_rm_dir(other.rm_dir) {} explicit operator rpc_rm_node_in_t() { return {m_path.c_str()}; return {m_path.c_str(), m_rm_dir}; } private: std::string m_path; bool m_rm_dir; }; class output { Loading include/common/rpc/rpc_types.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,8 @@ MERCURY_GEN_PROC(rpc_path_only_in_t, ((hg_const_string_t) (path))) MERCURY_GEN_PROC(rpc_stat_out_t, ((hg_int32_t) (err))((hg_const_string_t) (db_val))) MERCURY_GEN_PROC(rpc_rm_node_in_t, ((hg_const_string_t) (path))) MERCURY_GEN_PROC(rpc_rm_node_in_t, ((hg_const_string_t) (path))((hg_bool_t) (rm_dir))) MERCURY_GEN_PROC( rpc_rm_metadata_out_t, Loading src/client/gkfs_functions.cpp +10 −11 Original line number Diff line number Diff line Loading @@ -339,6 +339,8 @@ gkfs_create(const std::string& path, mode_t mode) { */ int gkfs_remove(const std::string& path) { #ifdef HAS_SYMLINKS #ifdef HAS_RENAME auto md = gkfs::utils::get_metadata(path); if(!md) { return -1; Loading @@ -349,8 +351,6 @@ gkfs_remove(const std::string& path) { errno = EISDIR; return -1; } #ifdef HAS_SYMLINKS #ifdef HAS_RENAME if(md.value().blocks() == -1) { errno = ENOENT; return -1; Loading Loading @@ -378,7 +378,7 @@ gkfs_remove(const std::string& path) { if(gkfs::config::proxy::fwd_remove && CTX->use_proxy()) { err = gkfs::rpc::forward_remove_proxy(path); } else { err = gkfs::rpc::forward_remove(path, CTX->get_replicas()); err = gkfs::rpc::forward_remove(path, false, CTX->get_replicas()); } if(err) { errno = err; Loading Loading @@ -1340,19 +1340,17 @@ gkfs_opendir(const std::string& path) { */ int gkfs_rmdir(const std::string& path) { int err; // check that directory is empty if a strict dir hierarchy is enforced // TODO rename #define #if GKFS_CREATE_CHECK_PARENTS auto md = gkfs::utils::get_metadata(path); if(!md) { LOG(DEBUG, "Error: Path '{}' err code '{}' ", path, strerror(errno)); return -1; } if(!S_ISDIR(md->mode())) { LOG(DEBUG, "Path '{}' is not a directory", path); errno = ENOTDIR; return -1; } auto ret = gkfs::rpc::forward_get_dirents(path); auto err = ret.first; err = ret.first; if(err) { errno = err; return -1; Loading @@ -1363,10 +1361,11 @@ gkfs_rmdir(const std::string& path) { errno = ENOTEMPTY; return -1; } #endif if(gkfs::config::proxy::fwd_remove && CTX->use_proxy()) { err = gkfs::rpc::forward_remove_proxy(path); } else { err = gkfs::rpc::forward_remove(path, CTX->get_replicas()); err = gkfs::rpc::forward_remove(path, true, CTX->get_replicas()); } if(err) { errno = err; Loading src/client/rpc/forward_metadata.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -135,7 +135,7 @@ forward_stat(const std::string& path, string& attr, const int copy) { * @return error code */ int forward_remove(const std::string& path, const int8_t num_copies) { forward_remove(const std::string& path, bool rm_dir, const int8_t num_copies) { if(gkfs::config::proxy::fwd_remove && CTX->use_proxy()) { LOG(WARNING, "{} was called even though proxy should be used!", __func__); Loading @@ -159,7 +159,8 @@ forward_remove(const std::string& path, const int8_t num_copies) { // returning one result and a broadcast(endpoint_set) returning a // result_set. When that happens we can remove the .at(0) :/ auto out = ld_network_service ->post<gkfs::rpc::remove_metadata>(endp, path) ->post<gkfs::rpc::remove_metadata>(endp, path, rm_dir) .get() .at(0); Loading @@ -174,9 +175,9 @@ forward_remove(const std::string& path, const int8_t num_copies) { return EBUSY; } } // if file is not a regular file and it's size is 0, data does not need to // if file is not a regular file or it's size is 0, data does not need to // be removed, thus, we exit if(!(S_ISREG(mode) && (size != 0))) if(!S_ISREG(mode) || size == 0) return 0; Loading Loading
include/client/rpc/forward_metadata.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ forward_rename(const std::string& oldpath, const std::string& newpath, #endif // HAS_RENAME int forward_remove(const std::string& path, const int8_t num_copies); forward_remove(const std::string& path, bool rm_dir, const int8_t num_copies); int forward_decr_size(const std::string& path, size_t length, const int copy); Loading
include/client/rpc/rpc_types.hpp +11 −3 Original line number Diff line number Diff line Loading @@ -520,7 +520,8 @@ struct remove_metadata { hermes::detail::post_to_mercury(ExecutionContext*); public: input(const std::string& path) : m_path(path) {} input(const std::string& path, bool rm_dir) : m_path(path), m_rm_dir(rm_dir) {} input(input&& rhs) = default; Loading @@ -537,14 +538,21 @@ struct remove_metadata { return m_path; } explicit input(const rpc_rm_node_in_t& other) : m_path(other.path) {} bool rm_dir() const { return m_rm_dir; } explicit input(const rpc_rm_node_in_t& other) : m_path(other.path), m_rm_dir(other.rm_dir) {} explicit operator rpc_rm_node_in_t() { return {m_path.c_str()}; return {m_path.c_str(), m_rm_dir}; } private: std::string m_path; bool m_rm_dir; }; class output { Loading
include/common/rpc/rpc_types.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,8 @@ MERCURY_GEN_PROC(rpc_path_only_in_t, ((hg_const_string_t) (path))) MERCURY_GEN_PROC(rpc_stat_out_t, ((hg_int32_t) (err))((hg_const_string_t) (db_val))) MERCURY_GEN_PROC(rpc_rm_node_in_t, ((hg_const_string_t) (path))) MERCURY_GEN_PROC(rpc_rm_node_in_t, ((hg_const_string_t) (path))((hg_bool_t) (rm_dir))) MERCURY_GEN_PROC( rpc_rm_metadata_out_t, Loading
src/client/gkfs_functions.cpp +10 −11 Original line number Diff line number Diff line Loading @@ -339,6 +339,8 @@ gkfs_create(const std::string& path, mode_t mode) { */ int gkfs_remove(const std::string& path) { #ifdef HAS_SYMLINKS #ifdef HAS_RENAME auto md = gkfs::utils::get_metadata(path); if(!md) { return -1; Loading @@ -349,8 +351,6 @@ gkfs_remove(const std::string& path) { errno = EISDIR; return -1; } #ifdef HAS_SYMLINKS #ifdef HAS_RENAME if(md.value().blocks() == -1) { errno = ENOENT; return -1; Loading Loading @@ -378,7 +378,7 @@ gkfs_remove(const std::string& path) { if(gkfs::config::proxy::fwd_remove && CTX->use_proxy()) { err = gkfs::rpc::forward_remove_proxy(path); } else { err = gkfs::rpc::forward_remove(path, CTX->get_replicas()); err = gkfs::rpc::forward_remove(path, false, CTX->get_replicas()); } if(err) { errno = err; Loading Loading @@ -1340,19 +1340,17 @@ gkfs_opendir(const std::string& path) { */ int gkfs_rmdir(const std::string& path) { int err; // check that directory is empty if a strict dir hierarchy is enforced // TODO rename #define #if GKFS_CREATE_CHECK_PARENTS auto md = gkfs::utils::get_metadata(path); if(!md) { LOG(DEBUG, "Error: Path '{}' err code '{}' ", path, strerror(errno)); return -1; } if(!S_ISDIR(md->mode())) { LOG(DEBUG, "Path '{}' is not a directory", path); errno = ENOTDIR; return -1; } auto ret = gkfs::rpc::forward_get_dirents(path); auto err = ret.first; err = ret.first; if(err) { errno = err; return -1; Loading @@ -1363,10 +1361,11 @@ gkfs_rmdir(const std::string& path) { errno = ENOTEMPTY; return -1; } #endif if(gkfs::config::proxy::fwd_remove && CTX->use_proxy()) { err = gkfs::rpc::forward_remove_proxy(path); } else { err = gkfs::rpc::forward_remove(path, CTX->get_replicas()); err = gkfs::rpc::forward_remove(path, true, CTX->get_replicas()); } if(err) { errno = err; Loading
src/client/rpc/forward_metadata.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -135,7 +135,7 @@ forward_stat(const std::string& path, string& attr, const int copy) { * @return error code */ int forward_remove(const std::string& path, const int8_t num_copies) { forward_remove(const std::string& path, bool rm_dir, const int8_t num_copies) { if(gkfs::config::proxy::fwd_remove && CTX->use_proxy()) { LOG(WARNING, "{} was called even though proxy should be used!", __func__); Loading @@ -159,7 +159,8 @@ forward_remove(const std::string& path, const int8_t num_copies) { // returning one result and a broadcast(endpoint_set) returning a // result_set. When that happens we can remove the .at(0) :/ auto out = ld_network_service ->post<gkfs::rpc::remove_metadata>(endp, path) ->post<gkfs::rpc::remove_metadata>(endp, path, rm_dir) .get() .at(0); Loading @@ -174,9 +175,9 @@ forward_remove(const std::string& path, const int8_t num_copies) { return EBUSY; } } // if file is not a regular file and it's size is 0, data does not need to // if file is not a regular file or it's size is 0, data does not need to // be removed, thus, we exit if(!(S_ISREG(mode) && (size != 0))) if(!S_ISREG(mode) || size == 0) return 0; Loading