Skip to content

Commit

Permalink
[fuse] fix preventing suspend
Browse files Browse the repository at this point in the history
  • Loading branch information
calebccff committed Feb 19, 2020
1 parent f51f3d4 commit 9b1e1f8
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions fs/fuse/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ void fuse_request_free(struct fuse_req *req)
kmem_cache_free(fuse_req_cachep, req);
}

static void block_sigs(sigset_t *oldset)
{
sigset_t mask;

siginitsetinv(&mask, sigmask(SIGKILL));
sigprocmask(SIG_BLOCK, &mask, oldset);
}

static void restore_sigs(sigset_t *oldset)
{
sigprocmask(SIG_SETMASK, oldset, NULL);
}

void __fuse_get_request(struct fuse_req *req)
{
atomic_inc(&req->count);
Expand Down Expand Up @@ -151,9 +164,15 @@ static struct fuse_req *__fuse_get_req(struct fuse_conn *fc, unsigned npages,
atomic_inc(&fc->num_waiting);

if (fuse_block_alloc(fc, for_background)) {
sigset_t oldset;
int intr;

block_sigs(&oldset);
intr = wait_event_interruptible_exclusive(fc->blocked_waitq,
!fuse_block_alloc(fc, for_background));
restore_sigs(&oldset);
err = -EINTR;
if (wait_event_killable_exclusive(fc->blocked_waitq,
!fuse_block_alloc(fc, for_background)))
if (intr)
goto out;
}
/* Matches smp_wmb() in fuse_set_initialized() */
Expand Down Expand Up @@ -452,9 +471,14 @@ static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
}

if (!test_bit(FR_FORCE, &req->flags)) {
sigset_t oldset;

/* Only fatal signals may interrupt this */
err = wait_event_killable(req->waitq,
block_sigs(&oldset);
err = wait_event_interruptible(req->waitq,
test_bit(FR_FINISHED, &req->flags));
restore_sigs(&oldset);

if (!err)
return;

Expand Down

0 comments on commit 9b1e1f8

Please sign in to comment.