Skip to content

Commit d9c10e5

Browse files
jankaraaxboe
authored andcommitted
direct-io: Fix sleep in atomic due to sync AIO
Commit e864f39 "fs: add RWF_DSYNC aand RWF_SYNC" added additional way for direct IO to become synchronous and thus trigger fsync from the IO completion handler. Then commit 9830f4b "fs: Use RWF_* flags for AIO operations" allowed these flags to be set for AIO as well. However that commit forgot to update the condition checking whether the IO completion handling should be defered to a workqueue and thus AIO DIO with RWF_[D]SYNC set will call fsync() from IRQ context resulting in sleep in atomic. Fix the problem by checking directly iocb flags (the same way as it is done in dio_complete()) instead of checking all conditions that could lead to IO being synchronous. CC: Christoph Hellwig <[email protected]> CC: Goldwyn Rodrigues <[email protected]> CC: [email protected] Reported-by: Mark Rutland <[email protected]> Tested-by: Mark Rutland <[email protected]> Fixes: 9830f4b Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent ba989a0 commit d9c10e5

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fs/direct-io.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,8 +1274,7 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
12741274
*/
12751275
if (dio->is_async && iov_iter_rw(iter) == WRITE) {
12761276
retval = 0;
1277-
if ((iocb->ki_filp->f_flags & O_DSYNC) ||
1278-
IS_SYNC(iocb->ki_filp->f_mapping->host))
1277+
if (iocb->ki_flags & IOCB_DSYNC)
12791278
retval = dio_set_defer_completion(dio);
12801279
else if (!dio->inode->i_sb->s_dio_done_wq) {
12811280
/*

0 commit comments

Comments
 (0)