qemu/hw/block/dataplane
Anthony PERARD 36d883ba0d xen-block: Fix double qlist remove and request leak
Commit a31ca6801c ("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 bfd0d63660 ("xen-block: improve
response latency"), where a `finished' list was removed.

That commit also introduced a leak of request in xen_block_do_aio().
That function calls xen_block_finish_request() but the request is
never released after that.

To fix both issue, we do two changes:
- we squash finish_request() and release_request() together as we want
  to remove a request from 'inflight' list to add it to 'freelist'.
- before releasing a request, we need to let the other end know the
  result, thus we should call xen_block_send_response() before
  releasing a request.

The first change fixes the double QLIST_REMOVE() as we remove the extra
call. The second change makes the leak go away because if we want to
call finish_request(), we need to call a function that does all of
finish, send response, and release.

Fixes: bfd0d63660 ("xen-block: improve response latency")
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Message-Id: <20200406140217.1441858-1-anthony.perard@citrix.com>
Reviewed-by: Paul Durrant <paul@xen.org>
[mreitz: Amended commit message as per Paul's suggestions]
Signed-off-by: Max Reitz <mreitz@redhat.com>
2020-04-07 13:51:09 +02:00
..
Makefile.objs block: fix recursion in hw/block/dataplane 2019-03-07 21:45:53 +01:00
trace-events trace-events: Shorten file names in comments 2019-03-22 16:18:07 +00:00
virtio-blk.c virtio-blk: fix out-of-bounds access to bitmap in notify_guest_bh 2019-12-19 16:20:25 +00:00
virtio-blk.h hw/block: Fix the return type 2017-12-19 09:25:28 +00:00
xen-block.c xen-block: Fix double qlist remove and request leak 2020-04-07 13:51:09 +02:00
xen-block.h xen-block: support feature-large-sector-size 2019-06-24 10:42:29 +01:00