Commit 6b7aa13d authored by Ramon Nou's avatar Ramon Nou
Browse files

added test, and CREATE_EXIST_CHECK env

parent 508faafe
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -662,6 +662,7 @@ Using two environment variables
### Daemon
#### Core
- `GKFS_DAEMON_CREATE_CHECK_PARENTS` - Enable checking parent directory for existence before creating children.
- `GKFS_DAEMON_CREATE_EXIST_CHECK` - Check for existence of file metadata before create in RocksDB.
- `GKFS_DAEMON_SYMLINK_SUPPORT` - Enable support for symbolic links.
- `GKFS_DAEMON_RENAME_SUPPORT` - Enable support for rename.
#### Logging
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ constexpr auto implicit_data_removal = true;
// metadata logic
// Check for existence of file metadata before create. This done on RocksDB
// level
constexpr auto create_exist_check = true;
inline bool create_exist_check = true;
// Verify that a parent directory exists before creating new files or
// directories
inline bool create_check_parents = true;
+2 −0
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ static constexpr auto USE_DIRENTS_COMPRESSION =
static constexpr auto HOSTS_FILE = ADD_PREFIX("HOSTS_FILE");
static constexpr auto DAEMON_CREATE_CHECK_PARENTS =
        ADD_PREFIX("DAEMON_CREATE_CHECK_PARENTS");
static constexpr auto DAEMON_CREATE_EXIST_CHECK =
        ADD_PREFIX("DAEMON_CREATE_EXIST_CHECK");
static constexpr auto DAEMON_SYMLINK_SUPPORT =
        ADD_PREFIX("DAEMON_SYMLINK_SUPPORT");
static constexpr auto DAEMON_RENAME_SUPPORT =
+10 −1
Original line number Diff line number Diff line
@@ -381,6 +381,11 @@ init_environment() {
                               gkfs::config::metadata::create_check_parents
                                       ? "ON"
                                       : "OFF") == "ON";
    gkfs::config::metadata::create_exist_check =
            gkfs::env::get_var(gkfs::env::DAEMON_CREATE_EXIST_CHECK,
                               gkfs::config::metadata::create_exist_check
                                       ? "ON"
                                       : "OFF") == "ON";
    gkfs::config::metadata::symlink_support =
            gkfs::env::get_var(gkfs::env::DAEMON_SYMLINK_SUPPORT,
                               gkfs::config::metadata::symlink_support
@@ -393,10 +398,11 @@ init_environment() {
                                       : "OFF") == "ON";

    GKFS_DATA->spdlogger()->info(
            "{}() Inline data: {} / Dirents compression: {} / Create check parents: {} / Symlink support: {} / Rename support: {}",
            "{}() Inline data: {} / Dirents compression: {} / Create check parents: {} / Create exist check: {} / Symlink support: {} / Rename support: {}",
            __func__, gkfs::config::metadata::use_inline_data,
            gkfs::config::rpc::use_dirents_compression,
            gkfs::config::metadata::create_check_parents,
            gkfs::config::metadata::create_exist_check,
            gkfs::config::metadata::symlink_support,
            gkfs::config::metadata::rename_support);

@@ -1066,6 +1072,9 @@ main(int argc, const char* argv[]) {
#else
        cout << "Create check parents: OFF" << endl;
#endif
        cout << "Create exist check: "
             << (gkfs::config::metadata::create_exist_check ? "ON" : "OFF")
             << endl;
        cout << "Chunk size: " << gkfs::config::rpc::chunksize << " bytes"
             << endl;
        return EXIT_SUCCESS;
+13 −2
Original line number Diff line number Diff line
@@ -82,11 +82,22 @@ void
create(const std::string& path, Metadata& md) {

    // update metadata object based on what metadata is needed
    if constexpr(gkfs::config::metadata::create_exist_check) {
    if(gkfs::config::metadata::create_exist_check) {
        bool exists = GKFS_DATA->mdb()->exists(path);
        if(exists) {
            // If it exists, put_no_exist would typically throw an error.
            // For now, we'll assume the intent is to do nothing or let the
            // backend handle the error. The original `put_no_exist` implies an
            // error if it exists. To maintain similar behavior, we should
            // probably throw an error here or rely on the backend. For now,
            // we'll just call put_no_exist as it was, but without constexpr.
            GKFS_DATA->mdb()->put_no_exist(path, md.serialize());
        } else {
            GKFS_DATA->mdb()->put(path, md.serialize());
        }
    } else {
        GKFS_DATA->mdb()->put(path, md.serialize());
    }
}

void
Loading