@@ -380,6 +380,15 @@ static void virtio_fs_hiprio_done_work(struct work_struct *work)
spin_unlock(&fsvq->lock);
}
+static void end_req_dec_in_flight(struct fuse_req *req,
+ struct virtio_fs_vq *fsvq)
+{
+ fuse_request_end(req);
+ spin_lock(&fsvq->lock);
+ dec_in_flight_req(fsvq);
+ spin_unlock(&fsvq->lock);
+}
+
static void virtio_fs_request_dispatch_work(struct work_struct *work)
{
struct fuse_req *req;
@@ -425,12 +434,9 @@ static void virtio_fs_request_dispatch_work(struct work_struct *work)
return;
}
req->out.h.error = ret;
- spin_lock(&fsvq->lock);
- dec_in_flight_req(fsvq);
- spin_unlock(&fsvq->lock);
pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n",
ret);
- fuse_request_end(req);
+ end_req_dec_in_flight(req, fsvq);
}
}
}
@@ -709,10 +715,7 @@ static void virtio_fs_request_complete(struct fuse_req *req,
}
}
- fuse_request_end(req);
- spin_lock(&fsvq->lock);
- dec_in_flight_req(fsvq);
- spin_unlock(&fsvq->lock);
+ end_req_dec_in_flight(req, fsvq);
}
static void virtio_fs_complete_req_work(struct work_struct *work)
Add a helper function to end fuse request and decrement number of inflight requests. This pattern is already used at two places and I am planning to use it two more times in later patches. Adding a helper reduces number of lines of code and improves readability. Signed-off-by: Vivek Goyal <vgoyal@redhat.com> --- fs/fuse/virtio_fs.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)