From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756017AbdLTSWW (ORCPT ); Wed, 20 Dec 2017 13:22:22 -0500 Received: from 5.mo1.mail-out.ovh.net ([178.33.45.107]:33946 "EHLO 5.mo1.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755829AbdLTSWV (ORCPT ); Wed, 20 Dec 2017 13:22:21 -0500 X-Greylist: delayed 1806 seconds by postgrey-1.27 at vger.kernel.org; Wed, 20 Dec 2017 13:22:20 EST Subject: [PATCH 2/2] 9p/trans_virtio: implement cancelled callback From: Greg Kurz To: linux-kernel@vger.kernel.org Cc: v9fs-developer@lists.sourceforge.net, "Michael S. Tsirkin" , Jason Wang , Al Viro Date: Wed, 20 Dec 2017 18:46:52 +0100 Message-ID: <151379201222.15509.5560840637636982207.stgit@bahia> In-Reply-To: <151379198727.15509.2771563206512953068.stgit@bahia> References: <151379198727.15509.2771563206512953068.stgit@bahia> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Ovh-Tracer-Id: 11677833834219411857 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtuddrgeeggddutdejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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