Commit d77a1d5b authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Linus Torvalds

[PATCH] fuse: introduce list for requests under I/O

Create a new list for requests in the process of being transfered to/from
userspace.  This will be needed to be able to abort all requests even those
currently under I/O
Signed-off-by: default avatarMiklos Szeredi <miklos@szeredi.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 83cfd493
...@@ -181,6 +181,7 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) ...@@ -181,6 +181,7 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
*/ */
static void request_end(struct fuse_conn *fc, struct fuse_req *req) static void request_end(struct fuse_conn *fc, struct fuse_req *req)
{ {
list_del(&req->list);
req->state = FUSE_REQ_FINISHED; req->state = FUSE_REQ_FINISHED;
spin_unlock(&fuse_lock); spin_unlock(&fuse_lock);
if (req->background) { if (req->background) {
...@@ -641,7 +642,7 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov, ...@@ -641,7 +642,7 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov,
req = list_entry(fc->pending.next, struct fuse_req, list); req = list_entry(fc->pending.next, struct fuse_req, list);
req->state = FUSE_REQ_READING; req->state = FUSE_REQ_READING;
list_del_init(&req->list); list_move(&req->list, &fc->io);
in = &req->in; in = &req->in;
reqsize = in->h.len; reqsize = in->h.len;
...@@ -675,7 +676,7 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov, ...@@ -675,7 +676,7 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov,
request_end(fc, req); request_end(fc, req);
else { else {
req->state = FUSE_REQ_SENT; req->state = FUSE_REQ_SENT;
list_add_tail(&req->list, &fc->processing); list_move_tail(&req->list, &fc->processing);
spin_unlock(&fuse_lock); spin_unlock(&fuse_lock);
} }
return reqsize; return reqsize;
...@@ -768,7 +769,6 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov, ...@@ -768,7 +769,6 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov,
if (!req) if (!req)
goto err_unlock; goto err_unlock;
list_del_init(&req->list);
if (req->interrupted) { if (req->interrupted) {
spin_unlock(&fuse_lock); spin_unlock(&fuse_lock);
fuse_copy_finish(&cs); fuse_copy_finish(&cs);
...@@ -776,6 +776,7 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov, ...@@ -776,6 +776,7 @@ static ssize_t fuse_dev_writev(struct file *file, const struct iovec *iov,
request_end(fc, req); request_end(fc, req);
return -ENOENT; return -ENOENT;
} }
list_move(&req->list, &fc->io);
req->out.h = oh; req->out.h = oh;
req->locked = 1; req->locked = 1;
cs.req = req; cs.req = req;
...@@ -835,7 +836,6 @@ static void end_requests(struct fuse_conn *fc, struct list_head *head) ...@@ -835,7 +836,6 @@ static void end_requests(struct fuse_conn *fc, struct list_head *head)
while (!list_empty(head)) { while (!list_empty(head)) {
struct fuse_req *req; struct fuse_req *req;
req = list_entry(head->next, struct fuse_req, list); req = list_entry(head->next, struct fuse_req, list);
list_del_init(&req->list);
req->out.h.error = -ECONNABORTED; req->out.h.error = -ECONNABORTED;
request_end(fc, req); request_end(fc, req);
spin_lock(&fuse_lock); spin_lock(&fuse_lock);
......
...@@ -124,8 +124,8 @@ enum fuse_req_state { ...@@ -124,8 +124,8 @@ enum fuse_req_state {
* A request to the client * A request to the client
*/ */
struct fuse_req { struct fuse_req {
/** This can be on either unused_list, pending or processing /** This can be on either unused_list, pending processing or
lists in fuse_conn */ io lists in fuse_conn */
struct list_head list; struct list_head list;
/** Entry on the background list */ /** Entry on the background list */
...@@ -223,6 +223,9 @@ struct fuse_conn { ...@@ -223,6 +223,9 @@ struct fuse_conn {
/** The list of requests being processed */ /** The list of requests being processed */
struct list_head processing; struct list_head processing;
/** The list of requests under I/O */
struct list_head io;
/** Requests put in the background (RELEASE or any other /** Requests put in the background (RELEASE or any other
interrupted request) */ interrupted request) */
struct list_head background; struct list_head background;
......
...@@ -382,6 +382,7 @@ static struct fuse_conn *new_conn(void) ...@@ -382,6 +382,7 @@ static struct fuse_conn *new_conn(void)
init_waitqueue_head(&fc->waitq); init_waitqueue_head(&fc->waitq);
INIT_LIST_HEAD(&fc->pending); INIT_LIST_HEAD(&fc->pending);
INIT_LIST_HEAD(&fc->processing); INIT_LIST_HEAD(&fc->processing);
INIT_LIST_HEAD(&fc->io);
INIT_LIST_HEAD(&fc->unused_list); INIT_LIST_HEAD(&fc->unused_list);
INIT_LIST_HEAD(&fc->background); INIT_LIST_HEAD(&fc->background);
sema_init(&fc->outstanding_sem, 1); /* One for INIT */ sema_init(&fc->outstanding_sem, 1); /* One for INIT */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment