From: Vivek Goyal <vgoyal@redhat.com>
To: linux-fsdevel@vger.kernel.org, virtio-fs@redhat.com,
miklos@szeredi.hu, stefanha@redhat.com
Cc: vgoyal@redhat.com, iangelak@redhat.com, jaggel@bu.edu,
dgilbert@redhat.com
Subject: [PATCH 6/8] virtiofs: Add a helper to end request and decrement inflight number
Date: Thu, 30 Sep 2021 10:38:48 -0400 [thread overview]
Message-ID: <20210930143850.1188628-7-vgoyal@redhat.com> (raw)
In-Reply-To: <20210930143850.1188628-1-vgoyal@redhat.com>
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(-)
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index b70a22a79901..8d33879d62fb 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -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)
--
2.31.1
next prev parent reply other threads:[~2021-09-30 14:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-30 14:38 [PATCH 0/8] virtiofs: Notification queue and blocking posix locks Vivek Goyal
2021-09-30 14:38 ` [PATCH 1/8] virtiofs: Disable interrupt requests properly Vivek Goyal
2021-09-30 14:38 ` [PATCH 2/8] virtiofs: Fix a comment about fuse_dev allocation Vivek Goyal
2021-09-30 14:38 ` [PATCH 3/8] virtiofs: Add an index to keep track of first request queue Vivek Goyal
2021-09-30 14:38 ` [PATCH 4/8] virtiofs: Decouple queue index and queue type Vivek Goyal
2021-09-30 14:38 ` [PATCH 5/8] virtiofs: Add a virtqueue for notifications Vivek Goyal
2021-10-06 12:46 ` Miklos Szeredi
2021-10-06 12:54 ` Vivek Goyal
2021-09-30 14:38 ` Vivek Goyal [this message]
2021-09-30 14:38 ` [PATCH 7/8] virtiofs: Add new notification type FUSE_NOTIFY_LOCK Vivek Goyal
2021-10-06 12:55 ` Miklos Szeredi
2021-10-06 15:01 ` Vivek Goyal
2021-10-06 13:02 ` Miklos Szeredi
2021-10-06 16:12 ` Vivek Goyal
2021-10-07 13:45 ` Miklos Szeredi
2021-10-07 14:21 ` Vivek Goyal
2021-10-07 18:11 ` Miklos Szeredi
2021-10-07 18:32 ` Vivek Goyal
2021-10-07 18:46 ` Miklos Szeredi
2021-09-30 14:38 ` [PATCH 8/8] virtiofs: Handle reordering of reply and notification event Vivek Goyal
2021-09-30 15:43 ` [PATCH 0/8] virtiofs: Notification queue and blocking posix locks Vivek Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210930143850.1188628-7-vgoyal@redhat.com \
--to=vgoyal@redhat.com \
--cc=dgilbert@redhat.com \
--cc=iangelak@redhat.com \
--cc=jaggel@bu.edu \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=stefanha@redhat.com \
--cc=virtio-fs@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).