Commit 0865164b authored by Julius Athenstaedt's avatar Julius Athenstaedt Committed by Ramon Nou
Browse files

fix removal race condition, add tuning parameters and descriptions

parent b044f51e
Loading
Loading
Loading
Loading
+27 −12
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ get_inode(fuse_ino_t ino) {

static void
remove_inode_by_path(const std::string path) {
    std::lock_guard<std::mutex> lk(ino_mutex);
    auto it_src = path_map.find(path);
    if(it_src != path_map.end()) {
        path_map.erase(it_src);
@@ -143,16 +144,21 @@ static void
passthrough_ll_help(void) {
    printf("    -o writeback           Enable writeback\n"
           "    -o no_writeback        Disable write back\n"
           "    -o direct_io           Enables direct io\n"
           "    -o direct_io           Enables direct io and bypasses page cache (can boost performance a lot)\n"
           "    -o no_direct_io        Disable direct io\n"
           "    -o max_readahead=0     Amount of allowed readaheads in bytes\n"
           "    -o max_read=0          Preferred read buffer size, depends on kernel, default: 0 for unlimited. You have to set -o max_read2 to the same value. This is due to fuse internal logic\n"
           "    -o max_read2=0         Preferred read buffer size, depends on kernel, default: 0 for unlimited. You have to set -o max_read to the same value. This is due to fuse internal logic\n"
           "    -o max_write=0         Preferred write buffer size, depends on kernel, default: 0 for unlimited.\n"
           "    -o big_writes          Enables to write >= 128KiB in one request. Default for FUSE >= 3\n"
           "    -o fifo                Enable fifo, disables GekkoFS access check\n"
           "    -o no_fifo             Disable fifo\n"
           "    -o access              Enable GekkoFS access check if fifo is deactivated\n"
           "    -o no_access           Disable access handler\n"
           "    -o xattr               Enable xattr\n"
           "    -o no_xattr            Disable xattr\n"
           "    -o async_read          Enable async reads (default)\n"
           "    -o sync_read           Disable async reads\n"
           "    -o timeout=1.0         Caching timeout\n"
           "    -o timeout=0/1         Timeout is set\n"
           "    -o cache=never         Disable cache\n"
@@ -163,29 +169,36 @@ passthrough_ll_help(void) {
static void
init_handler(void* userdata, struct fuse_conn_info* conn) {
    struct u_data* ud = (struct u_data*) userdata;
    DEBUG_INFO(ud, "init handler readahead %i direct_io %i max_read2 %i",
    DEBUG_INFO(ud,
               "init handler: requested readahead %i direct_io %i max_read2 %i",
               ud->max_readahead, ud->direct_io, ud->max_read2);
    DEBUG_INFO(ud, "actual values: readahead %i direct_io %i max_read2 %i",
               conn->max_readahead, conn->max_read, conn->max_write);

    // TODO check other capabilities e.g. FUSE_CAP_READDIRPLUS
    if(ud->writeback) {
#if FUSE_MAJOR_VERSION > 3 ||                                                  \
        (FUSE_MAJOR_VERSION == 3 && FUSE_MINOR_VERSION >= 12)
    if(ud->writeback) {
        fuse_set_feature_flag(conn, FUSE_CAP_WRITEBACK_CACHE);
        DEBUG_INFO(ud, "init_handler: try to activate writeback");
    }
#else
        // for older fuse versions like on the ubuntu22
    if(ud->writeback) {
        conn->want |= FUSE_CAP_WRITEBACK_CACHE;
#endif
        DEBUG_INFO(ud, "init_handler: try to activate writeback");
    }
    // if(lo->flock && conn->capable & FUSE_CAP_FLOCK_LOCKS) {
    //     has_flag = fuse_set_feature_flag(conn, FUSE_CAP_FLOCK_LOCKS);
    //     if(lo->debug && has_flag)
    //         fuse_log(FUSE_LOG_DEBUG, "init_handler: activating flock
    //         locks\n");
    // }
    // TODO make this optional!!!
    // see conn->max_background description
    conn->max_background = 16;
    conn->want |= FUSE_CAP_ASYNC_DIO;
    conn->want |= FUSE_CAP_READDIRPLUS;
    conn->want |= FUSE_CAP_SPLICE_READ;
    conn->want |= FUSE_CAP_SPLICE_MOVE;
    conn->want |= FUSE_CAP_SPLICE_WRITE;
#endif

    /* Disable the receiving and processing of FUSE_INTERRUPT requests */
    // conn->no_interrupt = 1;

    conn->max_readahead = ud->max_readahead;
    conn->max_read = ud->max_read2;
}
@@ -233,6 +246,8 @@ lookup_handler(fuse_req_t req, fuse_ino_t parent, const char* name) {
    }

    // See if we already have this path
    // TODO Do we have to lock here? The test ends up in a deadlock!
    // std::lock_guard<std::mutex> lk(ino_mutex);
    auto it = path_map.find(child);
    fuse_ino_t ino;
    if(it != path_map.end()) {