Skip to content

Commit

Permalink
fuse: add req flag for private list
Browse files Browse the repository at this point in the history
When an unlocked request is aborted, it is moved from fpq->io to a private
list.  Then, after unlocking fpq->lock, the private list is processed and
the requests are finished off.

To protect the private list, we need to mark the request with a flag, so if
in the meantime the request is unlocked the list is not corrupted.

Signed-off-by: Miklos Szeredi <[email protected]>
Reviewed-by: Ashish Samant <[email protected]>
  • Loading branch information
Miklos Szeredi committed Jul 1, 2015
1 parent 45a91cb commit 77cd9d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fs/fuse/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,8 @@ static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
return reqsize;

out_end:
list_del_init(&req->list);
if (!test_bit(FR_PRIVATE, &req->flags))
list_del_init(&req->list);
spin_unlock(&fpq->lock);
request_end(fc, req);
return err;
Expand Down Expand Up @@ -1945,7 +1946,8 @@ static ssize_t fuse_dev_do_write(struct fuse_conn *fc,
err = -ENOENT;
else if (err)
req->out.h.error = -EIO;
list_del_init(&req->list);
if (!test_bit(FR_PRIVATE, &req->flags))
list_del_init(&req->list);
spin_unlock(&fpq->lock);
request_end(fc, req);

Expand Down Expand Up @@ -2149,8 +2151,10 @@ void fuse_abort_conn(struct fuse_conn *fc)
req->out.h.error = -ECONNABORTED;
spin_lock(&req->waitq.lock);
set_bit(FR_ABORTED, &req->flags);
if (!test_bit(FR_LOCKED, &req->flags))
if (!test_bit(FR_LOCKED, &req->flags)) {
set_bit(FR_PRIVATE, &req->flags);
list_move(&req->list, &to_end1);
}
spin_unlock(&req->waitq.lock);
}
list_splice_init(&fpq->processing, &to_end2);
Expand Down
2 changes: 2 additions & 0 deletions fs/fuse/fuse_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ struct fuse_io_priv {
* FR_PENDING: request is not yet in userspace
* FR_SENT: request is in userspace, waiting for an answer
* FR_FINISHED: request is finished
* FR_PRIVATE: request is on private list
*/
enum fuse_req_flag {
FR_ISREPLY,
Expand All @@ -281,6 +282,7 @@ enum fuse_req_flag {
FR_PENDING,
FR_SENT,
FR_FINISHED,
FR_PRIVATE,
};

/**
Expand Down

0 comments on commit 77cd9d4

Please sign in to comment.