Commit 8dc9810c authored by Julius Athenstaedt's avatar Julius Athenstaedt Committed by Ramon Nou
Browse files

optional features for fuse: max_write, max_background, splice

parent 0865164b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -126,7 +126,10 @@ struct u_data {
    int direct_io;
    int max_readahead;
    int max_read2;
    int max_write;
    int max_background;
    int fifo;
    int splice;
    int access;
    int xattr;
    char* mountpoint;
+41 −11
Original line number Diff line number Diff line
@@ -126,8 +126,12 @@ static const struct fuse_opt lo_opts[] = {
        {"no_direct_io", offsetof(struct u_data, direct_io), 0},
        {"max_readahead=%ui", offsetof(struct u_data, max_readahead), 0},
        {"max_read2=%ui", offsetof(struct u_data, max_read2), 0},
        {"max_write=%ui", offsetof(struct u_data, max_write), 0},
        {"max_background=%ui", offsetof(struct u_data, max_background), 0},
        {"fifo", offsetof(struct u_data, fifo), 1},
        {"no_fifo", offsetof(struct u_data, fifo), 0},
        {"splice", offsetof(struct u_data, splice), 1},
        {"no_splice", offsetof(struct u_data, splice), 0},
        {"access", offsetof(struct u_data, access), 1},
        {"no_access", offsetof(struct u_data, access), 0},
        {"xattr", offsetof(struct u_data, xattr), 1},
@@ -150,9 +154,11 @@ passthrough_ll_help(void) {
           "    -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 max_background=0    Maximum number of pending \"background\" requests.\n"
           "    -o fifo                Enable fifo, disables GekkoFS access check\n"
           "    -o no_fifo             Disable fifo\n"
           "    -o splice              Enable splice for read, move, write\n"
           "    -o no_splice           Disable splice\n"
           "    -o access              Enable GekkoFS access check if fifo is deactivated\n"
           "    -o no_access           Disable access handler\n"
           "    -o xattr               Enable xattr\n"
@@ -172,7 +178,7 @@ init_handler(void* userdata, struct fuse_conn_info* conn) {
    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",
    DEBUG_INFO(ud, "current values: readahead %i direct_io %i max_read2 %i",
               conn->max_readahead, conn->max_read, conn->max_write);

#if FUSE_MAJOR_VERSION > 3 ||                                                  \
@@ -181,27 +187,51 @@ init_handler(void* userdata, struct fuse_conn_info* conn) {
        fuse_set_feature_flag(conn, FUSE_CAP_WRITEBACK_CACHE);
        DEBUG_INFO(ud, "init_handler: try to activate writeback");
    }
    // TODO copy the other feature flags here
#else
    if(ud->writeback) {
        conn->want |= FUSE_CAP_WRITEBACK_CACHE;
        DEBUG_INFO(ud, "init_handler: try to activate writeback");
    }
    // TODO make this optional!!!
    // see conn->max_background description
    conn->max_background = 16;
    // default activated if kernel supports it: FUSE_CAP_PARALLEL_DIROPS,
    // FUSE_CAP_ASYNC_DIO
    if(ud->max_background > 0) {
        conn->want |= FUSE_CAP_ASYNC_DIO;
    conn->want |= FUSE_CAP_READDIRPLUS;
    }

    // conn->want |= FUSE_CAP_READDIRPLUS;
    // conn->want |= FUSE_CAP_READDIRPLUS_AUTO;

    if(ud->splice) {
        conn->want |= FUSE_CAP_SPLICE_READ;
        conn->want |= FUSE_CAP_SPLICE_MOVE;
        conn->want |= FUSE_CAP_SPLICE_WRITE;
    } else {
        conn->want &= ~(FUSE_CAP_SPLICE_READ | FUSE_CAP_SPLICE_WRITE |
                        FUSE_CAP_SPLICE_MOVE);
    }

    // deactivated because of distributed nature of GekkoFS
    conn->want &= ~FUSE_CAP_CACHE_SYMLINKS;
#endif

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

    conn->max_readahead = ud->max_readahead;
    if(ud->max_background) {
        conn->max_background = ud->max_background;
    }
    if(ud->max_read2 > 0) {
        conn->max_read = ud->max_read2;
    }
    // TODO max_write one could fail in newer FUSE version because it exists
    // there by default!
    if(ud->max_write > 0) {
        conn->max_write = ud->max_write;
    }
}

static void
destroy_handler(void* userdata) {
@@ -991,8 +1021,8 @@ init_ll_ops(fuse_lowlevel_ops* ops) {
    ops->readdir = readdir_handler;
    ops->opendir = opendir_handler;
    ops->releasedir = releasedir_handler;
    // ops->readdirplus = readdirplus_handler;
    // ops->fsyncdir = nullptr;
    // ops->readdirplus

    // I/O
    ops->write = write_handler;