From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akvHx-0004q8-1N for qemu-devel@nongnu.org; Tue, 29 Mar 2016 11:10:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1akvHw-0006aX-4K for qemu-devel@nongnu.org; Tue, 29 Mar 2016 11:10:36 -0400 From: Kevin Wolf Date: Tue, 29 Mar 2016 17:08:36 +0200 Message-Id: <1459264128-12761-37-git-send-email-kwolf@redhat.com> In-Reply-To: <1459264128-12761-1-git-send-email-kwolf@redhat.com> References: <1459264128-12761-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 36/48] block: Introduce bdrv_co_writev_flags() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org This function will allow drivers to implement BDRV_REQ_FUA natively instead of sending a separate flush after the write. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block/io.c | 9 ++++++++- include/block/block_int.h | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index 4c9e3f4..fb5cba0 100644 --- a/block/io.c +++ b/block/io.c @@ -1152,13 +1152,20 @@ static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs, } else if (flags & BDRV_REQ_ZERO_WRITE) { bdrv_debug_event(bs, BLKDBG_PWRITEV_ZERO); ret = bdrv_co_do_write_zeroes(bs, sector_num, nb_sectors, flags); + } else if (drv->bdrv_co_writev_flags) { + bdrv_debug_event(bs, BLKDBG_PWRITEV); + ret = drv->bdrv_co_writev_flags(bs, sector_num, nb_sectors, qiov, + flags); } else { + assert(drv->supported_write_flags == 0); bdrv_debug_event(bs, BLKDBG_PWRITEV); ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); } bdrv_debug_event(bs, BLKDBG_PWRITEV_DONE); - if (ret == 0 && (flags & BDRV_REQ_FUA)) { + if (ret == 0 && (flags & BDRV_REQ_FUA) && + !(drv->supported_write_flags & BDRV_REQ_FUA)) + { ret = bdrv_co_flush(bs); } diff --git a/include/block/block_int.h b/include/block/block_int.h index 4884609..10d8759 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -155,6 +155,11 @@ struct BlockDriver { int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); int coroutine_fn (*bdrv_co_writev)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); + int coroutine_fn (*bdrv_co_writev_flags)(BlockDriverState *bs, + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags); + + int supported_write_flags; + /* * Efficiently zero a region of the disk image. Typically an image format * would use a compact metadata representation to implement this. This -- 1.8.3.1