mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yun Zhou <yun.zhou@windriver.com>
To: <tytso@mit.edu>, <adilger.kernel@dilger.ca>,
	<libaokun@linux.alibaba.com>, <jack@suse.cz>,
	<ojaswin@linux.ibm.com>, <ritesh.list@gmail.com>,
	<yi.zhang@huawei.com>
Cc: <linux-ext4@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<yun.zhou@windriver.com>
Subject: [RFC PATCH 3/9] ext4: use safe convert path for inline data write overflow
Date: Mon, 27 Jul 2026 18:54:35 +0800	[thread overview]
Message-ID: <20260727105441.3213095-4-yun.zhou@windriver.com> (raw)
In-Reply-To: <20260727105441.3213095-1-yun.zhou@windriver.com>

Replace ext4_convert_inline_data_to_extent() with
ext4_convert_inline_data() in the write paths that handle inline data
overflow.

ext4_convert_inline_data_to_extent() destroys inline data before
allocating the target block.  If block allocation fails (e.g. -ENOSPC),
the inline data is already gone and cannot be recovered -- a potential
data loss on crash.

ext4_convert_inline_data() keeps
a copy of the inline data in a buffer and restores it on failure, making
the conversion safe against allocation failures.

Signed-off-by: Yun Zhou <yun.zhou@windriver.com>
---
 fs/ext4/inline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index ceee69a66482..8f1efe4297a0 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -724,7 +724,7 @@ int ext4_generic_write_inline_data(struct address_space *mapping,
 		if (!da) {
 			brelse(iloc.bh);
 			/* Retry inside */
-			return ext4_convert_inline_data_to_extent(mapping, inode);
+			return ext4_convert_inline_data(inode);
 		}
 
 		ret = ext4_da_convert_inline_data_to_extent(mapping, inode);
@@ -785,7 +785,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
 				  struct folio **foliop)
 {
 	if (pos + len > ext4_get_max_inline_size(inode))
-		return ext4_convert_inline_data_to_extent(mapping, inode);
+		return ext4_convert_inline_data(inode);
 	return ext4_generic_write_inline_data(mapping, inode, pos, len,
 					      foliop, false);
 }
-- 
2.43.0


  parent reply	other threads:[~2026-07-27 10:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 10:54 [RFC PATCH 0/9] ext4: phase out inline data write paths for regular files Yun Zhou
2026-07-27 10:54 ` [RFC PATCH 1/9] ext4: add deprecation warning for inline_data feature Yun Zhou
2026-07-27 10:54 ` [RFC PATCH 2/9] ext4: stop creating inline data for new regular files Yun Zhou
2026-07-27 10:54 ` Yun Zhou [this message]
2026-07-27 10:54 ` [RFC PATCH 4/9] ext4: remove inline data write paths for " Yun Zhou
2026-07-27 10:54 ` [RFC PATCH 5/9] ext4: remove dead inline data write code Yun Zhou
2026-07-27 10:54 ` [RFC PATCH 6/9] ext4: allocate block before destroying inline data in conversion Yun Zhou
2026-07-27 10:54 ` [RFC PATCH 7/9] ext4: remove DA convert path for regular file inline data Yun Zhou
2026-07-27 10:54 ` [RFC PATCH 8/9] ext4: document inline_data deprecation Yun Zhou
2026-07-27 10:54 ` [RFC PATCH 9/9] ext4: populate extent entry atomically during inline data destroy Yun Zhou
2026-07-27 15:03 ` [RFC PATCH 0/9] ext4: phase out inline data write paths for regular files Theodore Tso
2026-07-29  3:12   ` Zhou, Yun

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=20260727105441.3213095-4-yun.zhou@windriver.com \
    --to=yun.zhou@windriver.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=libaokun@linux.alibaba.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®