Commit 93e1f7fc authored by Jan Kara's avatar Jan Kara Committed by Greg Kroah-Hartman

direct-io: Fix sleep in atomic due to sync AIO

commit d9c10e5b upstream.

Commit e864f395 "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 9830f4be "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 <>
CC: Goldwyn Rodrigues <>
Reported-by: default avatarMark Rutland <>
Tested-by: default avatarMark Rutland <>
Fixes: 9830f4beSigned-off-by: default avatarJan Kara <>
Signed-off-by: default avatarJens Axboe <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 0ba6c33b
......@@ -1252,8 +1252,7 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
if (dio->is_async && iov_iter_rw(iter) == WRITE) {
retval = 0;
if ((iocb->ki_filp->f_flags & O_DSYNC) ||
if (iocb->ki_flags & IOCB_DSYNC)
retval = dio_set_defer_completion(dio);
else if (!dio->inode->i_sb->s_dio_done_wq) {
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment