Loading ifs/include/adafs_ops/metadentry.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ int remove_metadentry(const std::string& path); int remove_node(const std::string& path); long update_metadentry_size(const std::string& path, off_t size, bool append); int update_metadentry_size(const std::string& path, size_t io_size, off_t offset, bool append, size_t& read_size); int update_metadentry(const std::string& path, Metadata& md); Loading ifs/include/classes/metadata.hpp +4 −4 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ private: mode_t mode_; uint64_t inode_no_; nlink_t link_count_; // number of names for this inode (hardlinks) off_t size_; // size_ in bytes, might be computed instead of stored size_t size_; // size_ in bytes, might be computed instead of stored blkcnt_t blocks_; // allocated file system blocks_ std::string path_; Loading @@ -23,7 +23,7 @@ private: public: Metadata(); Metadata(const std::string& path, const mode_t mode); Metadata(const std::string& path, mode_t mode); Metadata(const std::string& path, std::string db_val); Loading Loading @@ -66,9 +66,9 @@ public: void link_count(nlink_t link_count_); off_t size() const; size_t size() const; void size(off_t size_); void size(size_t size_); blkcnt_t blocks() const; Loading ifs/include/preload/rpc/ld_rpc_metadentry.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ int rpc_send_unlink(const std::string& path); int rpc_send_update_metadentry(const std::string& path, const Metadentry& md, const MetadentryUpdateFlags& md_flags); int rpc_send_update_metadentry_size(const std::string& path, off_t size, bool append_flag, off_t& ret_size); int rpc_send_update_metadentry_size(const std::string& path, size_t size, off_t offset, bool append_flag, off_t& ret_size); #endif //IFS_PRELOAD_C_METADENTRY_HPP ifs/include/rpc/rpc_types.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ MERCURY_GEN_PROC(rpc_update_metadentry_in_t, ((hg_bool_t) (ctime_flag))) MERCURY_GEN_PROC(rpc_update_metadentry_size_in_t, ((hg_const_string_t) (path)) ((hg_int64_t) (size)) ((hg_uint64_t) (size)) ((hg_int64_t) (offset)) ((hg_bool_t) (append))) MERCURY_GEN_PROC(rpc_update_metadentry_size_out_t, ((hg_int32_t) (err)) Loading ifs/src/adafs_ops/metadentry.cpp +22 −8 Original line number Diff line number Diff line Loading @@ -92,24 +92,38 @@ int remove_node(const string& path) { /** * Updates a metadentry's size atomically and returns the corresponding size after update * @param path * @param size * @param io_size * @return the updated size */ long update_metadentry_size(const string& path, off_t size, bool append) { int update_metadentry_size(const string& path, size_t io_size, off_t offset, bool append, size_t& read_size) { // XXX This function has to be completely atomic. Do we need transactions here? or a separate locking db? #ifdef LOG_TRACE db_iterate_all_entries(); #endif string val; auto err = db_get_metadentry(path, val); if (!err || val.size() == 0) { return -1; return ENOENT; } Metadata md{path, val}; // update size if (static_cast<unsigned long>(offset) > md.size()) // Writing beyond file dimensions is prohibited for now return EFAULT; // update io_size if (append) md.size(md.size() + size); else md.size(size); return db_update_metadentry(path, path, md.to_KVentry()) ? md.size() : -1; // update database atomically md.size(md.size() + io_size); else { // if no append but io_size exceeds the file's size, update the size correspondingly if (io_size + static_cast<unsigned long>(offset) > md.size()) md.size(io_size + offset); else { read_size = md.size(); return 0; } } read_size = db_update_metadentry(path, path, md.to_KVentry()) ? md.size() : -1; // update database atomically #ifdef LOG_TRACE db_iterate_all_entries(); #endif return 0; } int update_metadentry(const string& path, Metadata& md) { Loading Loading
ifs/include/adafs_ops/metadentry.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ int remove_metadentry(const std::string& path); int remove_node(const std::string& path); long update_metadentry_size(const std::string& path, off_t size, bool append); int update_metadentry_size(const std::string& path, size_t io_size, off_t offset, bool append, size_t& read_size); int update_metadentry(const std::string& path, Metadata& md); Loading
ifs/include/classes/metadata.hpp +4 −4 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ private: mode_t mode_; uint64_t inode_no_; nlink_t link_count_; // number of names for this inode (hardlinks) off_t size_; // size_ in bytes, might be computed instead of stored size_t size_; // size_ in bytes, might be computed instead of stored blkcnt_t blocks_; // allocated file system blocks_ std::string path_; Loading @@ -23,7 +23,7 @@ private: public: Metadata(); Metadata(const std::string& path, const mode_t mode); Metadata(const std::string& path, mode_t mode); Metadata(const std::string& path, std::string db_val); Loading Loading @@ -66,9 +66,9 @@ public: void link_count(nlink_t link_count_); off_t size() const; size_t size() const; void size(off_t size_); void size(size_t size_); blkcnt_t blocks() const; Loading
ifs/include/preload/rpc/ld_rpc_metadentry.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ int rpc_send_unlink(const std::string& path); int rpc_send_update_metadentry(const std::string& path, const Metadentry& md, const MetadentryUpdateFlags& md_flags); int rpc_send_update_metadentry_size(const std::string& path, off_t size, bool append_flag, off_t& ret_size); int rpc_send_update_metadentry_size(const std::string& path, size_t size, off_t offset, bool append_flag, off_t& ret_size); #endif //IFS_PRELOAD_C_METADENTRY_HPP
ifs/include/rpc/rpc_types.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ MERCURY_GEN_PROC(rpc_update_metadentry_in_t, ((hg_bool_t) (ctime_flag))) MERCURY_GEN_PROC(rpc_update_metadentry_size_in_t, ((hg_const_string_t) (path)) ((hg_int64_t) (size)) ((hg_uint64_t) (size)) ((hg_int64_t) (offset)) ((hg_bool_t) (append))) MERCURY_GEN_PROC(rpc_update_metadentry_size_out_t, ((hg_int32_t) (err)) Loading
ifs/src/adafs_ops/metadentry.cpp +22 −8 Original line number Diff line number Diff line Loading @@ -92,24 +92,38 @@ int remove_node(const string& path) { /** * Updates a metadentry's size atomically and returns the corresponding size after update * @param path * @param size * @param io_size * @return the updated size */ long update_metadentry_size(const string& path, off_t size, bool append) { int update_metadentry_size(const string& path, size_t io_size, off_t offset, bool append, size_t& read_size) { // XXX This function has to be completely atomic. Do we need transactions here? or a separate locking db? #ifdef LOG_TRACE db_iterate_all_entries(); #endif string val; auto err = db_get_metadentry(path, val); if (!err || val.size() == 0) { return -1; return ENOENT; } Metadata md{path, val}; // update size if (static_cast<unsigned long>(offset) > md.size()) // Writing beyond file dimensions is prohibited for now return EFAULT; // update io_size if (append) md.size(md.size() + size); else md.size(size); return db_update_metadentry(path, path, md.to_KVentry()) ? md.size() : -1; // update database atomically md.size(md.size() + io_size); else { // if no append but io_size exceeds the file's size, update the size correspondingly if (io_size + static_cast<unsigned long>(offset) > md.size()) md.size(io_size + offset); else { read_size = md.size(); return 0; } } read_size = db_update_metadentry(path, path, md.to_KVentry()) ? md.size() : -1; // update database atomically #ifdef LOG_TRACE db_iterate_all_entries(); #endif return 0; } int update_metadentry(const string& path, Metadata& md) { Loading