From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=18.9.28.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796187733; b=tzCbzifj5F3rBlUkiDxlx8OpdwEvxhW4vr4bLlSKW+pzZ7v5IonVaJ2VjGPUa6C4wQJb KUxaB8KMgYCKSzA69Y8iCvdzclf961Pk8E6jZdiWUJQf5QWH6NmUei4BP16Vv9mfQhU9i qyOuNpnCBulzQtd0eRo/XpWrfC29aHDvnUsvn1zcIOMO3b6evs9zHHKxUbCUhUYXlCzFo 41ZcDwuZOSx0eXvMCs8v7C/A+0hWcS2IPAz09dotBsgkhE1NINfL2pyT0ZGK0LVDbyyW+ bRupXk9gEX2f/4E0i4dDo2YoPeqXCQRfKex6ye1ftyIX6zhk24K7qjDC+33+r+pFgnA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796187733; h=DMARC-Filter:Received:DKIM-Signature:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=iu5pRHKl26fXq60cuEUMbQ3NesEBWAIk0QgU8vPUb0c=; b=ZCGTzbDXvB8ywWZcf6yk8JNlzz3ieUqhdi+DJmUI7QLSgrrEnAnXdGsEwIikGqt4nVM6 hDhcOAcrhl7D4Y6OnDwt3rwos6YgFUS7bKXlSKt+RXCTCuT76xwMlfHrgKbJDNov2QQou fiM/7n0YuUWsd7wkbNu7S5a+BM81DO70eH6wTPN5xNSHUiMOlT04L296o7OFWcvV3ISgJ +M4jmAlBwZFOZCpKLXcXsNXjL5jthRIb9F4TQBsoDtP9KVm+HgxvnRxt4+fNOkawCd5PR GnX7R0DD+81brCaGCzy6zVOEvmkXs8M8p7VehOA5v6JtQRMPBm3W3lmxtaf7wtwJVFQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=mit.edu; spf=pass smtp.mailfrom=mit.edu; dkim=pass header.d=mit.edu header.i=@mit.edu header.a=rsa-sha256 header.s=outgoing header.b=ktGMmuU5; arc=none smtp.remote-ip=18.9.28.11 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B577606A325 for ; Wed, 2 Dec 2026 05:02:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6B577606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mit.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mit.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mit.edu header.i=@mit.edu header.a=rsa-sha256 header.s=outgoing header.b=ktGMmuU5 Received: from macsyma.thunk.org (pool-108-26-156-184.bstnma.fios.verizon.net [108.26.156.184]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 6B251a2I026678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 2 Dec 2026 00:01:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1796187700; bh=iu5pRHKl26fXq60cuEUMbQ3NesEBWAIk0QgU8vPUb0c=; h=Date:From:Subject:Message-ID:MIME-Version:Content-Type; b=ktGMmuU5wKoyaEz3LT4NRxOfAKjU2rnjV965K+aBD+A3miRS7XIPt/7K0TtT1rM8p lpecKIrcBczI4lSpvBb3abKDg4KEVjwsyKJ60Fl1Nxd1SKlR/t0o1LSvn4b59cdi8d Uwack9whGSrsgLEamy3DTyQHKhQaD8N86e9ZFeBMEw7NT8hzkvKfS3fC1v9KykdbUn 8623PmkDcZpTbZ/rLFKk+4Iq7HOeLUZADS2llaH2sIyKYdCgrcDcHXMpbWEOf1Y1uB uDS6CexfDSgkgz1liG6HIB7ADVVyHjiTUUuDHe+MDMuIPuU1MdBna5UNIPov1SuN8c d1iPb93s1EwTA== Received: by macsyma.thunk.org (Postfix, from userid 15806) id EE9FC2ABD428; Wed, 2 Dec 2026 00:01:35 -0500 (EST) Date: Wed, 2 Dec 2026 00:01:35 -0500 From: "Theodore Tso" To: Tianyi Chen Cc: Jan Kara , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: ext4: fsync waits for journal credits behind throttled writeback Message-ID: References: <20261201163709.467333-1-hi@tychen.cc> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261201163709.467333-1-hi@tychen.cc> 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