From: Paul Durrant <xadimgnik@gmail.com>
To: "'Anthony PERARD'" <anthony.perard@citrix.com>, <qemu-devel@nongnu.org>
Cc: 'Kevin Wolf' <kwolf@redhat.com>,
'Stefano Stabellini' <sstabellini@kernel.org>,
qemu-block@nongnu.org, qemu-stable@nongnu.org,
'Max Reitz' <mreitz@redhat.com>,
'Stefan Hajnoczi' <stefanha@redhat.com>,
xen-devel@lists.xenproject.org
Subject: RE: [PATCH for-5.0] xen-block: Fix double qlist remove
Date: Thu, 2 Apr 2020 15:27:22 +0100 [thread overview]
Message-ID: <001801d608fa$d3f0d3f0$7bd27bd0$@xen.org> (raw)
In-Reply-To: <20200402130819.1216125-1-anthony.perard@citrix.com>
> -----Original Message-----
> From: Anthony PERARD <anthony.perard@citrix.com>
> Sent: 02 April 2020 14:08
> To: qemu-devel@nongnu.org
> Cc: qemu-stable@nongnu.org; Anthony PERARD <anthony.perard@citrix.com>; Stefano Stabellini
> <sstabellini@kernel.org>; Paul Durrant <paul@xen.org>; Stefan Hajnoczi <stefanha@redhat.com>; Kevin
> Wolf <kwolf@redhat.com>; Max Reitz <mreitz@redhat.com>; xen-devel@lists.xenproject.org; qemu-
> block@nongnu.org
> Subject: [PATCH for-5.0] xen-block: Fix double qlist remove
>
> Commit a31ca6801c02 ("qemu/queue.h: clear linked list pointers on
> remove") revealed that a request was removed twice from a list, once
> in xen_block_finish_request() and a second time in
> xen_block_release_request() when both function are called from
> xen_block_complete_aio(). But also, the `requests_inflight' counter is
> decreased twice, and thus became negative.
>
> This is a bug that was introduced in bfd0d6366043, where a `finished'
> list was removed.
>
> This patch simply re-add the `finish' parameter of
> xen_block_release_request() so that we can distinguish when we need to
> remove a request from the inflight list and when not.
>
> Fixes: bfd0d6366043 ("xen-block: improve response latency")
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
It looks to me like it would just be more straightforward to simply drop the QLIST_REMOVE and requests_inflight-- from
xen_block_release_request() and simply insist that xen_block_finish_request() is called in all cases (which I think means adding one
extra call to it in xen_block_handle_requests()).
Paul
> ---
> hw/block/dataplane/xen-block.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c
> index 288a87a814ad..6cc089fc561f 100644
> --- a/hw/block/dataplane/xen-block.c
> +++ b/hw/block/dataplane/xen-block.c
> @@ -123,15 +123,19 @@ static void xen_block_finish_request(XenBlockRequest *request)
> dataplane->requests_inflight--;
> }
>
> -static void xen_block_release_request(XenBlockRequest *request)
> +static void xen_block_release_request(XenBlockRequest *request, bool finish)
> {
> XenBlockDataPlane *dataplane = request->dataplane;
>
> - QLIST_REMOVE(request, list);
> + if (!finish) {
> + QLIST_REMOVE(request, list);
> + }
> reset_request(request);
> request->dataplane = dataplane;
> QLIST_INSERT_HEAD(&dataplane->freelist, request, list);
> - dataplane->requests_inflight--;
> + if (!finish) {
> + dataplane->requests_inflight--;
> + }
> }
>
> /*
> @@ -316,7 +320,7 @@ static void xen_block_complete_aio(void *opaque, int ret)
> error_report_err(local_err);
> }
> }
> - xen_block_release_request(request);
> + xen_block_release_request(request, true);
>
> if (dataplane->more_work) {
> qemu_bh_schedule(dataplane->bh);
> @@ -585,7 +589,7 @@ static bool xen_block_handle_requests(XenBlockDataPlane *dataplane)
> error_report_err(local_err);
> }
> }
> - xen_block_release_request(request);
> + xen_block_release_request(request, false);
> continue;
> }
>
> --
> Anthony PERARD
next prev parent reply other threads:[~2020-04-02 14:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-02 13:08 [PATCH for-5.0] xen-block: Fix double qlist remove Anthony PERARD
2020-04-02 14:27 ` Paul Durrant [this message]
2020-04-06 10:59 ` Anthony PERARD
2020-04-06 14:02 ` [PATCH v2 for-5.0] xen-block: Fix double qlist remove and request leak Anthony PERARD
2020-04-06 14:34 ` Paul Durrant
2020-04-07 11:50 ` Max Reitz
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='001801d608fa$d3f0d3f0$7bd27bd0$@xen.org' \
--to=xadimgnik@gmail.com \
--cc=anthony.perard@citrix.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=paul@xen.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=sstabellini@kernel.org \
--cc=stefanha@redhat.com \
--cc=xen-devel@lists.xenproject.org \
/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).