Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH] ext4: retry inline data conversion on -EAGAIN
@ 2026-11-30  9:40 Petr Vaněk
  2026-11-30  9:49 ` Petr Vaněk
  2026-11-30  9:53 ` sashiko-bot
  0 siblings, 2 replies; 3+ messages in thread
From: Petr Vaněk @ 2026-11-30  9:40 UTC (permalink / raw)
  To: Theodore Ts'o, Andreas Dilger, Baokun Li, Jan Kara,
	Ojaswin Mujoo, Ritesh Harjani (IBM), Zhang Yi
  Cc: Petr Vaněk, Sashiko, stable, linux-ext4

Commit e2c4c49dee64 ("ext4: restart handle if credits are insufficient
during allocating blocks") made ext4_block_write_begin() return -EAGAIN
when it cannot extend the handle, and taught its callers in inode.c to
retry.  ext4_convert_inline_data_to_extent() was missed and passes the
error to write(2).  It always needs the extension, because its handle is
sized before the inode has an extent tree, so with nodelalloc a write
that converts inline data fails with EAGAIN when a commit starts.

Retry on -EAGAIN like the other callers.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://lore.kernel.org/linux-ext4/sashiko-outbox-236164@kernel.org/
Fixes: e2c4c49dee64 ("ext4: restart handle if credits are insufficient during allocating blocks")
Cc: stable@vger.kernel.org
---
Found while checking a review comment on "ext4: convert regular file
inline data through the page cache", which has the same gap.

Reproduced in QEMU (x86_64, 4 CPUs) on a 1k-block filesystem with a
1 MiB journal, mounted with nodelalloc: 8 threads create a file, write
42 bytes and then 300 bytes at offset 100, while another thread loops on
sync().  In each of three 20-second runs, write() failed with EAGAIN
about 300 times on e2c4c49dee64 and never on its parent.  With this
patch it never failed, and every file read back intact.  The ext4 KUnit
suite passes.

After a failed attempt the error path has already dropped the inline
data, so the retry continues from the data in folio 0, as the existing
ENOSPC retry does.

This patch was developed with the help of an AI coding assistant
(Claude Opus via OpenCode).  It analysed the bug, wrote the fix, the
changelog and the reproducer; I reviewed the change and the test
results.

 fs/ext4/inline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index acdc65ce4796..274cc96daec7 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -682,7 +682,8 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
 			ext4_orphan_del(NULL, inode);
 	}
 
-	if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
+	if (ret == -EAGAIN ||
+	    (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)))
 		goto retry;
 
 	if (folio)
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-30  9:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  9:40 [PATCH] ext4: retry inline data conversion on -EAGAIN Petr Vaněk
2026-11-30  9:49 ` Petr Vaněk
2026-11-30  9:53 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox