block: Convert .bdrv_truncate callback to coroutine_fn
bdrv_truncate() is an operation that can block (even for a quite long time, depending on the PreallocMode) in I/O paths that shouldn't block. Convert it to a coroutine_fn so that we have the infrastructure for drivers to make their .bdrv_co_truncate implementation asynchronous. This change could potentially introduce new race conditions because bdrv_truncate() isn't necessarily executed atomically any more. Whether this is a problem needs to be evaluated for each block driver that supports truncate: * file-posix/win32, gluster, iscsi, nfs, rbd, ssh, sheepdog: The protocol drivers are trivially safe because they don't actually yield yet, so there is no change in behaviour. * copy-on-read, crypto, raw-format: Essentially just filter drivers that pass the request to a child node, no problem. * qcow2: The implementation modifies metadata, so it needs to hold s->lock to be safe with concurrent I/O requests. In order to avoid double locking, this requires pulling the locking out into preallocate_co() and using qcow2_write_caches() instead of bdrv_flush(). * qed: Does a single header update, this is fine without locking. Signed-off-by:Kevin Wolf <kwolf@redhat.com> Reviewed-by:
Stefan Hajnoczi <stefanha@redhat.com>
Showing
- block.c 55 additions, 8 deletionsblock.c
- block/copy-on-read.c 4 additions, 4 deletionsblock/copy-on-read.c
- block/crypto.c 5 additions, 4 deletionsblock/crypto.c
- block/file-posix.c 6 additions, 6 deletionsblock/file-posix.c
- block/file-win32.c 3 additions, 3 deletionsblock/file-win32.c
- block/gluster.c 8 additions, 6 deletionsblock/gluster.c
- block/iscsi.c 4 additions, 4 deletionsblock/iscsi.c
- block/nfs.c 4 additions, 3 deletionsblock/nfs.c
- block/qcow2.c 44 additions, 30 deletionsblock/qcow2.c
- block/qed.c 5 additions, 3 deletionsblock/qed.c
- block/raw-format.c 4 additions, 4 deletionsblock/raw-format.c
- block/rbd.c 5 additions, 3 deletionsblock/rbd.c
- block/sheepdog.c 6 additions, 6 deletionsblock/sheepdog.c
- block/ssh.c 3 additions, 3 deletionsblock/ssh.c
- include/block/block.h 4 additions, 0 deletionsinclude/block/block.h
- include/block/block_int.h 2 additions, 2 deletionsinclude/block/block_int.h
Loading
Please register or sign in to comment