From: Baokun Li <libaokun1@huawei.com>
To: Jan Kara <jack@suse.cz>
Cc: Theodore Tso <tytso@mit.edu>, Zhang Yi <yi.zhang@huaweicloud.com>,
Christoph Hellwig <hch@infradead.org>,
<linux-ext4@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <adilger.kernel@dilger.ca>,
<ojaswin@linux.ibm.com>, <ritesh.list@gmail.com>,
<djwong@kernel.org>, Zhang Yi <yi.zhang@huawei.com>,
<yizhang089@gmail.com>, <yangerkun@huawei.com>,
<yukuai@alb-78bjiv52429oh8qptp.cn-shenzhen.alb.aliyuncs.com>,
<libaokun9@gmail.com>, Baokun Li <libaokun1@huawei.com>
Subject: Re: [PATCH -next v2 00/22] ext4: use iomap for regular file's buffered I/O path
Date: Thu, 5 Feb 2026 10:55:59 +0800 [thread overview]
Message-ID: <4a210be6-eced-4a47-a54b-3f2bc3f3bfbf@huawei.com> (raw)
In-Reply-To: <eldlhdvhc4sdlmfed5omg6huv5rl6m7ummstlygh2bownaejqn@bykrybkyywzp>
On 2026-02-04 22:23, Jan Kara wrote:
> On Wed 04-02-26 09:59:36, Baokun Li wrote:
>> On 2026-02-03 21:14, Theodore Tso wrote:
>>> On Tue, Feb 03, 2026 at 05:18:10PM +0800, Zhang Yi wrote:
>>>> This means that the ordered journal mode is no longer in ext4 used
>>>> under the iomap infrastructure. The main reason is that iomap
>>>> processes each folio one by one during writeback. It first holds the
>>>> folio lock and then starts a transaction to create the block mapping.
>>>> If we still use the ordered mode, we need to perform writeback in
>>>> the logging process, which may require initiating a new transaction,
>>>> potentially leading to deadlock issues. In addition, ordered journal
>>>> mode indeed has many synchronization dependencies, which increase
>>>> the risk of deadlocks, and I believe this is one of the reasons why
>>>> ext4_do_writepages() is implemented in such a complicated manner.
>>>> Therefore, I think we need to give up using the ordered data mode.
>>>>
>>>> Currently, there are three scenarios where the ordered mode is used:
>>>> 1) append write,
>>>> 2) partial block truncate down, and
>>>> 3) online defragmentation.
>>>>
>>>> For append write, we can always allocate unwritten blocks to avoid
>>>> using the ordered journal mode.
>>> This is going to be a pretty severe performance regression, since it
>>> means that we will be doubling the journal load for append writes.
>>> What we really need to do here is to first write out the data blocks,
>>> and then only start the transaction handle to modify the data blocks
>>> *after* the data blocks have been written (to heretofore, unused
>>> blocks that were just allocated). It means inverting the order in
>>> which we write data blocks for the append write case, and in fact it
>>> will improve fsync() performance since we won't be gating writing the
>>> commit block on the date blocks getting written out in the append
>>> write case.
>> I have some local demo patches doing something similar, and I think this
>> work could be decoupled from Yi's patch set.
>>
>> Since inode preallocation (PA) maintains physical block occupancy with a
>> logical-to-physical mapping, and ensures on-disk data consistency after
>> power failure, it is an excellent location for recording temporary
>> occupancy. Furthermore, since inode PA often allocates more blocks than
>> requested, it can also help reduce file fragmentation.
>>
>> The specific approach is as follows:
>>
>> 1. Allocate only the PA during block allocation without inserting it into
>> the extent status tree. Return the PA to the caller and increment its
>> refcount to prevent it from being discarded.
>>
>> 2. Issue IOs to the blocks within the inode PA. If IO fails, release the
>> refcount and return -EIO. If successful, proceed to the next step.
>>
>> 3. Start a handle upon successful IO completion to convert the inode PA to
>> extents. Release the refcount and update the extent tree.
>>
>> 4. If a corresponding extent already exists, we’ll need to punch holes to
>> release the old extent before inserting the new one.
> Sounds good. Just if I understand correctly case 4 would happen only if you
> really try to do something like COW with this? Normally you'd just use the
> already present blocks and write contents into them?
Yes, case 4 only needs to be considered when implementing COW.
>
>> This ensures data atomicity, while jbd2—being a COW-like implementation
>> itself—ensures metadata atomicity. By leveraging this "delay map"
>> mechanism, we can achieve several benefits:
>>
>> * Lightweight, high-performance COW.
>> * High-performance software atomic writes (hardware-independent).
>> * Replacing dio_readnolock, which might otherwise read unexpected zeros.
>> * Replacing ordered data and data journal modes.
>> * Reduced handle hold time, as it's only held during extent tree updates.
>> * Paving the way for snapshot support.
>>
>> Of course, COW itself can lead to severe file fragmentation, especially
>> in small-scale overwrite scenarios.
> I agree the feature can provide very interesting benefits and we were
> pondering about something like that for a long time, just never got to
> implementing it. I'd say the immediate benefits are you can completely get
> rid of dioread_nolock as well as the legacy dioread_lock modes so overall
> code complexity should not increase much. We could also mostly get rid of
> data=ordered mode use (although not completely - see my discussion with
> Zhang over patch 3) which would be also welcome simplification. These
> benefits alone are IMO a good enough reason to have the functionality :).
> Even without COW, atomic writes and other fancy stuff.
Glad you liked the 'delay map' concept (naming suggestions are welcome!).
With delay-map in place, implementing COW only requires handling overwrite
scenarios, and software atomic writes can be achieved by enabling atomic
delay-maps across multiple PAs.
I expect to send out a minimal RFC version for discussion in a few weeks.
I will share some additional thoughts regarding EOF blocks and
data=ordered mode in patch 3.
Thanks for your feedback!
>
> I don't see how you want to get rid of data=journal mode - perhaps that's
> related to the COW functionality?
>
> Honza
Yes. The only real advantage of data=journal mode over data=ordered is
its guarantee of data atomicity for overwrites.
If we can achieve this through COW-based software atomic writes, we can
move away from the performance-heavy data=journal mode.
Cheers,
Baokun
next prev parent reply other threads:[~2026-02-05 2:56 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 6:25 Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 01/22] ext4: make ext4_block_zero_page_range() pass out did_zero Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 02/22] ext4: make ext4_block_truncate_page() return zeroed length Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 03/22] ext4: only order data when partially block truncating down Zhang Yi
2026-02-03 9:59 ` Jan Kara
2026-02-04 6:42 ` Zhang Yi
2026-02-04 14:18 ` Jan Kara
2026-02-05 3:27 ` Baokun Li
2026-02-05 14:07 ` Jan Kara
2026-02-06 1:14 ` Baokun Li
2026-02-05 7:50 ` Zhang Yi
2026-02-05 15:05 ` Jan Kara
2026-02-06 11:09 ` Zhang Yi
2026-02-06 15:35 ` Jan Kara
2026-02-09 8:28 ` Zhang Yi
2026-02-10 12:02 ` Zhang Yi
2026-02-10 14:07 ` Jan Kara
2026-02-10 16:11 ` Zhang Yi
2026-02-11 11:42 ` Jan Kara
2026-02-11 13:38 ` Zhang Yi
2026-02-04 4:21 ` kernel test robot
2026-02-10 7:05 ` Ojaswin Mujoo
2026-02-10 15:57 ` Zhang Yi
2026-02-11 15:23 ` Ojaswin Mujoo
2026-02-03 6:25 ` [PATCH -next v2 04/22] ext4: factor out journalled block zeroing range Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 05/22] ext4: stop passing handle to ext4_journalled_block_zero_range() Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 06/22] ext4: don't zero partial block under an active handle when truncating down Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 07/22] ext4: move ext4_block_zero_page_range() out of an active handle Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 08/22] ext4: zero post EOF partial block before appending write Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 09/22] ext4: add a new iomap aops for regular file's buffered IO path Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 10/22] ext4: implement buffered read iomap path Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 11/22] ext4: pass out extent seq counter when mapping da blocks Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 12/22] ext4: implement buffered write iomap path Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 13/22] ext4: implement writeback " Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 14/22] ext4: implement mmap " Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 15/22] iomap: correct the range of a partial dirty clear Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 16/22] iomap: support invalidating partial folios Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 17/22] ext4: implement partial block zero range iomap path Zhang Yi
2026-02-04 0:21 ` kernel test robot
2026-02-03 6:25 ` [PATCH -next v2 18/22] ext4: do not order data for inodes using buffered " Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 19/22] ext4: add block mapping tracepoints for iomap buffered I/O path Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 20/22] ext4: disable online defrag when inode using " Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 21/22] ext4: partially enable iomap for the buffered I/O path of regular files Zhang Yi
2026-02-03 6:25 ` [PATCH -next v2 22/22] ext4: introduce a mount option for iomap buffered I/O path Zhang Yi
2026-02-03 6:43 ` [PATCH -next v2 00/22] ext4: use iomap for regular file's " Christoph Hellwig
2026-02-03 9:18 ` Zhang Yi
2026-02-03 13:14 ` Theodore Tso
2026-02-04 1:33 ` Zhang Yi
2026-02-04 1:59 ` Baokun Li
2026-02-04 14:23 ` Jan Kara
2026-02-05 2:06 ` Zhang Yi
2026-02-05 3:04 ` Baokun Li
2026-02-05 12:58 ` Jan Kara
2026-02-06 2:15 ` Zhang Yi
2026-02-05 2:55 ` Baokun Li [this message]
2026-02-05 12:46 ` Jan Kara
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=4a210be6-eced-4a47-a54b-3f2bc3f3bfbf@huawei.com \
--to=libaokun1@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=libaokun9@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yi.zhang@huaweicloud.com \
--cc=yizhang089@gmail.com \
--cc=yukuai@alb-78bjiv52429oh8qptp.cn-shenzhen.alb.aliyuncs.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®