From: Greg Kurz <groug@kaod.org>
To: linux-kernel@vger.kernel.org
Cc: v9fs-developer@lists.sourceforge.net,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Al Viro <viro@ZenIV.linux.org.uk>
Subject: [PATCH 2/2] 9p/trans_virtio: implement cancelled callback
Date: Wed, 20 Dec 2017 18:46:52 +0100 [thread overview]
Message-ID: <151379201222.15509.5560840637636982207.stgit@bahia> (raw)
In-Reply-To: <151379198727.15509.2771563206512953068.stgit@bahia>
When 9p requests are successfully flushed, we must manually move the
associated buffers to the virtqueue freelist, since the server doesn't
send a reply.
Signed-off-by: Greg Kurz <groug@kaod.org>
---
net/9p/trans_virtio.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index f3a4efcf1456..d3216af124c4 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -206,6 +206,23 @@ static int p9_virtio_cancel(struct p9_client *client, struct p9_req_t *req)
return 1;
}
+static int p9_virtio_cancelled(struct p9_client *client, struct p9_req_t *req)
+{
+ struct virtio_chan *chan = client->trans;
+ unsigned long flags;
+
+ spin_lock_irqsave(&chan->lock, flags);
+ if (virtqueue_detach_buf(chan->vq, req) != req) {
+ spin_unlock_irqrestore(&chan->lock, flags);
+ return 0;
+ }
+ chan->ring_bufs_avail = 1;
+ spin_unlock_irqrestore(&chan->lock, flags);
+ /* Wakeup if anyone waiting for VirtIO ring space. */
+ wake_up(chan->vc_wq);
+ return 0;
+}
+
/**
* pack_sg_list_p - Just like pack_sg_list. Instead of taking a buffer,
* this takes a list of pages.
@@ -737,6 +754,7 @@ static struct p9_trans_module p9_virtio_trans = {
.request = p9_virtio_request,
.zc_request = p9_virtio_zc_request,
.cancel = p9_virtio_cancel,
+ .cancelled = p9_virtio_cancelled,
/*
* We leave one entry for input and one entry for response
* headers. We also skip one more entry to accomodate, address
next prev parent reply other threads:[~2017-12-20 18:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-20 17:46 [PATCH 0/2] 9p/trans_virtio: handle request cancellation Greg Kurz
2017-12-20 17:46 ` [PATCH 1/2] virtio: allow to detach a buffer from the virtqueue Greg Kurz
2018-01-19 19:49 ` Michael S. Tsirkin
2018-01-20 9:20 ` Greg Kurz
2017-12-20 17:46 ` Greg Kurz [this message]
2018-01-08 9:18 ` [PATCH 0/2] 9p/trans_virtio: handle request cancellation Greg Kurz
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=151379201222.15509.5560840637636982207.stgit@bahia \
--to=groug@kaod.org \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=v9fs-developer@lists.sourceforge.net \
--cc=viro@ZenIV.linux.org.uk \
/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).