* Re: ext4: fsync waits for journal credits behind throttled writeback
2026-12-01 16:37 ext4: fsync waits for journal credits behind throttled writeback Tianyi Chen
@ 2026-12-02 5:01 ` Theodore Tso
2026-12-02 6:31 ` Tianyi Chen
0 siblings, 1 reply; 4+ messages in thread
From: Theodore Tso @ 2026-12-02 5:01 UTC (permalink / raw)
To: Tianyi Chen
Cc: Jan Kara, Andreas Dilger, Baokun Li, Ojaswin Mujoo,
Ritesh Harjani, Zhang Yi, linux-ext4, linux-kernel
On Wed, Dec 02, 2026 at 01:37:08AM -0500, Tianyi Chen wrote:
> Hi Ted, Jan,
>
> An uncapped writer's fsync slowed down when it shared an ext4
> filesystem with a write-limited group (io.max wbps=16 MiB/s). On
> unmodified f47d223627f8 in one KVM boot, the uncapped writer's fsync
> p95 was 222 ms on the shared filesystem and 3.8 ms with separate
> filesystems on the same disk. The other group's cap was unchanged.
In general, if you try to use proportional I/O (where different
cgroups have different capped I/O bandwidth), there are always some
potential priority inversions. Even without the journal, if one
process is blocked waiting on some lock which is being held by another
process in a different cgroup which is capped, the high priority
process can get blocked behind the lower priority process.
Once journalling is enabled, this gets far more tricky. The simplest
one is that if the file system is mounted by a capped process, the
journal commit thread will be capped, and everyone who tries to write
to the file system may be subject to being blocked until until the
commit has completed. Even if the journal thread is not capped, there
are two other things that bite you.
First, the commit can't start until all of the processes that are
currently modifying the file system have finished their operations.
So when the journal starts getting full, or an fsync() is requested
forcing a commit to happen, no new "handles can get started"; any
process attempting to modify file system metadata will block until the
commit has completed. Most handles are short, and only involve a few
metadata blocks worth of mutations. However, the exception to that is
a truncate or unlink operation, which may need to read many metadata
blocks, and modifying them. So if a process doing a truncate gets
capped, the time to complete the truncate handle may be significant,
and all of the other processes that are waiting to start a new handle
will sit there, twiddling their fingers, until the last process with
an open handle closes it.
Once all of the handles are closed, then the commit thread can start
doing its thing. But one of the things that the commit thread needs
to do before it can complete the commit is in data=ordered mode, all
newly allocated blocks must be written to disk. This is because
otherwise, the stale data (the previous contents of the data blocks)
might get exposed after a crash. This stale data might be Personally
Identifiable Information --- someone's SSN, credit card numbers, birth
date, etc, or something embarassing (some one's love letter, or an
offer to sell export controlled GPU's to a restricted country ---
actually, that might be illegal, but if the US President has promised
to pardon the CEO in question, it's merely only embarassing :-).
But the writeback thread caps the I/O write rate based on which
process first dirtied the page. So if the page was dirtied by a
capped process, that's going to slow down the writeback, and until all
of the writeback has been completed --- the commit is not going to
complete. And so the process trying to do the fsync(), as well as any
other process waiting to get a handle so they can modify the file
system, will all be sitting their twiddling their fingers until the
writeback has completed, so the commmit can complete.
Now, if you mount the file system using data=writeback, then it won't
require the writeback before the commit is allowed to complete.
However, after a crash, you risk stale data exposure, which might
(depending on your legal obligations) open you up to civil or criminal
penalties. Or, it might just be embarassing. YMMV.
But remember, while data=writeback will reduce one of the larger
causes of priority inversion, it won't completely eliminate it.
Ultimately, using proportional I/O with a shared journalling file
system is always going to be fraught. This has always been true, and
has been for years.
Changes in the kernel, or in the workload, might make this problem
better or worse. But fundamentally this sort of thing has always
been an issue.
Cheers,
- Ted
^ permalink raw reply [flat|nested] 4+ messages in thread