> - case BLKIF_OP_WRITE_BARRIER: > + case BLKIF_OP_FLUSH_DISKCACHE: > if (!ioreq->req.nr_segments) { > ioreq->presync = 1; > return 0; > } > - ioreq->presync = ioreq->postsync = 1; > + ioreq->postsync = 1; > /* fall through */
It might be worth documenting the semantics of BLKIF_OP_FLUSH_DISKCACHE in a comment here. I haven't found any spec for the xen_disk protocol, but from looking at the Linux frontend it seems like the semantics of REQ_FLUSH and REQ_FUA in the Linux block driver are overloaded into BLKIF_OP_FLUSH_DISKCACHE, which is fairly confusing given that REQ_FLUSH already overload functionality. Even worse REQ_FLUSH with a payload implies a preflush, while REQ_FUA implies a post flush, and it seems like Xen has no way to distinguish the two, making thing like log writes very inefficient. Independent of that the implementation should really use a state machine around bdrv_aio_flush instead of doing guest-sychronous bdrv_flush calls.