Thread (9 messages) 9 messages, 3 authors, 2022-11-28
STALE1328d

[PATCH 2/2] block: fops: Do not set REQ_SYNC for async IOs

From: Damien Le Moal <hidden>
Date: 2022-11-26 02:55:57
Subsystem: block layer, the rest · Maintainers: Jens Axboe, Linus Torvalds

Taking a blktrace of a simple fio run on a block device file using
libaio and iodepth > 1 reveals that asynchronous writes are executed as
sync writes, that is, REQ_SYNC is set for the write BIOs.

Fix this by modifying dio_bio_write_op() to set REQ_SYNC only for IOs
that are indeed synchronous ones and set REQ_IDLE only for asynchronous
IOs.

Signed-off-by: Damien Le Moal <redacted>
---
 block/fops.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/block/fops.c b/block/fops.c
index 50d245e8c913..5a4f57726828 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -34,7 +34,12 @@ static int blkdev_get_block(struct inode *inode, sector_t iblock,
 
 static blk_opf_t dio_bio_write_op(struct kiocb *iocb)
 {
-	blk_opf_t opf = REQ_OP_WRITE | REQ_SYNC | REQ_IDLE;
+	blk_opf_t opf = REQ_OP_WRITE;
+
+	if (is_sync_kiocb(iocb))
+		opf |= REQ_SYNC;
+	else
+		opf |= REQ_IDLE;
 
 	/* avoid the need for a I/O completion work item */
 	if (iocb_is_dsync(iocb))
-- 
2.38.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help