Commit 9bc5ddda authored by Miklos Szeredi's avatar Miklos Szeredi

[fuse] Fix accounting the number of waiting requests

Properly accounting the number of waiting requests was forgotten in
"clean up request accounting" patch.
Signed-off-by: default avatarMiklos Szeredi <miklos@szeredi.hu>
parent 73ce8355
...@@ -92,29 +92,38 @@ struct fuse_req *fuse_get_req(struct fuse_conn *fc) ...@@ -92,29 +92,38 @@ struct fuse_req *fuse_get_req(struct fuse_conn *fc)
{ {
struct fuse_req *req; struct fuse_req *req;
sigset_t oldset; sigset_t oldset;
int intr;
int err; int err;
atomic_inc(&fc->num_waiting);
block_sigs(&oldset); block_sigs(&oldset);
err = wait_event_interruptible(fc->blocked_waitq, !fc->blocked); intr = wait_event_interruptible(fc->blocked_waitq, !fc->blocked);
restore_sigs(&oldset); restore_sigs(&oldset);
if (err) err = -EINTR;
return ERR_PTR(-EINTR); if (intr)
goto out;
req = fuse_request_alloc(); req = fuse_request_alloc();
err = -ENOMEM;
if (!req) if (!req)
return ERR_PTR(-ENOMEM); goto out;
atomic_inc(&fc->num_waiting);
fuse_request_init(req); fuse_request_init(req);
req->in.h.uid = current->fsuid; req->in.h.uid = current->fsuid;
req->in.h.gid = current->fsgid; req->in.h.gid = current->fsgid;
req->in.h.pid = current->pid; req->in.h.pid = current->pid;
req->waiting = 1;
return req; return req;
out:
atomic_dec(&fc->num_waiting);
return ERR_PTR(err);
} }
void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req) void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req)
{ {
if (atomic_dec_and_test(&req->count)) { if (atomic_dec_and_test(&req->count)) {
if (req->waiting)
atomic_dec(&fc->num_waiting); atomic_dec(&fc->num_waiting);
fuse_request_free(req); fuse_request_free(req);
} }
...@@ -281,6 +290,10 @@ static void queue_request(struct fuse_conn *fc, struct fuse_req *req) ...@@ -281,6 +290,10 @@ static void queue_request(struct fuse_conn *fc, struct fuse_req *req)
len_args(req->in.numargs, (struct fuse_arg *) req->in.args); 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);
req->state = FUSE_REQ_PENDING; req->state = FUSE_REQ_PENDING;
if (!req->waiting) {
req->waiting = 1;
atomic_inc(&fc->num_waiting);
}
wake_up(&fc->waitq); wake_up(&fc->waitq);
kill_fasync(&fc->fasync, SIGIO, POLL_IN); kill_fasync(&fc->fasync, SIGIO, POLL_IN);
} }
......
...@@ -159,6 +159,9 @@ struct fuse_req { ...@@ -159,6 +159,9 @@ 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 is counted as "waiting" */
unsigned waiting:1;
/** State of the request */ /** State of the request */
enum fuse_req_state state; enum fuse_req_state state;
......
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