aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kara <[email protected]>2020-07-08 17:35:16 +0200
committerTheodore Ts'o <[email protected]>2020-08-06 01:05:46 -0400
commit0b3171b6d195637f84ddf8b59bae818ea20bc8ac (patch)
tree6b42f17fa36f96a449d665d60002330acf90f14d
parente65bf6e468c39a60c1dfae439198ad875bb8a870 (diff)
ext4: do not block RWF_NOWAIT dio write on unallocated space
Since commit 378f32bab371 ("ext4: introduce direct I/O write using iomap infrastructure") we don't properly bail out of RWF_NOWAIT direct IO write if underlying blocks are not allocated. Also ext4_dio_write_checks() does not honor RWF_NOWAIT when re-acquiring i_rwsem. Fix both issues. Fixes: 378f32bab371 ("ext4: introduce direct I/O write using iomap infrastructure") Cc: [email protected] Reported-by: Filipe Manana <[email protected]> Signed-off-by: Jan Kara <[email protected]> Reviewed-by: Ritesh Harjani <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
-rw-r--r--fs/ext4/file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 453cafecf5cc..7a2720517bbb 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -427,6 +427,10 @@ restart:
*/
if (*ilock_shared && (!IS_NOSEC(inode) || *extend ||
!ext4_overwrite_io(inode, offset, count))) {
+ if (iocb->ki_flags & IOCB_NOWAIT) {
+ ret = -EAGAIN;
+ goto out;
+ }
inode_unlock_shared(inode);
*ilock_shared = false;
inode_lock(inode);