Skip to contentSkip to conversation

Patch "direct-io: Fix sleep in atomic due to sync AIO" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Mar 6, 2018

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

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

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
direct-io-fix-sleep-in-atomic-due-to-sync-aio.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From d9c10e5b8863cfb6886d1640386455075c6e979d Mon Sep 17 00:00:00 2001

From: Jan Kara <[email protected]>
Date: Mon, 26 Feb 2018 12:51:43 +0100
Subject: direct-io: Fix sleep in atomic due to sync AIO

From: Jan Kara <[email protected]>

commit d9c10e5b8863cfb6886d1640386455075c6e979d upstream.

Commit e864f39569f4 "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 9830f4be159b "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]>
Fixes 9830f4be159b29399d107bffb99e0132bc5aedd4
---
 fs/direct-io.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/direct-io.c +1 -2
@@ -1252,8 +1252,7 @@ do_blockdev_direct_IO(struct kiocb *iocb
 	 */
 	if (dio->is_async && iov_iter_rw(iter) == WRITE) {
 		retval = 0;
-		if ((iocb->ki_filp->f_flags & O_DSYNC) ||
-		    IS_SYNC(iocb->ki_filp->f_mapping->host))
+		if (iocb->ki_flags & IOCB_DSYNC)
 			retval = dio_set_defer_completion(dio);
 		else if (!dio->inode->i_sb->s_dio_done_wq) {
 			/*

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/dax-fix-vma_is_fsdax-helper.patch queue-4.14/direct-io-fix-sleep-in-atomic-due-to-sync-aio.patch