[Devel] [PATCH vz9 v1 14/63] dm-ploop: set IOCB_DSYNC on all FUA requests

Alexander Atanasov alexander.atanasov at virtuozzo.com
Fri Jan 24 18:35:48 MSK 2025


From: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>

When mapping request, save all flags, rather then only operation
type. Use it later to check if the request is FUA or not.
Unfortunately there is no REQ_FUA equivalent on IOCB layer, but
IOCB_DSYNC is usually translated to it, as can be seen in
__iomap_dio_rw().

https://virtuozzo.atlassian.net/browse/VSTOR-91817
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c    | 13 ++++++++++---
 drivers/md/dm-ploop-target.c |  2 ++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index c83b93f0590a..857896a61ce9 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -133,7 +133,7 @@ static void ploop_init_prq_and_embedded_pio(struct ploop *ploop,
 		struct request *rq, struct ploop_rq *prq, struct pio *pio)
 {
 	ploop_init_prq(prq, rq);
-	ploop_init_pio(ploop, req_op(rq), pio);
+	ploop_init_pio(ploop, rq->cmd_flags, pio);
 	pio->css = prq->css;
 
 	pio->endio_cb = ploop_prq_endio;
@@ -279,7 +279,11 @@ static struct pio *ploop_split_and_chain_pio(struct ploop *ploop,
 	if (!split)
 		return NULL;
 
-	ploop_init_pio(ploop, pio->bi_op, split);
+	/*
+	 * Do not copy REQ_FUA to every split pio. we will sync
+	 * before calling endio on original pio.
+	 */
+	ploop_init_pio(ploop, pio->bi_op & ~REQ_FUA, split);
 	split->css = pio->css;
 	split->queue_list_id = pio->queue_list_id;
 	split->free_on_endio = true;
@@ -1496,6 +1500,9 @@ static bool ploop_locate_new_cluster_and_attach_pio(struct ploop *ploop,
 	if (bat_update_prepared)
 		ploop_md_make_dirty(ploop, md);
 
+	if (pio->bi_op & REQ_FUA)
+		piwb->pio->bi_op |= REQ_FUA;
+
 	ploop_attach_end_action(pio, piwb);
 	attached = true;
 out:
@@ -1914,7 +1921,7 @@ static void ploop_submit_embedded_pio(struct ploop *ploop, struct pio *pio)
 	if (blk_rq_bytes(rq)) {
 		pio->queue_list_id = PLOOP_LIST_PREPARE;
 	} else {
-		WARN_ON_ONCE(pio->bi_op != REQ_OP_FLUSH);
+		WARN_ON_ONCE(!((pio->bi_op & REQ_OP_MASK) == REQ_OP_FLUSH));
 		pio->queue_list_id = PLOOP_LIST_FLUSH;
 	}
 
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 589082c8e110..00d160b3fd3c 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -61,6 +61,8 @@ void ploop_call_rw_iter(struct file *file, loff_t pos, unsigned rw,
 	init_sync_kiocb(iocb, file);
 	iocb->ki_pos = pos;
 	iocb->ki_complete = ploop_aio_complete;
+	if (pio->bi_op & REQ_FUA)
+		iocb->ki_flags |= IOCB_DSYNC;
 
 	atomic_set(&pio->aio_ref, 2);
 
-- 
2.43.0



More information about the Devel mailing list