Patch "ext4: update direct I/O read lock pattern for IOCB_NOWAIT" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

    ext4: update direct I/O read lock pattern for IOCB_NOWAIT

to the 4.19-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:
     ext4-update-direct-i-o-read-lock-pattern-for-iocb_no.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e3d6bf069846f2dc60128632994322977c9cd206
Author: Matthew Bobrowski <mbobrowski@xxxxxxxxxxxxxx>
Date:   Tue Nov 5 22:59:22 2019 +1100

    ext4: update direct I/O read lock pattern for IOCB_NOWAIT
    
    [ Upstream commit 548feebec7e93e58b647dba70b3303dcb569c914 ]
    
    This patch updates the lock pattern in ext4_direct_IO_read() to not
    block on inode lock in cases of IOCB_NOWAIT direct I/O reads. The
    locking condition implemented here is similar to that of 942491c9e6d6
    ("xfs: fix AIM7 regression").
    
    Fixes: 16c54688592c ("ext4: Allow parallel DIO reads")
    Signed-off-by: Matthew Bobrowski <mbobrowski@xxxxxxxxxxxxxx>
    Reviewed-by: Jan Kara <jack@xxxxxxx>
    Reviewed-by: Ritesh Harjani <riteshh@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/c5d5e759f91747359fbd2c6f9a36240cf75ad79f.1572949325.git.mbobrowski@xxxxxxxxxxxxxx
    Signed-off-by: Theodore Ts'o <tytso@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 215802cbc42b..00d0c4b8fa30 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3848,7 +3848,13 @@ static ssize_t ext4_direct_IO_read(struct kiocb *iocb, struct iov_iter *iter)
 	 * writes & truncates and since we take care of writing back page cache,
 	 * we are protected against page writeback as well.
 	 */
-	inode_lock_shared(inode);
+	if (iocb->ki_flags & IOCB_NOWAIT) {
+		if (!inode_trylock_shared(inode))
+			return -EAGAIN;
+	} else {
+		inode_lock_shared(inode);
+	}
+
 	ret = filemap_write_and_wait_range(mapping, iocb->ki_pos,
 					   iocb->ki_pos + count - 1);
 	if (ret)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux