Loading ifs/include/daemon/adafs_ops/metadentry.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ void remove_node(const std::string& path); size_t get_metadentry_size(const std::string& path); int update_metadentry_size(const std::string& path, size_t io_size, off_t offset, bool append, size_t& read_size); void update_metadentry_size(const std::string& path, size_t io_size, off_t offset, bool append); void update_metadentry(const std::string& path, Metadata& md); Loading ifs/include/daemon/backend/metadata/db.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ class MetadataDB { void remove(const std::string& key); bool exists(const std::string& key); void update(const std::string& old_key, const std::string& new_key, const std::string& val); bool update_size(const std::string& key, size_t size, off64_t offset, bool append); void update_size(const std::string& key, size_t size, bool append); void iterate_all(); }; Loading ifs/src/daemon/adafs_ops/metadentry.cpp +2 −8 Original line number Diff line number Diff line Loading @@ -81,20 +81,14 @@ size_t get_metadentry_size(const string& path) { * @param io_size * @return the updated size */ int update_metadentry_size(const string& path, size_t io_size, off64_t offset, bool append, size_t& read_size) { void update_metadentry_size(const string& path, size_t io_size, off64_t offset, bool append) { #ifdef LOG_TRACE ADAFS_DATA->mdb()->iterate_all(); #endif auto err = ADAFS_DATA->mdb()->update_size(path, io_size, offset, append); if (!err) { return EBUSY; } ADAFS_DATA->mdb()->update_size(path, io_size + offset, append); #ifdef LOG_TRACE ADAFS_DATA->mdb()->iterate_all(); #endif //XXX This breaks append writes, needs to be fixed read_size = 0; return 0; } void update_metadentry(const string& path, Metadata& md) { Loading ifs/src/daemon/backend/metadata/db.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -89,13 +89,12 @@ void MetadataDB::update(const std::string& old_key, const std::string& new_key, } } bool MetadataDB::update_size(const std::string& key, size_t size, off64_t offset, bool append){ auto uop = IncreaseSizeOperand(offset + size, append); void MetadataDB::update_size(const std::string& key, size_t size, bool append){ auto uop = IncreaseSizeOperand(size, append); auto s = db->Merge(write_opts, key, uop.serialize()); if(!s.ok()){ //TODO ADAFS_DATA->spdlogger()->error("Failed to update metadentry size. RDB error: [{}]", s.ToString()); MetadataDB::throw_rdb_status_excpt(s); } return s.ok(); } void MetadataDB::iterate_all() { Loading ifs/src/daemon/handler/h_metadentry.cpp +12 −8 Original line number Diff line number Diff line Loading @@ -236,16 +236,20 @@ static hg_return_t rpc_srv_update_metadentry_size(hg_handle_t handle) { assert(ret == HG_SUCCESS); ADAFS_DATA->spdlogger()->debug("{}() Got update metadentry size RPC with path {}", __func__, in.path); // do update size_t read_size; auto err = update_metadentry_size(in.path, in.size, in.offset, (in.append == HG_TRUE), read_size); if (err == 0) { try { update_metadentry_size(in.path, in.size, in.offset, (in.append == HG_TRUE)); out.err = 0; out.ret_size = read_size; } else { out.err = err; out.ret_size = 0; //TODO the actual size of the file could be different after the size update // do to concurrency on size out.ret_size = in.size + in.offset; } catch (const NotFoundException& e) { ADAFS_DATA->spdlogger()->debug("{}() Entry not found: {}", in.path); out.err = ENOENT; } catch (const std::exception& e) { ADAFS_DATA->spdlogger()->error("{}() Failed to update metadentry size on DB: {}", e.what()); out.err = EBUSY; } ADAFS_DATA->spdlogger()->debug("{}() Sending output {}", __func__, out.err); auto hret = margo_respond(handle, &out); if (hret != HG_SUCCESS) { Loading Loading
ifs/include/daemon/adafs_ops/metadentry.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ void remove_node(const std::string& path); size_t get_metadentry_size(const std::string& path); int update_metadentry_size(const std::string& path, size_t io_size, off_t offset, bool append, size_t& read_size); void update_metadentry_size(const std::string& path, size_t io_size, off_t offset, bool append); void update_metadentry(const std::string& path, Metadata& md); Loading
ifs/include/daemon/backend/metadata/db.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ class MetadataDB { void remove(const std::string& key); bool exists(const std::string& key); void update(const std::string& old_key, const std::string& new_key, const std::string& val); bool update_size(const std::string& key, size_t size, off64_t offset, bool append); void update_size(const std::string& key, size_t size, bool append); void iterate_all(); }; Loading
ifs/src/daemon/adafs_ops/metadentry.cpp +2 −8 Original line number Diff line number Diff line Loading @@ -81,20 +81,14 @@ size_t get_metadentry_size(const string& path) { * @param io_size * @return the updated size */ int update_metadentry_size(const string& path, size_t io_size, off64_t offset, bool append, size_t& read_size) { void update_metadentry_size(const string& path, size_t io_size, off64_t offset, bool append) { #ifdef LOG_TRACE ADAFS_DATA->mdb()->iterate_all(); #endif auto err = ADAFS_DATA->mdb()->update_size(path, io_size, offset, append); if (!err) { return EBUSY; } ADAFS_DATA->mdb()->update_size(path, io_size + offset, append); #ifdef LOG_TRACE ADAFS_DATA->mdb()->iterate_all(); #endif //XXX This breaks append writes, needs to be fixed read_size = 0; return 0; } void update_metadentry(const string& path, Metadata& md) { Loading
ifs/src/daemon/backend/metadata/db.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -89,13 +89,12 @@ void MetadataDB::update(const std::string& old_key, const std::string& new_key, } } bool MetadataDB::update_size(const std::string& key, size_t size, off64_t offset, bool append){ auto uop = IncreaseSizeOperand(offset + size, append); void MetadataDB::update_size(const std::string& key, size_t size, bool append){ auto uop = IncreaseSizeOperand(size, append); auto s = db->Merge(write_opts, key, uop.serialize()); if(!s.ok()){ //TODO ADAFS_DATA->spdlogger()->error("Failed to update metadentry size. RDB error: [{}]", s.ToString()); MetadataDB::throw_rdb_status_excpt(s); } return s.ok(); } void MetadataDB::iterate_all() { Loading
ifs/src/daemon/handler/h_metadentry.cpp +12 −8 Original line number Diff line number Diff line Loading @@ -236,16 +236,20 @@ static hg_return_t rpc_srv_update_metadentry_size(hg_handle_t handle) { assert(ret == HG_SUCCESS); ADAFS_DATA->spdlogger()->debug("{}() Got update metadentry size RPC with path {}", __func__, in.path); // do update size_t read_size; auto err = update_metadentry_size(in.path, in.size, in.offset, (in.append == HG_TRUE), read_size); if (err == 0) { try { update_metadentry_size(in.path, in.size, in.offset, (in.append == HG_TRUE)); out.err = 0; out.ret_size = read_size; } else { out.err = err; out.ret_size = 0; //TODO the actual size of the file could be different after the size update // do to concurrency on size out.ret_size = in.size + in.offset; } catch (const NotFoundException& e) { ADAFS_DATA->spdlogger()->debug("{}() Entry not found: {}", in.path); out.err = ENOENT; } catch (const std::exception& e) { ADAFS_DATA->spdlogger()->error("{}() Failed to update metadentry size on DB: {}", e.what()); out.err = EBUSY; } ADAFS_DATA->spdlogger()->debug("{}() Sending output {}", __func__, out.err); auto hret = margo_respond(handle, &out); if (hret != HG_SUCCESS) { Loading