The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* ext4: fsync waits for journal credits behind throttled writeback
@ 2026-12-01 16:37 Tianyi Chen
  2026-12-02  5:01 ` Theodore Tso
  0 siblings, 1 reply; 4+ messages in thread
From: Tianyi Chen @ 2026-12-01 16:37 UTC (permalink / raw)
  To: Theodore Ts'o, Jan Kara
  Cc: Andreas Dilger, Baokun Li, Ojaswin Mujoo, Ritesh Harjani,
	Zhang Yi, linux-ext4, linux-kernel, hi

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.

With the default dioread_nolock, I saw 28 add_transaction_credits()
waits of at least 10 ms on the shared filesystem (12.2 s total), and
none with separate filesystems. In all 28, the task that woke the
writer was a kworker just seen entering jbd2_journal_start_reserved().
This test did not identify the particular reservation or bio.

In a separate run on a modified kernel I could follow the flusher's
reservation until the conversion worker returned the credits. Is it
expected that a group's pending writeback can tie up journal credits
long enough to delay an unrelated writer on the same filesystem?

Thanks,
Tianyi

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

* 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

* Re: ext4: fsync waits for journal credits behind throttled writeback
  2026-12-02  5:01 ` Theodore Tso
@ 2026-12-02  6:31   ` Tianyi Chen
  2026-12-02 17:25     ` Theodore Tso
  0 siblings, 1 reply; 4+ messages in thread
From: Tianyi Chen @ 2026-12-02  6:31 UTC (permalink / raw)
  To: Theodore Tso
  Cc: Jan Kara, Andreas Dilger, Baokun Li, Ojaswin Mujoo,
	Ritesh Harjani, Zhang Yi, linux-ext4, linux-kernel, hi

On Wed, Dec 02, 2026 at 12:01:35AM -0500, Theodore Tso wrote:
> 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.

Thanks, Ted! That clears it up for me. I wasn't expecting love letters
in an fsync thread. :)

Tianyi

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

* Re: ext4: fsync waits for journal credits behind throttled writeback
  2026-12-02  6:31   ` Tianyi Chen
@ 2026-12-02 17:25     ` Theodore Tso
  0 siblings, 0 replies; 4+ messages in thread
From: Theodore Tso @ 2026-12-02 17:25 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 03:31:17PM -0500, Tianyi Chen wrote:
> On Wed, Dec 02, 2026 at 12:01:35AM -0500, Theodore Tso wrote:
> > 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.
> 
> Thanks, Ted! That clears it up for me. I wasn't expecting love letters
> in an fsync thread. :)

Yeah, this has come up before.  A few years back, someone was trying
to use Kubernetes, and they wanted to cap how much I/O various
containers might be using so one container couldn't cause problems for
the others.

In that case, the only real solution was to use separate block devices
for each containers and then use prop i/o on the block device;
however, (a) this inhibits sharing between containers, which might not
be an issue, and (b) it's potentially wasteful of storage space.  You
can use something like thin-provisioning (dm-thin) to mitigate the
waste of storage space, but this doesn't solve the data isolation
problem, and you still have wasted space because of the file system
metadata.

Cheers,

						- Ted

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

end of thread, other threads:[~2026-12-02 17:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-12-02 17:25     ` Theodore Tso

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