Loading ifs/include/daemon/adafs_ops/data.hppdeleted 100644 → 0 +0 −34 Original line number Diff line number Diff line #ifndef IFS_DATA_HPP #define IFS_DATA_HPP #include <daemon/adafs_daemon.hpp> struct write_chunk_args { const std::string* path; const char* buf; rpc_chnk_id_t chnk_id; size_t size; off64_t off; ABT_eventual eventual; }; struct read_chunk_args { const std::string* path; char* buf; rpc_chnk_id_t chnk_id; size_t size; off64_t off; ABT_eventual eventual; }; std::string path_to_fspath(const std::string& path); int init_chunk_space(const std::string& path); int destroy_chunk_space(const std::string& path); void read_file_abt(void* _arg); void write_file_abt(void* _arg); #endif //IFS_DATA_HPP ifs/include/daemon/backend/data/chunk_storage.hpp 0 → 100644 +37 −0 Original line number Diff line number Diff line #ifndef IFS_CHUNK_STORAGE_HPP #define IFS_CHUNK_STORAGE_HPP #include <abt.h> #include <string> #include <memory> /* Forward declarations */ namespace spdlog { class logger; } class ChunkStorage { private: static constexpr const char * LOGGER_NAME = "ChunkStorage"; std::shared_ptr<spdlog::logger> log; std::string root_path; inline std::string absolute(const std::string& internal_path) const; static inline std::string get_chunks_dir(const std::string& file_path); static inline std::string get_chunk_path(const std::string& file_path, unsigned int chunk_id); void init_chunk_space(const std::string& file_path) const; public: ChunkStorage(const std::string& path); void write_chunk(const std::string& file_path, unsigned int chunk_id, const char * buff, size_t size, off64_t offset, ABT_eventual& eventual) const; void read_chunk(const std::string& file_path, unsigned int chunk_id, char * buff, size_t size, off64_t offset, ABT_eventual& eventual) const; void destroy_chunk_space(const std::string& file_path) const; }; #endif //IFS_CHUNK_STORAGE_HPP ifs/include/daemon/classes/fs_data.hpp +7 −5 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ /* Forward declarations */ class MetadataDB; class ChunkStorage; #include <unordered_map> #include <functional> //std::hash Loading @@ -32,7 +33,6 @@ private: std::string rootdir_; std::string mountdir_; std::string metadir_; std::string chunk_path_; // hosts_ std::string hosts_raw_; // raw hosts string, given when daemon is started. Used to give it to fs client Loading @@ -43,6 +43,8 @@ private: // Database std::shared_ptr<MetadataDB> mdb_; // Storage backend std::shared_ptr<ChunkStorage> storage_; // configurable metadata bool atime_state_; Loading Loading @@ -109,16 +111,16 @@ public: void metadir(const std::string& metadir_); const std::string& chunk_path() const; void chunk_path(const std::string& chunk_path_); const std::shared_ptr<MetadataDB>& mdb() const; void mdb(const std::shared_ptr<MetadataDB>& mdb); void close_mdb(); const std::shared_ptr<ChunkStorage>& storage() const; void storage(const std::shared_ptr<ChunkStorage>& storage); const std::string& hosts_raw() const; void hosts_raw(const std::string& hosts_raw); Loading ifs/src/daemon/CMakeLists.txt +2 −2 Original line number Diff line number Diff line add_subdirectory(backend/metadata) add_subdirectory(backend/data) set(DAEMON_SRC ../global/rpc/rpc_utils.cpp ../global/global_func.cpp ../global/path_util.cpp adafs_daemon.cpp adafs_ops/data.cpp adafs_ops/metadentry.cpp classes/fs_data.cpp classes/rpc_data.cpp Loading @@ -24,7 +24,6 @@ set(DAEMON_HEADERS ../../include/global/rpc/rpc_utils.hpp ../../include/global/path_util.hpp ../../include/daemon/adafs_daemon.hpp ../../include/daemon/adafs_ops/data.hpp ../../include/daemon/adafs_ops/metadentry.hpp ../../include/daemon/classes/fs_data.hpp ../../include/daemon/classes/metadata.hpp Loading @@ -35,6 +34,7 @@ add_executable(adafs_daemon ${DAEMON_SRC} ${DAEMON_HEADERS}) target_link_libraries(adafs_daemon # internal libs metadata_db storage # margo libs ${ABT_LIBRARIES} ${ABT_SNOOZER_LIBRARIES} Loading ifs/src/daemon/adafs_daemon.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ #include <daemon/handler/rpc_defs.hpp> #include <daemon/adafs_ops/metadentry.hpp> #include <daemon/backend/metadata/db.hpp> #include <daemon/backend/data/chunk_storage.hpp> #include <boost/filesystem.hpp> #include <boost/program_options.hpp> Loading Loading @@ -39,6 +40,16 @@ bool init_environment() { ADAFS_DATA->spdlogger()->error("{}() unable to initialize metadata DB: {}", __func__, e.what()); } // Initialize data backend std::string chunk_storage_path = ADAFS_DATA->rootdir() + "/data/chunks"s; ADAFS_DATA->spdlogger()->debug("{}() Creating chunk storage directory: '{}'", __func__, chunk_storage_path); bfs::create_directories(chunk_storage_path); try { ADAFS_DATA->storage(std::make_shared<ChunkStorage>(chunk_storage_path)); } catch (const std::exception & e) { ADAFS_DATA->spdlogger()->error("{}() unable to initialize storage backend: {}", __func__, e.what()); } // Init margo for RPC if (!init_rpc_server()) { ADAFS_DATA->spdlogger()->error("{}() unable to initialize margo rpc server.", __func__); Loading Loading @@ -328,6 +339,7 @@ void initialize_loggers() { auto logger_names = std::vector<std::string>{ "main", "MetadataDB", "ChunkStorage", }; /* Create common sink */ Loading Loading @@ -465,12 +477,10 @@ int main(int argc, const char* argv[]) { ADAFS_DATA->host_size(hostmap.size()); ADAFS_DATA->rpc_port(fmt::FormatInt(RPC_PORT).str()); ADAFS_DATA->hosts_raw(hosts_raw); ADAFS_DATA->chunk_path(ADAFS_DATA->rootdir() + "/data/chunks"s); ADAFS_DATA->spdlogger()->info("{}() Initializing environment. Hold on ...", __func__); // Make sure directory structure exists bfs::create_directories(ADAFS_DATA->chunk_path()); bfs::create_directories(ADAFS_DATA->metadir()); // Create mountdir. We use this dir to get some information on the underlying fs with statfs in adafs_statfs bfs::create_directories(ADAFS_DATA->mountdir()); Loading Loading
ifs/include/daemon/adafs_ops/data.hppdeleted 100644 → 0 +0 −34 Original line number Diff line number Diff line #ifndef IFS_DATA_HPP #define IFS_DATA_HPP #include <daemon/adafs_daemon.hpp> struct write_chunk_args { const std::string* path; const char* buf; rpc_chnk_id_t chnk_id; size_t size; off64_t off; ABT_eventual eventual; }; struct read_chunk_args { const std::string* path; char* buf; rpc_chnk_id_t chnk_id; size_t size; off64_t off; ABT_eventual eventual; }; std::string path_to_fspath(const std::string& path); int init_chunk_space(const std::string& path); int destroy_chunk_space(const std::string& path); void read_file_abt(void* _arg); void write_file_abt(void* _arg); #endif //IFS_DATA_HPP
ifs/include/daemon/backend/data/chunk_storage.hpp 0 → 100644 +37 −0 Original line number Diff line number Diff line #ifndef IFS_CHUNK_STORAGE_HPP #define IFS_CHUNK_STORAGE_HPP #include <abt.h> #include <string> #include <memory> /* Forward declarations */ namespace spdlog { class logger; } class ChunkStorage { private: static constexpr const char * LOGGER_NAME = "ChunkStorage"; std::shared_ptr<spdlog::logger> log; std::string root_path; inline std::string absolute(const std::string& internal_path) const; static inline std::string get_chunks_dir(const std::string& file_path); static inline std::string get_chunk_path(const std::string& file_path, unsigned int chunk_id); void init_chunk_space(const std::string& file_path) const; public: ChunkStorage(const std::string& path); void write_chunk(const std::string& file_path, unsigned int chunk_id, const char * buff, size_t size, off64_t offset, ABT_eventual& eventual) const; void read_chunk(const std::string& file_path, unsigned int chunk_id, char * buff, size_t size, off64_t offset, ABT_eventual& eventual) const; void destroy_chunk_space(const std::string& file_path) const; }; #endif //IFS_CHUNK_STORAGE_HPP
ifs/include/daemon/classes/fs_data.hpp +7 −5 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ /* Forward declarations */ class MetadataDB; class ChunkStorage; #include <unordered_map> #include <functional> //std::hash Loading @@ -32,7 +33,6 @@ private: std::string rootdir_; std::string mountdir_; std::string metadir_; std::string chunk_path_; // hosts_ std::string hosts_raw_; // raw hosts string, given when daemon is started. Used to give it to fs client Loading @@ -43,6 +43,8 @@ private: // Database std::shared_ptr<MetadataDB> mdb_; // Storage backend std::shared_ptr<ChunkStorage> storage_; // configurable metadata bool atime_state_; Loading Loading @@ -109,16 +111,16 @@ public: void metadir(const std::string& metadir_); const std::string& chunk_path() const; void chunk_path(const std::string& chunk_path_); const std::shared_ptr<MetadataDB>& mdb() const; void mdb(const std::shared_ptr<MetadataDB>& mdb); void close_mdb(); const std::shared_ptr<ChunkStorage>& storage() const; void storage(const std::shared_ptr<ChunkStorage>& storage); const std::string& hosts_raw() const; void hosts_raw(const std::string& hosts_raw); Loading
ifs/src/daemon/CMakeLists.txt +2 −2 Original line number Diff line number Diff line add_subdirectory(backend/metadata) add_subdirectory(backend/data) set(DAEMON_SRC ../global/rpc/rpc_utils.cpp ../global/global_func.cpp ../global/path_util.cpp adafs_daemon.cpp adafs_ops/data.cpp adafs_ops/metadentry.cpp classes/fs_data.cpp classes/rpc_data.cpp Loading @@ -24,7 +24,6 @@ set(DAEMON_HEADERS ../../include/global/rpc/rpc_utils.hpp ../../include/global/path_util.hpp ../../include/daemon/adafs_daemon.hpp ../../include/daemon/adafs_ops/data.hpp ../../include/daemon/adafs_ops/metadentry.hpp ../../include/daemon/classes/fs_data.hpp ../../include/daemon/classes/metadata.hpp Loading @@ -35,6 +34,7 @@ add_executable(adafs_daemon ${DAEMON_SRC} ${DAEMON_HEADERS}) target_link_libraries(adafs_daemon # internal libs metadata_db storage # margo libs ${ABT_LIBRARIES} ${ABT_SNOOZER_LIBRARIES} Loading
ifs/src/daemon/adafs_daemon.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ #include <daemon/handler/rpc_defs.hpp> #include <daemon/adafs_ops/metadentry.hpp> #include <daemon/backend/metadata/db.hpp> #include <daemon/backend/data/chunk_storage.hpp> #include <boost/filesystem.hpp> #include <boost/program_options.hpp> Loading Loading @@ -39,6 +40,16 @@ bool init_environment() { ADAFS_DATA->spdlogger()->error("{}() unable to initialize metadata DB: {}", __func__, e.what()); } // Initialize data backend std::string chunk_storage_path = ADAFS_DATA->rootdir() + "/data/chunks"s; ADAFS_DATA->spdlogger()->debug("{}() Creating chunk storage directory: '{}'", __func__, chunk_storage_path); bfs::create_directories(chunk_storage_path); try { ADAFS_DATA->storage(std::make_shared<ChunkStorage>(chunk_storage_path)); } catch (const std::exception & e) { ADAFS_DATA->spdlogger()->error("{}() unable to initialize storage backend: {}", __func__, e.what()); } // Init margo for RPC if (!init_rpc_server()) { ADAFS_DATA->spdlogger()->error("{}() unable to initialize margo rpc server.", __func__); Loading Loading @@ -328,6 +339,7 @@ void initialize_loggers() { auto logger_names = std::vector<std::string>{ "main", "MetadataDB", "ChunkStorage", }; /* Create common sink */ Loading Loading @@ -465,12 +477,10 @@ int main(int argc, const char* argv[]) { ADAFS_DATA->host_size(hostmap.size()); ADAFS_DATA->rpc_port(fmt::FormatInt(RPC_PORT).str()); ADAFS_DATA->hosts_raw(hosts_raw); ADAFS_DATA->chunk_path(ADAFS_DATA->rootdir() + "/data/chunks"s); ADAFS_DATA->spdlogger()->info("{}() Initializing environment. Hold on ...", __func__); // Make sure directory structure exists bfs::create_directories(ADAFS_DATA->chunk_path()); bfs::create_directories(ADAFS_DATA->metadir()); // Create mountdir. We use this dir to get some information on the underlying fs with statfs in adafs_statfs bfs::create_directories(ADAFS_DATA->mountdir()); Loading