Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 373782
b: refs/heads/master
c: 722d2be
h: refs/heads/master
v: v3
  • Loading branch information
Maxim Patlasov authored and Miklos Szeredi committed Apr 17, 2013
1 parent 1304b5d commit 3099109
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0aada88476a33690c9569b094191ce92a38e6541
refs/heads/master: 722d2bea8c601d0744e4a37170533fdf6214a678
29 changes: 24 additions & 5 deletions trunk/fs/fuse/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static struct fuse_req *__fuse_get_req(struct fuse_conn *fc, unsigned npages,
int intr;

block_sigs(&oldset);
intr = wait_event_interruptible(fc->blocked_waitq,
intr = wait_event_interruptible_exclusive(fc->blocked_waitq,
!fuse_block_alloc(fc, for_background));
restore_sigs(&oldset);
err = -EINTR;
Expand All @@ -161,8 +161,11 @@ static struct fuse_req *__fuse_get_req(struct fuse_conn *fc, unsigned npages,

req = fuse_request_alloc(npages);
err = -ENOMEM;
if (!req)
if (!req) {
if (for_background)
wake_up(&fc->blocked_waitq);
goto out;
}

fuse_req_init_context(req);
req->waiting = 1;
Expand Down Expand Up @@ -262,6 +265,17 @@ struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc,
void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req)
{
if (atomic_dec_and_test(&req->count)) {
if (unlikely(req->background)) {
/*
* We get here in the unlikely case that a background
* request was allocated but not sent
*/
spin_lock(&fc->lock);
if (!fc->blocked)
wake_up(&fc->blocked_waitq);
spin_unlock(&fc->lock);
}

if (req->waiting)
atomic_dec(&fc->num_waiting);

Expand Down Expand Up @@ -359,10 +373,15 @@ __releases(fc->lock)
list_del(&req->intr_entry);
req->state = FUSE_REQ_FINISHED;
if (req->background) {
if (fc->num_background == fc->max_background) {
req->background = 0;

if (fc->num_background == fc->max_background)
fc->blocked = 0;
wake_up_all(&fc->blocked_waitq);
}

/* Wake up next waiter, if any */
if (!fc->blocked)
wake_up(&fc->blocked_waitq);

if (fc->num_background == fc->congestion_threshold &&
fc->connected && fc->bdi_initialized) {
clear_bdi_congested(&fc->bdi, BLK_RW_SYNC);
Expand Down

0 comments on commit 3099109

Please sign in to comment.