Commit 2f3b6e61f6 for qemu.org

commit 2f3b6e61f692bade441230dd25c1c0f101bd2eef
Author: Kevin Wolf <kwolf@redhat.com>
Date:   Fri Mar 7 23:16:31 2025 +0100

    block/io: Ignore FUA with cache.no-flush=on

    For block drivers that don't advertise FUA support, we already call
    bdrv_co_flush(), which considers BDRV_O_NO_FLUSH. However, drivers that
    do support FUA still see the FUA flag with BDRV_O_NO_FLUSH and get the
    associated performance penalty that cache.no-flush=on was supposed to
    avoid.

    Clear FUA for write requests if BDRV_O_NO_FLUSH is set.

    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Message-ID: <20250307221634.71951-3-kwolf@redhat.com>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>

diff --git a/block/io.c b/block/io.c
index d369b994df..1ba8d1aeea 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1058,6 +1058,10 @@ bdrv_driver_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
         return -ENOMEDIUM;
     }

+    if (bs->open_flags & BDRV_O_NO_FLUSH) {
+        flags &= ~BDRV_REQ_FUA;
+    }
+
     if ((flags & BDRV_REQ_FUA) &&
         (~bs->supported_write_flags & BDRV_REQ_FUA)) {
         flags &= ~BDRV_REQ_FUA;