The patch creates helper to advance flush generation.

Right now there is the only place which handles bs->write_gen, but this
is going to be changed in the next patches. Unfortunately we need to
precisely control the moment of flush() when BDRV_REQ_FUA is passed
as a request flag. Generic processing inside bdrv_co_write_req_finish()
is too late.

Signed-off-by: Denis V. Lunev <[email protected]>
CC: Andrey Drobyshev <[email protected]>
CC: Kevin Wolf <[email protected]>
CC: Hanna Reitz <[email protected]>
---
 block/io.c                       | 2 +-
 include/block/block_int-common.h | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/block/io.c b/block/io.c
index d37da2e0ac5..f39ff862c11 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2147,7 +2147,7 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t 
offset, int64_t bytes,
 
     bdrv_check_request(offset, bytes, &error_abort);
 
-    qatomic_inc(&bs->write_gen);
+    bdrv_advance_flush_gen(bs);
 
     /*
      * Discard cannot extend the image, but in error handling cases, such as
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index 80c54a6d09f..67552463dbe 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -1373,6 +1373,11 @@ int bdrv_check_qiov_request(int64_t offset, int64_t 
bytes,
                             QEMUIOVector *qiov, size_t qiov_offset,
                             Error **errp);
 
+static inline void bdrv_advance_flush_gen(BlockDriverState *bs)
+{
+    qatomic_inc(&bs->write_gen);
+}
+
 bool cbw_filter_present(void);
 
 #ifdef _WIN32
-- 
2.43.5


Reply via email to