Hello, On Tue, 12 Mar 2024 at 15:15, Kevin Wolf <kw...@redhat.com> wrote: > Am 11.03.2024 um 20:36 hat Stefan Hajnoczi geschrieben: > > > > That can be avoided with a variable that keeps track of whether -EINVAL > > > > was seen before and skips Linux AIO in that > > > > case. > > > > > > > > Fallback should be very rare, so I don't think it needs to be optimized: > You're right. I missed that io_submit() returns failure only if the > first request in the queue is invalid, and returns a "short submission" > for errors in later entries.
=== +bool laio_has_fdsync(int fd) +{ + AioContext *ctx = qemu_get_current_aio_context(); + struct qemu_laiocb cb = { + .co = qemu_coroutine_self(), + .ctx = aio_get_linux_aio(ctx), + }; + struct iocb *iocbs[] = {&cb.iocb, NULL}; + + /* check if host kernel supports IO_CMD_FDSYNC */ + io_prep_fdsync(&cb.iocb, fd); + int ret = io_submit(cb.ctx->ctx, 1, iocbs); + + return ret != -EINVAL; +} === To confirm: * Do we need a revised patch V3? I'm testing one with the above function to check if IO_CMD_FDSYNC is supported. If it returns true we call laio_co_submit(..., QEMU_AIO_FLUSH, ), else fallback to thread-pool. Thank you. --- - Prasad