Commit ff5457df authored by sevenuz's avatar sevenuz Committed by Julius Athenstaedt
Browse files

readahead and direct io as client options

parent 918dfe08
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -115,9 +115,11 @@ struct u_data {
    pthread_mutex_t mutex;
    int debug;
    int writeback;
    int direct_io;
    int max_readahead;
    int flock;
    int xattr;
    char* source;
    char* mountpoint;
    double timeout;
    int cache;
    int timeout_set;
+16 −7
Original line number Diff line number Diff line
@@ -81,6 +81,9 @@ get_path(const Inode* inode, const char* name) {
static const struct fuse_opt lo_opts[] = {
        {"writeback", offsetof(struct u_data, writeback), 1},
        {"no_writeback", offsetof(struct u_data, writeback), 0},
        {"direct_io", offsetof(struct u_data, direct_io), 1},
        {"no_direct_io", offsetof(struct u_data, direct_io), 0},
        {"max_readahead=%ui", offsetof(struct u_data, max_readahead), 0},
        {"flock", offsetof(struct u_data, flock), 1},
        {"no_flock", offsetof(struct u_data, flock), 0},
        {"xattr", offsetof(struct u_data, xattr), 1},
@@ -97,7 +100,9 @@ static void
passthrough_ll_help(void) {
    printf("    -o writeback           Enable writeback\n"
           "    -o no_writeback        Disable write back\n"
           "    -o source=/home/dir    Source directory to be mounted\n"
           "    -o direct_io           Enables direct io\n"
           "    -o no_direct_io        Disable direct io\n"
           "    -o max_readahead=1     Amount of allowed readaheads\n"
           "    -o flock               Enable flock\n"
           "    -o no_flock            Disable flock\n"
           "    -o xattr               Enable xattr\n"
@@ -111,8 +116,8 @@ passthrough_ll_help(void) {

static void
init_handler(void* userdata, struct fuse_conn_info* conn) {
    fuse_log(FUSE_LOG_DEBUG, "init handler \n");
    // struct u_data* lo = (struct u_data*) userdata;
    struct u_data* ud = (struct u_data*) userdata;
    fuse_log(FUSE_LOG_DEBUG, "init handler readahead %i direct_io %i \n", ud->max_readahead, ud->direct_io);
    // bool has_flag;

    // TODO check other capabilities e.g. FUSE_CAP_READDIRPLUS
@@ -130,6 +135,7 @@ init_handler(void* userdata, struct fuse_conn_info* conn) {

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

static void
@@ -235,6 +241,7 @@ setattr_handler(fuse_req_t req, fuse_ino_t ino, struct stat* attr, int to_set,
static void
open_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) {
    fuse_log(FUSE_LOG_DEBUG, "open handler \n");
    auto* ud = udata(req);
    auto* inode = get_inode(ino);
    if(!inode) {
        fuse_reply_err(req, ENOENT);
@@ -248,6 +255,7 @@ open_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) {
        return;
    }
    fi->fh = fd; // TODO file handle == file descriptor?
    fi->direct_io = ud->direct_io;
    fuse_reply_open(req, fi);
}

@@ -325,6 +333,7 @@ create_handler(fuse_req_t req, fuse_ino_t parent, const char* name, mode_t mode,
        return;
    }
    fi->fh = fd;
    fi->direct_io = ud->direct_io;
    struct stat st;
    int sc = gkfs::syscall::gkfs_stat(path, &st);
    if(sc == -1) {
@@ -665,10 +674,10 @@ symlink_handler(fuse_req_t req, const char* linkname, fuse_ino_t parent,
    std::string path = get_path(parent_inode, name);
    std::string target = get_path(parent_inode, linkname);

    if(target.rfind(ud->source, 0) == 0) {
    if(target.rfind(ud->mountpoint, 0) == 0) {
        // starts with mount path
        target = get_path(parent_inode,
                          target.substr(strlen(ud->source)).c_str());
                          target.substr(strlen(ud->mountpoint)).c_str());
    }

    fuse_log(FUSE_LOG_DEBUG, "mk symlink path %s target %s\n", path.c_str(),
@@ -879,7 +888,7 @@ init_ll_ops(fuse_lowlevel_ops* ops) {
void
err_cleanup1(fuse_cmdline_opts opts, fuse_args& args, struct u_data& ud) {
    free(opts.mountpoint);
    free(ud.source);
    free(ud.mountpoint);
    fuse_opt_free_args(&args);
    std::cout << "# Resources released" << std::endl;
}
@@ -964,7 +973,7 @@ main(int argc, char* argv[]) {
    }


    ud.source = strdup(opts.mountpoint);
    ud.mountpoint = strdup(opts.mountpoint);
    init_gekkofs();