On Mon, Oct 26, 2026 at 11:11:12AM +0100, Daniel Gomez wrote:
> From: Daniel Gomez <[email protected]>
> 
> dma_blk_cb() submits dbs->iov to io_func() in one shot, so callers
> must keep dbs->iov.niov below IOV_MAX or the host preadv()/pwritev()
> rejects the call.
> 
> Break the accumulation loop when niov reaches IOV_MAX. The existing
> re-entry path resumes mapping and submits a follow-up chunk under
> the same AIOCB, so callers no longer carry that constraint.
> 
> Suggested-by: Klaus Jensen <[email protected]>
> Acked-by: Jesper Wendel Devantier <[email protected]>
> Reviewed-by: Keith Busch <[email protected]>
> Signed-off-by: Daniel Gomez <[email protected]>
> ---
>  system/dma-helpers.c | 3 +++
>  1 file changed, 3 insertions(+)

What happens when two large writes to the same sector run concurrently?
Before, the result was either write A or write B. Now it's possible to
get an interleaving of write A and B's data. I think this violates block
device semantics and corrupts data. A serialization mechanism is needed
if you want to do this.

> 
> diff --git a/system/dma-helpers.c b/system/dma-helpers.c
> index d4fd33a3d4c..613fa548669 100644
> --- a/system/dma-helpers.c
> +++ b/system/dma-helpers.c
> @@ -175,6 +175,9 @@ static void dma_blk_cb(void *opaque, int ret)
>              dbs->sg_cur_byte = 0;
>              ++dbs->sg_cur_index;
>          }
> +        if (dbs->iov.niov >= IOV_MAX) {
> +            break;
> +        }
>      }
>  
>      if (dbs->iov.size == 0) {
> 
> -- 
> 2.56.0
> 
> 


Reply via email to