Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

loop: create a lo_can_use_dio helper

Factor out a part of __loop_update_dio in preparation for further
refactoring.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20250110073750.1582447-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
781fc49a 4155adb0

+14 -11
+14 -11
drivers/block/loop.c
··· 182 182 return true; 183 183 } 184 184 185 - static void __loop_update_dio(struct loop_device *lo, bool dio) 185 + static bool lo_can_use_dio(struct loop_device *lo) 186 186 { 187 - struct file *file = lo->lo_backing_file; 188 - struct inode *inode = file->f_mapping->host; 189 - struct block_device *backing_bdev = NULL; 190 - bool use_dio; 187 + struct inode *inode = lo->lo_backing_file->f_mapping->host; 188 + 189 + if (!(lo->lo_backing_file->f_mode & FMODE_CAN_ODIRECT)) 190 + return false; 191 191 192 192 if (S_ISBLK(inode->i_mode)) 193 - backing_bdev = I_BDEV(inode); 194 - else if (inode->i_sb->s_bdev) 195 - backing_bdev = inode->i_sb->s_bdev; 193 + return lo_bdev_can_use_dio(lo, I_BDEV(inode)); 194 + if (inode->i_sb->s_bdev) 195 + return lo_bdev_can_use_dio(lo, inode->i_sb->s_bdev); 196 + return true; 197 + } 196 198 197 - use_dio = dio && (file->f_mode & FMODE_CAN_ODIRECT) && 198 - (!backing_bdev || lo_bdev_can_use_dio(lo, backing_bdev)); 199 + static void __loop_update_dio(struct loop_device *lo, bool dio) 200 + { 201 + bool use_dio = dio && lo_can_use_dio(lo); 199 202 200 203 if (lo->use_dio == use_dio) 201 204 return; 202 205 203 206 /* flush dirty pages before changing direct IO */ 204 - vfs_fsync(file, 0); 207 + vfs_fsync(lo->lo_backing_file, 0); 205 208 206 209 /* 207 210 * The flag of LO_FLAGS_DIRECT_IO is handled similarly with