Skip to content
  • Jean-Philippe Brucker's avatar
    disk/aio: Add wait() disk operation · 2790307c
    Jean-Philippe Brucker authored
    
    
    Add a call into the disk layer to synchronize the AIO queue. Wait for all
    pending requests to complete. This will be necessary when resetting a
    virtqueue.
    
    The wait() operation isn't the same as flush(). A VIRTIO_BLK_T_FLUSH
    request ensures that any write request *that completed before the FLUSH is
    sent* is committed to permanent storage (e.g. written back from a write
    cache). But it doesn't do anything for requests that are still pending
    when the FLUSH is sent.
    
    Avoid introducing a mutex on the io_submit() and io_getevents() paths,
    because it can lead to 30% throughput drop on heavy FIO jobs. Instead
    manage an inflight counter using compare-and-swap operations, which is
    simple enough as the caller doesn't submit new requests while it waits for
    the AIO queue to drain. The __sync_fetch_and_* operations are a bit rough
    since they use full barriers, but that didn't seem to introduce a
    performance regression.
    
    Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm....>
    2790307c