Loading include/client/rpc/forward_metadata.hpp +0 −6 Original line number Diff line number Diff line Loading @@ -28,12 +28,6 @@ class Metadata; } namespace rpc { // enum definieren TODO enum class ForwardCreateStatus { ok, exists, error = -1 }; int forward_create(const std::string& path, mode_t mode); Loading include/config.hpp +4 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,10 @@ constexpr auto use_ctime = false; constexpr auto use_mtime = false; constexpr auto use_link_cnt = false; constexpr auto use_blocks = false; // metadata logic // Check for existence of file metadata before create. This done on RocksDB level constexpr auto create_exist_check = true; } // namespace metadata namespace rpc { Loading include/daemon/backend/exceptions.hpp +2 −2 Original line number Diff line number Diff line Loading @@ -30,9 +30,9 @@ public: explicit NotFoundException(const std::string& s) : DBException(s) {}; }; class CreateException : public DBException { class ExistsException : public DBException { public: CreateException(const std::string& s) : DBException(s) {}; explicit ExistsException(const std::string& s) : DBException(s) {}; }; } // namespace metadata Loading include/daemon/backend/metadata/db.hpp +3 −1 Original line number Diff line number Diff line Loading @@ -35,12 +35,14 @@ private: public: static inline void throw_rdb_status_excpt(const rdb::Status& s); MetadataDB(const std::string& path); explicit MetadataDB(const std::string& path); std::string get(const std::string& key) const; void put(const std::string& key, const std::string& val); void put_if_not_exist(const std::string& key, const std::string& val); void remove(const std::string& key); bool exists(const std::string& key); Loading src/client/gkfs_functions.cpp +18 −18 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ int gkfs_open(const std::string& path, mode_t mode, int flags) { } // dummy metadata creation std::shared_ptr<gkfs::metadata::Metadata> md{}; std::shared_ptr<gkfs::metadata::Metadata> md = nullptr; if (flags & O_CREAT) { if (flags & O_DIRECTORY) { Loading @@ -110,12 +110,9 @@ int gkfs_open(const std::string& path, mode_t mode, int flags) { return -1; } // no access check required here. If one is using our FS they have the permissions. int err_code = gkfs_create(path, mode | S_IFREG); if (err_code == (int) gkfs::rpc::ForwardCreateStatus::error) { LOG(ERROR, "Error creating file: '{}'", strerror(errno)); return -1; } if (err_code == (int) gkfs::rpc::ForwardCreateStatus::exists) { int err = gkfs_create(path, mode | S_IFREG); if (err) { if (errno == EEXIST) { // file exists, O_CREAT was set if (flags & O_EXCL) { // File exists and O_EXCL & O_CREAT was set Loading @@ -123,13 +120,16 @@ int gkfs_open(const std::string& path, mode_t mode, int flags) { return -1; } // file exists, O_CREAT was set O_EXCL wasnt, so function does not fail // this case is actually undefined as per `man 2 open` md = gkfs::util::get_metadata(path); } else { LOG(ERROR, "Error creating file: '{}'", strerror(errno)); return -1; } if (err_code == 0) { // file was created } else { // file was successfully created. Add to filemap return CTX->file_map()->add(std::make_shared<gkfs::filemap::OpenFile>(path, flags)); } } else { md = gkfs::util::get_metadata(path); if (!md) { Loading @@ -137,7 +137,7 @@ int gkfs_open(const std::string& path, mode_t mode, int flags) { // file doesn't exists and O_CREAT was not set return -1; } else { LOG(ERROR, "Error statting existing file"); LOG(ERROR, "Error stating existing file"); return -1; } } Loading Loading
include/client/rpc/forward_metadata.hpp +0 −6 Original line number Diff line number Diff line Loading @@ -28,12 +28,6 @@ class Metadata; } namespace rpc { // enum definieren TODO enum class ForwardCreateStatus { ok, exists, error = -1 }; int forward_create(const std::string& path, mode_t mode); Loading
include/config.hpp +4 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,10 @@ constexpr auto use_ctime = false; constexpr auto use_mtime = false; constexpr auto use_link_cnt = false; constexpr auto use_blocks = false; // metadata logic // Check for existence of file metadata before create. This done on RocksDB level constexpr auto create_exist_check = true; } // namespace metadata namespace rpc { Loading
include/daemon/backend/exceptions.hpp +2 −2 Original line number Diff line number Diff line Loading @@ -30,9 +30,9 @@ public: explicit NotFoundException(const std::string& s) : DBException(s) {}; }; class CreateException : public DBException { class ExistsException : public DBException { public: CreateException(const std::string& s) : DBException(s) {}; explicit ExistsException(const std::string& s) : DBException(s) {}; }; } // namespace metadata Loading
include/daemon/backend/metadata/db.hpp +3 −1 Original line number Diff line number Diff line Loading @@ -35,12 +35,14 @@ private: public: static inline void throw_rdb_status_excpt(const rdb::Status& s); MetadataDB(const std::string& path); explicit MetadataDB(const std::string& path); std::string get(const std::string& key) const; void put(const std::string& key, const std::string& val); void put_if_not_exist(const std::string& key, const std::string& val); void remove(const std::string& key); bool exists(const std::string& key); Loading
src/client/gkfs_functions.cpp +18 −18 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ int gkfs_open(const std::string& path, mode_t mode, int flags) { } // dummy metadata creation std::shared_ptr<gkfs::metadata::Metadata> md{}; std::shared_ptr<gkfs::metadata::Metadata> md = nullptr; if (flags & O_CREAT) { if (flags & O_DIRECTORY) { Loading @@ -110,12 +110,9 @@ int gkfs_open(const std::string& path, mode_t mode, int flags) { return -1; } // no access check required here. If one is using our FS they have the permissions. int err_code = gkfs_create(path, mode | S_IFREG); if (err_code == (int) gkfs::rpc::ForwardCreateStatus::error) { LOG(ERROR, "Error creating file: '{}'", strerror(errno)); return -1; } if (err_code == (int) gkfs::rpc::ForwardCreateStatus::exists) { int err = gkfs_create(path, mode | S_IFREG); if (err) { if (errno == EEXIST) { // file exists, O_CREAT was set if (flags & O_EXCL) { // File exists and O_EXCL & O_CREAT was set Loading @@ -123,13 +120,16 @@ int gkfs_open(const std::string& path, mode_t mode, int flags) { return -1; } // file exists, O_CREAT was set O_EXCL wasnt, so function does not fail // this case is actually undefined as per `man 2 open` md = gkfs::util::get_metadata(path); } else { LOG(ERROR, "Error creating file: '{}'", strerror(errno)); return -1; } if (err_code == 0) { // file was created } else { // file was successfully created. Add to filemap return CTX->file_map()->add(std::make_shared<gkfs::filemap::OpenFile>(path, flags)); } } else { md = gkfs::util::get_metadata(path); if (!md) { Loading @@ -137,7 +137,7 @@ int gkfs_open(const std::string& path, mode_t mode, int flags) { // file doesn't exists and O_CREAT was not set return -1; } else { LOG(ERROR, "Error statting existing file"); LOG(ERROR, "Error stating existing file"); return -1; } } Loading