On 29/05/2026 16.42, Keith Busch wrote:
> On Fri, May 29, 2026 at 02:36:13PM +0200, 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.
>
> Thanks, I like the idea. One question below.
>
>> - if (!mem)
>> + if (!mem || dbs->iov.niov >= IOV_MAX) {
>> break;
>> + }
>
> Won't this leak "mem" if it is not NULL, but we've hit the iov.niov
> condition? If so, I think you can move this new check to after the
> qemu_iovec_add call.
Good catch, thanks. For v2, I'll move the new break condition after
qemu_iovec_add and sg length accounting:
@@ -156,15 +156,17 @@ static void dma_blk_cb(void *opaque, int ret)
}
}
}
- if (!mem || dbs->iov.niov >= IOV_MAX) {
+ if (!mem)
break;
- }
qemu_iovec_add(&dbs->iov, mem, cur_len);
dbs->sg_cur_byte += cur_len;
if (dbs->sg_cur_byte == dbs->sg->sg[dbs->sg_cur_index].len) {
dbs->sg_cur_byte = 0;
++dbs->sg_cur_index;
}
+ if (dbs->iov.niov >= IOV_MAX) {
+ break;
+ }
}
if (dbs->iov.size == 0) {