Skip to content

asynchronous IO processing at FUSE layer #593

@vishnuitta

Description

@vishnuitta

currently, go-fuse supports multiple background threads which reads IO, and processes them by handing over to fs implementation.

Consider the case where my client is single threaded but can do asynchronous IO, i.e, sends a request, waits for ACK but need not the complete response to send next request and process the out-of-order responses. In such cases, this multiple background thread approach won't help as there is no concept of sending ACKs. Such clients are worker threads of loop devices that are mounted using direct_io=on over a file on FUSE.

However, such clients are supported by using low-level fuse APIs in C language. For ex., C code would look like:

static void ll_read(fuse_req_t req, fuse_ino_t ino, size_t size,
                    off_t off, struct fuse_file_info *fi) {
    (void) fi;
    if (ino != FILE_INODE) {
        fuse_reply_err(req, EISDIR);
        return;
    }
    // Main thread just pushes. It does not wait.
    push_async_job(req, OP_READ, size, off, NULL);
}
// worker thread to pick job from queues
void *worker_thread_func(void *arg) {
.
.
    while (1) {
        pthread_mutex_lock(&worker.lock);
        // Pop the job
        // Unlock immediately so other threads can pick up other jobs!
        pthread_mutex_unlock(&worker.lock);

        // --- PERFORM PARALLEL BLOCKING I/O ---
        // Since we are unlocked, other threads can process other requests here.
        
        if (task->type == OP_READ) {
                // Process read IO and at the end call fuse_reply_buf
.
.
                    fuse_reply_buf(task->req, buffer, res);
            }

        } else if (task->type == OP_WRITE) {
                // Process write IO
.
.
                fuse_reply_write(task->req, res);
        }
.
.
    return NULL;
}

I'm not able to have equivalent Go code with go-fuse.
Is it possible to support such behaviour (single threaded, but asynchronous IO processing) of clients with this fuse to have high performance by doing multiple IO processing at FS implementations?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions