Il 26/08/2014 11:21, Fam Zheng ha scritto: > On Tue, 08/26 10:46, Paolo Bonzini wrote: >> Il 26/08/2014 08:08, Fam Zheng ha scritto: >>> + if (dbs->cancelled) { >>> + ret = -ECANCELED; >>> + } >> >> Why is dbs->cancelled necessary? > > Request may complete after bdrv_aio_cancel_async with other status, this flag > is checked to fix the status to -ECANCELED.
Ah, that's because the operation could be partly incomplete? I think it would be better to call dma_complete with -ECANCELED, instead of doing the same dbs->cancelled check twice. For example, in dma_bdrv_cb: if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) { dma_complete(dbs, ret); return; } if (dbs->cancelled) { dma_complete(dbs, -ECANCELED); return; } >>> +static void dma_aio_cancel_async(BlockDriverAIOCB *acb) >>> +{ >>> + DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common); >>> + >>> + trace_dma_aio_cancel(dbs); >>> + >>> + dbs->cancelled = true; >>> + if (dbs->acb) { >>> + acb = dbs->acb; >>> + dbs->acb = NULL; >> >> Why do you need to set dbs->acb to NULL, since the callback is going to >> be called? > > Just copied from dma_aio_cancel, but seems not particularly useful. It reminds > me that the one in dma_aio_cancel also looks suspicious. Yeah, that one looks useless too... Paolo