Skip to content

Commit

Permalink
fuse: request_end(): do once
Browse files Browse the repository at this point in the history
When the connection is aborted it is possible that request_end() will be
called twice.  Use atomic test and set to do the actual ending only once.

test_and_set_bit() also provides the necessary barrier semantics so no
explicit smp_wmb() is necessary.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Reviewed-by: Ashish Samant <ashish.samant@oracle.com>
  • Loading branch information
Miklos Szeredi committed Jul 1, 2015
1 parent 77cd9d4 commit 365ae71
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fs/fuse/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,18 @@ __releases(fc->lock)
{
struct fuse_iqueue *fiq = &fc->iq;
void (*end) (struct fuse_conn *, struct fuse_req *) = req->end;

if (test_and_set_bit(FR_FINISHED, &req->flags)) {
spin_unlock(&fc->lock);
return;
}

req->end = NULL;
spin_lock(&fiq->waitq.lock);
list_del_init(&req->intr_entry);
spin_unlock(&fiq->waitq.lock);
WARN_ON(test_bit(FR_PENDING, &req->flags));
WARN_ON(test_bit(FR_SENT, &req->flags));
smp_wmb();
set_bit(FR_FINISHED, &req->flags);
if (test_bit(FR_BACKGROUND, &req->flags)) {
clear_bit(FR_BACKGROUND, &req->flags);
if (fc->num_background == fc->max_background)
Expand Down

0 comments on commit 365ae71

Please sign in to comment.