diff mbox series

dm: disable REQ_NOWAIT for flushes

Message ID 79cd51da-2546-de7e-86e1-be6a835721e2@redhat.com (mailing list archive)
State New
Headers show
Series dm: disable REQ_NOWAIT for flushes | expand

Commit Message

Mikulas Patocka Jan. 9, 2025, 1:49 p.m. UTC
REQ_NOWAIT for flushes cannot be easily supported by device mapper
because it may allocate multiple bios and its impossible to undo if one
of those allocations wants to wait. So, this patch disables REQ_NOWAIT
flushes in device mapper and we always return EAGAIN.

Previously, the code accepted REQ_NOWAIT flushes, but the non-blocking
execution was not guaranteed.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 drivers/md/dm.c |    9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

Index: linux-2.6/drivers/md/dm.c
===================================================================
--- linux-2.6.orig/drivers/md/dm.c	2025-01-08 17:26:52.000000000 +0100
+++ linux-2.6/drivers/md/dm.c	2025-01-08 17:44:59.000000000 +0100
@@ -1968,6 +1968,15 @@  static void dm_split_and_process_bio(str
 
 	/* Only support nowait for normal IO */
 	if (unlikely(bio->bi_opf & REQ_NOWAIT) && !is_abnormal) {
+		/*
+		 * Don't support NOWAIT for FLUSH because it may allocate
+		 * multiple bios and there's no easy way how to undo the
+		 * allocations.
+		 */
+		if (bio->bi_opf & REQ_PREFLUSH) {
+			bio_wouldblock_error(bio);
+			return;
+		}
 		io = alloc_io(md, bio, GFP_NOWAIT);
 		if (unlikely(!io)) {
 			/* Unable to do anything without dm_io. */