Commit 83cfd493 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Linus Torvalds

[PATCH] fuse: introduce unified request state

The state of request was made up of 2 bitfields (->sent and ->finished) and of
the fact that the request was on a list or not.

Unify this into a single state field.
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 6383bdaa
...@@ -181,7 +181,7 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) ...@@ -181,7 +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)
{ {
req->finished = 1; req->state = FUSE_REQ_FINISHED;
spin_unlock(&fuse_lock); spin_unlock(&fuse_lock);
if (req->background) { if (req->background) {
down_read(&fc->sbput_sem); down_read(&fc->sbput_sem);
...@@ -250,10 +250,10 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req) ...@@ -250,10 +250,10 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
spin_unlock(&fuse_lock); spin_unlock(&fuse_lock);
block_sigs(&oldset); block_sigs(&oldset);
wait_event_interruptible(req->waitq, req->finished); wait_event_interruptible(req->waitq, req->state == FUSE_REQ_FINISHED);
restore_sigs(&oldset); restore_sigs(&oldset);
spin_lock(&fuse_lock); spin_lock(&fuse_lock);
if (req->finished) if (req->state == FUSE_REQ_FINISHED)
return; return;
req->out.h.error = -EINTR; req->out.h.error = -EINTR;
...@@ -268,10 +268,10 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req) ...@@ -268,10 +268,10 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
wait_event(req->waitq, !req->locked); wait_event(req->waitq, !req->locked);
spin_lock(&fuse_lock); spin_lock(&fuse_lock);
} }
if (!req->sent && !list_empty(&req->list)) { if (req->state == FUSE_REQ_PENDING) {
list_del(&req->list); list_del(&req->list);
__fuse_put_request(req); __fuse_put_request(req);
} else if (!req->finished && req->sent) } else if (req->state == FUSE_REQ_SENT)
background_request(fc, req); background_request(fc, req);
} }
...@@ -306,6 +306,7 @@ static void queue_request(struct fuse_conn *fc, struct fuse_req *req) ...@@ -306,6 +306,7 @@ static void queue_request(struct fuse_conn *fc, struct fuse_req *req)
fc->outstanding_debt++; fc->outstanding_debt++;
} }
list_add_tail(&req->list, &fc->pending); list_add_tail(&req->list, &fc->pending);
req->state = FUSE_REQ_PENDING;
wake_up(&fc->waitq); wake_up(&fc->waitq);
} }
...@@ -639,6 +640,7 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov, ...@@ -639,6 +640,7 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov,
goto err_unlock; goto err_unlock;
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;
list_del_init(&req->list); list_del_init(&req->list);
in = &req->in; in = &req->in;
...@@ -672,7 +674,7 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov, ...@@ -672,7 +674,7 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov,
if (!req->isreply) if (!req->isreply)
request_end(fc, req); request_end(fc, req);
else { else {
req->sent = 1; req->state = FUSE_REQ_SENT;
list_add_tail(&req->list, &fc->processing); list_add_tail(&req->list, &fc->processing);
spin_unlock(&fuse_lock); spin_unlock(&fuse_lock);
} }
......
...@@ -111,6 +111,15 @@ struct fuse_out { ...@@ -111,6 +111,15 @@ struct fuse_out {
struct fuse_arg args[3]; struct fuse_arg args[3];
}; };
/** The request state */
enum fuse_req_state {
FUSE_REQ_INIT = 0,
FUSE_REQ_PENDING,
FUSE_REQ_READING,
FUSE_REQ_SENT,
FUSE_REQ_FINISHED
};
/** /**
* A request to the client * A request to the client
*/ */
...@@ -140,11 +149,8 @@ struct fuse_req { ...@@ -140,11 +149,8 @@ struct fuse_req {
/** Data is being copied to/from the request */ /** Data is being copied to/from the request */
unsigned locked:1; unsigned locked:1;
/** Request has been sent to userspace */ /** State of the request */
unsigned sent:1; enum fuse_req_state state;
/** The request is finished */
unsigned finished:1;
/** The request input */ /** The request input */
struct fuse_in in; struct fuse_in in;
......
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