diff mbox series

[6/8] loop: allow loop_set_status to re-enable direct I/O

Message ID 20250110073750.1582447-7-hch@lst.de (mailing list archive)
State New
Headers show
Series [1/8] loop: move updating lo_flags out of loop_set_status_from_info | expand

Commit Message

Christoph Hellwig Jan. 10, 2025, 7:37 a.m. UTC
Unlike all other calls of (__)loop_update_dio, loop_set_status never
looks at the O_DIRECT flag of the backing file, and thus doesn't
re-enable direct I/O on an O_DIRECT backing file if e.g. the new block
size would allow it.  Fix that and remove the need for the separate
__loop_update_dio flag.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/loop.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 6eb6d901151c..2e1f8aa045a9 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -196,8 +196,9 @@  static bool lo_can_use_dio(struct loop_device *lo)
 	return true;
 }
 
-static void __loop_update_dio(struct loop_device *lo, bool dio)
+static inline void loop_update_dio(struct loop_device *lo)
 {
+	bool dio = lo->use_dio || (lo->lo_backing_file->f_flags & O_DIRECT);
 	bool use_dio = dio && lo_can_use_dio(lo);
 
 	if (lo->use_dio == use_dio)
@@ -531,12 +532,6 @@  static int do_req_filebacked(struct loop_device *lo, struct request *rq)
 	}
 }
 
-static inline void loop_update_dio(struct loop_device *lo)
-{
-	__loop_update_dio(lo, (lo->lo_backing_file->f_flags & O_DIRECT) |
-				lo->use_dio);
-}
-
 static void loop_reread_partitions(struct loop_device *lo)
 {
 	int rc;
@@ -1301,7 +1296,7 @@  loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
 	}
 
 	/* update the direct I/O flag if lo_offset changed */
-	__loop_update_dio(lo, lo->use_dio);
+	loop_update_dio(lo);
 
 out_unfreeze:
 	blk_mq_unfreeze_queue(lo->lo_queue);