@@ -182,26 +182,29 @@ static bool lo_bdev_can_use_dio(struct loop_device *lo,
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
0 commit comments