From f92b0f43e6fa67858811746c88a81d204edd86df Mon Sep 17 00:00:00 2001 From: Shiqing Gao Date: Sat, 30 Dec 2023 23:55:26 +0800 Subject: [PATCH] dm: block_if: io_uring: flush the modified in-core data on demand When `io_uring` is used, `blockif_flush_cache` is missing when an WRITE operation is completed. `blockif_flush_cache` would flush the modified in-core data to the disk device according to the setting of the cache mode. Tracked-On: #8612 Signed-off-by: Shiqing Gao Acked-by: Wang, Yu1 --- devicemodel/hw/block_if.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/devicemodel/hw/block_if.c b/devicemodel/hw/block_if.c index f405f2561..8542f16e8 100644 --- a/devicemodel/hw/block_if.c +++ b/devicemodel/hw/block_if.c @@ -1120,6 +1120,7 @@ iou_process_completions(struct blockif_queue *bq) struct blockif_elem *be; struct blockif_req *br; struct io_uring *ring = &bq->ring; + int err = 0; while (io_uring_peek_cqe(ring, &cqes) == 0) { if (!cqes) { @@ -1150,8 +1151,12 @@ iou_process_completions(struct blockif_queue *bq) blockif_deinit_bounce_iov(br); } + if (be->op == BOP_WRITE) { + err = blockif_flush_cache(bq->bc); + } + be->status = BST_DONE; - (*br->callback)(br, 0); + (*br->callback)(br, err); blockif_complete(bq, be); }