From: Baokun Li <libaokun@linux.alibaba.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz,
yi.zhang@huawei.com, ojaswin@linux.ibm.com,
ritesh.list@gmail.com, peng_wang@linux.alibaba.com,
Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH v4 1/6] ext4: prevent sleeping allocation in NOWAIT write path
Date: Mon, 29 Jun 2026 19:38:22 +0800 [thread overview]
Message-ID: <20260629113827.4074335-2-libaokun@linux.alibaba.com> (raw)
In-Reply-To: <20260629113827.4074335-1-libaokun@linux.alibaba.com>
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>
---
fs/ext4/inode.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c2c2d6ac7f3d..832794294ccf 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3672,6 +3672,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.
--
2.43.7
next prev parent reply other threads:[~2026-06-29 11:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 11:38 [PATCH v4 0/6] ext4: allow more DIO writes under shared i_rwsem Baokun Li
2026-06-29 11:38 ` Baokun Li [this message]
2026-06-29 11:38 ` [PATCH v4 2/6] ext4: drain in-flight DIO before buffered write fallback Baokun Li
2026-06-29 11:38 ` [PATCH v4 3/6] ext4: skip overwrite check for aligned non-extending DIO writes Baokun Li
2026-06-29 11:38 ` [PATCH v4 4/6] ext4: base unaligned DIO lock decision on partial block zeroing Baokun Li
2026-06-29 11:38 ` [PATCH v4 5/6] ext4: use kiocb_modified instead of file_modified in DIO/DAX write path Baokun Li
2026-06-29 11:38 ` [PATCH v4 6/6] ext4: fix NOWAIT semantic violation in DAX extending writes Baokun Li
2026-06-30 1:08 ` Zhang Yi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260629113827.4074335-2-libaokun@linux.alibaba.com \
--to=libaokun@linux.alibaba.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=peng_wang@linux.alibaba.com \
--cc=ritesh.list@gmail.com \
--cc=sashiko-bot@kernel.org \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.