summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaokun Li <libaokun@linux.alibaba.com>2026-06-29 19:38:22 +0800
committerTheodore Ts'o <tytso@mit.edu>2026-07-22 11:45:36 -0400
commit07d62890ef19e41a87735b8fe1ec65922b5ecd8c (patch)
treea93feb111729092300f5d6edf97673de4ca7c1b1
parent91949729befb819c8748f9bd75c74ad5696dc090 (diff)
downloadlinux-07d62890ef19e41a87735b8fe1ec65922b5ecd8c.tar.gz
linux-07d62890ef19e41a87735b8fe1ec65922b5ecd8c.zip
ext4: prevent sleeping allocation in NOWAIT write path
Block allocation requires journal access which may sleep, violating NOWAIT semantics. Return -EAGAIN early when IOMAP_NOWAIT is set, allowing the caller to retry without the NOWAIT constraint. This ensures that write paths using IOMAP_NOWAIT (e.g., DIO with RWF_NOWAIT) will not block on journal operations when blocks need to be allocated. Reported-by: Sashiko <sashiko-bot@kernel.org> Closes: https://sashiko.dev/#/patchset/20260611163441.2431805-1-libaokun@linux.alibaba.com?part=1 Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Baokun Li <libaokun@linux.alibaba.com> Link: https://patch.msgid.link/20260629113827.4074335-2-libaokun@linux.alibaba.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--fs/ext4/inode.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 72a334978f69..fd86d536ff27 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3687,6 +3687,9 @@ static int ext4_iomap_alloc(struct inode *inode, struct ext4_map_blocks *map,
int ret, dio_credits, m_flags = 0, retries = 0;
bool force_commit = false;
+ if (flags & IOMAP_NOWAIT)
+ return -EAGAIN;
+
/*
* Trim the mapping request to the maximum value that we can map at
* once for direct I/O.