Skip to content

Commit 3a69311

Browse files
Christoph Hellwigaxboe
authored andcommitted
loop: allow loop_set_status to re-enable direct I/O
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> Link: https://lore.kernel.org/r/20250110073750.1582447-7-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent dc90952 commit 3a69311

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

drivers/block/loop.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,9 @@ static bool lo_can_use_dio(struct loop_device *lo)
196196
return true;
197197
}
198198

199-
static void __loop_update_dio(struct loop_device *lo, bool dio)
199+
static inline void loop_update_dio(struct loop_device *lo)
200200
{
201+
bool dio = lo->use_dio || (lo->lo_backing_file->f_flags & O_DIRECT);
201202
bool use_dio = dio && lo_can_use_dio(lo);
202203

203204
if (lo->use_dio == use_dio)
@@ -531,12 +532,6 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
531532
}
532533
}
533534

534-
static inline void loop_update_dio(struct loop_device *lo)
535-
{
536-
__loop_update_dio(lo, (lo->lo_backing_file->f_flags & O_DIRECT) |
537-
lo->use_dio);
538-
}
539-
540535
static void loop_reread_partitions(struct loop_device *lo)
541536
{
542537
int rc;
@@ -1301,7 +1296,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
13011296
}
13021297

13031298
/* update the direct I/O flag if lo_offset changed */
1304-
__loop_update_dio(lo, lo->use_dio);
1299+
loop_update_dio(lo);
13051300

13061301
out_unfreeze:
13071302
blk_mq_unfreeze_queue(lo->lo_queue);

0 commit comments

Comments
 (0)