diff options
Diffstat (limited to 'fs/fuse/dev.c')
-rw-r--r-- | fs/fuse/dev.c | 67 |
1 files changed, 49 insertions, 18 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 2aaf3ea..5a6c6dc 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -19,6 +19,9 @@ #include <linux/pipe_fs_i.h> #include <linux/swap.h> #include <linux/splice.h> +#include <linux/iocontext.h> +#include <linux/ioprio.h> +#include <linux/freezer.h> MODULE_ALIAS_MISCDEV(FUSE_MINOR); MODULE_ALIAS("devname:fuse"); @@ -237,17 +240,39 @@ static u64 fuse_get_unique(struct fuse_conn *fc) return fc->reqctr; } +static inline int is_rt(struct fuse_conn *fc) +{ + /* Returns 1 if request is RT class */ + /* && FUSE_HANDLE_RT_CLASS bit of fc->flags is set. */ + /* FUSE_HANDLE_RT_CLASS bit is set by 'handle_rt_class' */ + /* mount option while mounting a file system. */ + struct io_context *ioc; + + if (!fc) + return 0; + + if (!(fc->flags & FUSE_HANDLE_RT_CLASS)) /* Don't handle RT class */ + return 0; + + ioc = get_io_context(GFP_NOWAIT, 0); + if (ioc && IOPRIO_PRIO_CLASS(ioc->ioprio) == IOPRIO_CLASS_RT) + return 1; + + return 0; +} + + static void queue_request(struct fuse_conn *fc, struct fuse_req *req) { req->in.h.len = sizeof(struct fuse_in_header) + len_args(req->in.numargs, (struct fuse_arg *) req->in.args); - list_add_tail(&req->list, &fc->pending); + list_add_tail(&req->list, &fc->pending[is_rt(fc)]); req->state = FUSE_REQ_PENDING; if (!req->waiting) { req->waiting = 1; atomic_inc(&fc->num_waiting); } - wake_up(&fc->waitq); + wake_up(&fc->waitq[is_rt(fc)]); kill_fasync(&fc->fasync, SIGIO, POLL_IN); } @@ -261,7 +286,7 @@ void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, if (fc->connected) { fc->forget_list_tail->next = forget; fc->forget_list_tail = forget; - wake_up(&fc->waitq); + wake_up(&fc->waitq[is_rt(fc)]); kill_fasync(&fc->fasync, SIGIO, POLL_IN); } else { kfree(forget); @@ -337,8 +362,8 @@ __acquires(fc->lock) static void queue_interrupt(struct fuse_conn *fc, struct fuse_req *req) { - list_add_tail(&req->intr_entry, &fc->interrupts); - wake_up(&fc->waitq); + list_add_tail(&req->intr_entry, &fc->interrupts[is_rt(fc)]); + wake_up(&fc->waitq[is_rt(fc)]); kill_fasync(&fc->fasync, SIGIO, POLL_IN); } @@ -387,7 +412,10 @@ __acquires(fc->lock) * Wait it out. */ spin_unlock(&fc->lock); - wait_event(req->waitq, req->state == FUSE_REQ_FINISHED); + + while (req->state != FUSE_REQ_FINISHED) + wait_event_freezable(req->waitq, + req->state == FUSE_REQ_FINISHED); spin_lock(&fc->lock); if (!req->aborted) @@ -913,8 +941,8 @@ static int forget_pending(struct fuse_conn *fc) static int request_pending(struct fuse_conn *fc) { - return !list_empty(&fc->pending) || !list_empty(&fc->interrupts) || - forget_pending(fc); + return !list_empty(&fc->pending[is_rt(fc)]) || + !list_empty(&fc->interrupts[is_rt(fc)]) || forget_pending(fc); } /* Wait until a request is available on the pending list */ @@ -924,7 +952,7 @@ __acquires(fc->lock) { DECLARE_WAITQUEUE(wait, current); - add_wait_queue_exclusive(&fc->waitq, &wait); + add_wait_queue_exclusive(&fc->waitq[is_rt(fc)], &wait); while (fc->connected && !request_pending(fc)) { set_current_state(TASK_INTERRUPTIBLE); if (signal_pending(current)) @@ -935,7 +963,7 @@ __acquires(fc->lock) spin_lock(&fc->lock); } set_current_state(TASK_RUNNING); - remove_wait_queue(&fc->waitq, &wait); + remove_wait_queue(&fc->waitq[is_rt(fc)], &wait); } /* @@ -1122,21 +1150,22 @@ static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file, if (!request_pending(fc)) goto err_unlock; - if (!list_empty(&fc->interrupts)) { - req = list_entry(fc->interrupts.next, struct fuse_req, - intr_entry); + if (!list_empty(&fc->interrupts[is_rt(fc)])) { + req = list_entry(fc->interrupts[is_rt(fc)].next, + struct fuse_req, intr_entry); return fuse_read_interrupt(fc, cs, nbytes, req); } if (forget_pending(fc)) { - if (list_empty(&fc->pending) || fc->forget_batch-- > 0) + if (list_empty(&fc->pending[is_rt(fc)]) || + fc->forget_batch-- > 0) return fuse_read_forget(fc, cs, nbytes); if (fc->forget_batch <= -8) fc->forget_batch = 16; } - req = list_entry(fc->pending.next, struct fuse_req, list); + req = list_entry(fc->pending[is_rt(fc)].next, struct fuse_req, list); req->state = FUSE_REQ_READING; list_move(&req->list, &fc->io); @@ -1838,7 +1867,7 @@ static unsigned fuse_dev_poll(struct file *file, poll_table *wait) if (!fc) return POLLERR; - poll_wait(file, &fc->waitq, wait); + poll_wait(file, &fc->waitq[is_rt(fc)], wait); spin_lock(&fc->lock); if (!fc->connected) @@ -1911,7 +1940,8 @@ __acquires(fc->lock) { fc->max_background = UINT_MAX; flush_bg_queue(fc); - end_requests(fc, &fc->pending); + end_requests(fc, &fc->pending[0]); + end_requests(fc, &fc->pending[1]); end_requests(fc, &fc->processing); while (forget_pending(fc)) kfree(dequeue_forget(fc, 1, NULL)); @@ -1960,7 +1990,8 @@ void fuse_abort_conn(struct fuse_conn *fc) end_io_requests(fc); end_queued_requests(fc); end_polls(fc); - wake_up_all(&fc->waitq); + wake_up_all(&fc->waitq[0]); + wake_up_all(&fc->waitq[1]); wake_up_all(&fc->blocked_waitq); kill_fasync(&fc->fasync, SIGIO, POLL_IN); } |