[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] scsi: Await request purging
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH 2/2] scsi: Await request purging |
Date: |
Tue, 6 Feb 2024 11:56:54 -0500 |
On Fri, Feb 02, 2024 at 03:47:55PM +0100, Hanna Czenczek wrote:
> scsi_device_for_each_req_async() currently does not provide any way to
> be awaited. One of its callers is scsi_device_purge_requests(), which
> therefore currently does not guarantee that all requests are fully
> settled when it returns.
>
> We want all requests to be settled, because scsi_device_purge_requests()
> is called through the unrealize path, including the one invoked by
> virtio_scsi_hotunplug() through qdev_simple_device_unplug_cb(), which
> most likely assumes that all SCSI requests are done then.
>
> In fact, scsi_device_purge_requests() already contains a blk_drain(),
> but this will not fully await scsi_device_for_each_req_async(), only the
> I/O requests it potentially cancels (not the non-I/O requests).
> However, we can have scsi_device_for_each_req_async() increment the BB
> in-flight counter, and have scsi_device_for_each_req_async_bh()
> decrement it when it is done. This way, the blk_drain() will fully
> await all SCSI requests to be purged.
>
> This also removes the need for scsi_device_for_each_req_async_bh() to
> double-check the current context and potentially re-schedule itself,
> should it now differ from the BB's context: Changing a BB's AioContext
> with a root node is done through bdrv_try_change_aio_context(), which
> creates a drained section. With this patch, we keep the BB in-flight
> counter elevated throughout, so we know the BB's context cannot change.
>
> Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
> ---
> hw/scsi/scsi-bus.c | 30 +++++++++++++++++++++---------
> 1 file changed, 21 insertions(+), 9 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
signature.asc
Description: PGP signature
- [PATCH 0/2] block: Allow concurrent BB context changes, Hanna Czenczek, 2024/02/02
- [PATCH 2/2] scsi: Await request purging, Hanna Czenczek, 2024/02/02
- Re: [PATCH 2/2] scsi: Await request purging,
Stefan Hajnoczi <=
- [PATCH 1/2] block-backend: Allow concurrent context changes, Hanna Czenczek, 2024/02/02
- Re: [PATCH 0/2] block: Allow concurrent BB context changes, Stefan Hajnoczi, 2024/02/06
- Re: [PATCH 0/2] block: Allow concurrent BB context changes, Kevin Wolf, 2024/02/07
- Re: [PATCH 0/2] block: Allow concurrent BB context changes, Michael Tokarev, 2024/02/09