Am 21.10.2026 um 08:22 hat Alberto Faria geschrieben:
> virtio-blk FUA write support has been introduced to the virtio spec [1], and a
> kernel patch is under review [2]. This patch enables FUA on the virtio-blk
> device, so guests can submit FUA writes instead of the slower alternative of a
> regular write followed by a flush.
> 
> A simple randwrite fio workload on a RAM disk (bs=4k, iodepth=1, direct=1,
> sync=1) shows a throughput improvement of 17.1k IOPS to 27.7k IOPS (+62%).
> 
> [1] 
> https://lore.kernel.org/virtio-comment/[email protected]/
> [2] 
> https://lore.kernel.org/linux-block/[email protected]/
> 
> Alberto Faria (2):
>   include: Add virtio-blk request flag FUA definitions
>   virtio-blk: Add support for FUA write requests

As patch 1 can't be applied, I squashed in the below temporary
workaround that should be reverted after the Linux headers provide the
necessary definitions.

Thanks, applied to the block branch.

Kevin

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 345c9e07567..9b7c84fda6c 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -38,6 +38,16 @@
 #include "hw/virtio/virtio-blk-common.h"
 #include "qemu/coroutine.h"

+/* TODO Remove once the Linux headers have caught up */
+#ifndef VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA
+#define VIRTIO_BLK_F_REQ_FLAGS         18      /* Request flags supported */
+#define VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA 19      /* FUA flag supported */
+
+#define VIRTIO_BLK_REQ_FLAG_OUT_FUA    0
+
+#define VIRTIO_BLK_OUTDHR_FLAGS(out) out.ioprio
+#endif
+
 /* Internal buffer size limit for zone report */
 #define VIRTIO_BLK_MAX_ZONES_PER_BATCH 4096

@@ -936,7 +946,7 @@ static int virtio_blk_handle_request(VirtIOBlockReq *req, 
MultiReqBuffer *mrb)
                               &req->inhdr_undo);

     type = virtio_ldl_p(vdev, &req->out.type);
-    flags = virtio_ldl_p(vdev, &req->out.flags);
+    flags = virtio_ldl_p(vdev, &VIRTIO_BLK_OUTDHR_FLAGS(req->out));

     /* VIRTIO_BLK_T_OUT defines the command direction. VIRTIO_BLK_T_BARRIER
      * is an optional flag. Although a guest should not send this flag if
diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c
index a15ec3685a3..af2f4b73dce 100644
--- a/hw/virtio/virtio-qmp.c
+++ b/hw/virtio/virtio-qmp.c
@@ -33,6 +33,12 @@
 #include "standard-headers/linux/virtio_vsock.h"
 #include "standard-headers/linux/virtio_gpio.h"

+/* TODO Remove once the Linux headers have caught up */
+#ifndef VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA
+#define VIRTIO_BLK_F_REQ_FLAGS         18      /* Request flags supported */
+#define VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA 19      /* FUA flag supported */
+#endif
+
 #define FEATURE_ENTRY(name, desc) (qmp_virtio_feature_map_t) \
     { .virtio_bit = name, .feature_desc = desc }


Reply via email to