Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 657613164BB for ; Sat, 31 Jan 2026 01:07:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769821633; cv=none; b=OA3hZyGoOM+XkfkZiFFE/11MWb7P+jExcOruEbPply+cuzKnAeaj10sZKwfvLXW3WmWX4M7WTjwWgxY1n22uwfKDELzT+3aGiWBePyLvhUbq6dREjlIPWb0vIIKx9GGSvFvUtSq2EEjHW4YYTB2hdfSWg4LF4jki5vHAVVO4BwQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769821633; c=relaxed/simple; bh=sMBxLoDuoX2R1v0jBCiJgef7L56uFzZAYgHm6SCryi0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dCqHSmHoITlfchbKQCRgF3ZlkLflaEwrhX7idWgwWby+Yj2dxKWyHz9ooynYQX4b6WrcDXS1FPJKCy9xR0X8ZmwmazZqe6/6OpbQQZihenx+r2mgAIL3a1Qp7R7TVtCfJ3WXyE12WOppAoMncIdbZ7MqBEIj/Jubj1jwsVui+34= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.com; spf=pass smtp.mailfrom=gmx.com; dkim=pass (2048-bit key) header.d=gmx.com header.i=quwenruo.btrfs@gmx.com header.b=hnJIyZEQ; arc=none smtp.client-ip=212.227.17.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.com header.i=quwenruo.btrfs@gmx.com header.b="hnJIyZEQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.com; s=s31663417; t=1769821618; x=1770426418; i=quwenruo.btrfs@gmx.com; bh=hW8uIMJuZK9CMpQOBDmsFJ766T+K+NgTpEAjidRLrkc=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To:Cc: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=hnJIyZEQayp9i/ibSCC/n6Cdoh5WpVpEOtcskZD06nUuMXx9vwzgjOwmTQa8RF8Y gEtZzsrMcOmbEoNzM7APVIbTQuZRqlaMQ09Q8Xv7s/tsFwNtnh59Zxn9QhzlHcCSq FgTbznFvSBv0fVEZ5vjBC2J5j6tgkyTrcXvBdeDtz5gafbAmFlcoCoT8VljiPAfuN RBSbUmY+b+c7/S/Xv+euWdN6LEtf5V6ZeulztiYxu59t0XQa3oWd2aZvJZPp6G584 xHVWQgf/fNi/u+QcC6IuA8T3IGLU5akblqG1qrx6k+Rrg85v1MVNsZgAq2eW4Cqvl rNMqTFiL5HByj/DMow== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [172.16.0.229] ([159.196.52.54]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MmlXK-1wC0Wq0kf0-00oJHm; Sat, 31 Jan 2026 02:06:58 +0100 Message-ID: <94167ea3-8174-4d35-a316-1f9e46fdb988@gmx.com> Date: Sat, 31 Jan 2026 11:36:54 +1030 Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] btrfs: prevent COW amplification during btrfs_search_slot To: Boris Burkov , Qu Wenruo Cc: Leo Martins , Filipe Manana , linux-btrfs@vger.kernel.org, kernel-team@fb.com References: <20260130214319.3714908-1-loemra.dev@gmail.com> <4bff1e42-57de-4169-b3c0-a2085182cbb3@suse.com> <20260131001118.GA1432933@zen.localdomain> Content-Language: en-US From: Qu Wenruo Autocrypt: addr=quwenruo.btrfs@gmx.com; keydata= xsBNBFnVga8BCACyhFP3ExcTIuB73jDIBA/vSoYcTyysFQzPvez64TUSCv1SgXEByR7fju3o 8RfaWuHCnkkea5luuTZMqfgTXrun2dqNVYDNOV6RIVrc4YuG20yhC1epnV55fJCThqij0MRL 1NxPKXIlEdHvN0Kov3CtWA+R1iNN0RCeVun7rmOrrjBK573aWC5sgP7YsBOLK79H3tmUtz6b 9Imuj0ZyEsa76Xg9PX9Hn2myKj1hfWGS+5og9Va4hrwQC8ipjXik6NKR5GDV+hOZkktU81G5 gkQtGB9jOAYRs86QG/b7PtIlbd3+pppT0gaS+wvwMs8cuNG+Pu6KO1oC4jgdseFLu7NpABEB AAHNIlF1IFdlbnJ1byA8cXV3ZW5ydW8uYnRyZnNAZ214LmNvbT7CwJQEEwEIAD4CGwMFCwkI BwIGFQgJCgsCBBYCAwECHgECF4AWIQQt33LlpaVbqJ2qQuHCPZHzoSX+qAUCZxF1YAUJEP5a sQAKCRDCPZHzoSX+qF+mB/9gXu9C3BV0omDZBDWevJHxpWpOwQ8DxZEbk9b9LcrQlWdhFhyn xi+l5lRziV9ZGyYXp7N35a9t7GQJndMCFUWYoEa+1NCuxDs6bslfrCaGEGG/+wd6oIPb85xo naxnQ+SQtYLUFbU77WkUPaaIU8hH2BAfn9ZSDX9lIxheQE8ZYGGmo4wYpnN7/hSXALD7+oun tZljjGNT1o+/B8WVZtw/YZuCuHgZeaFdhcV2jsz7+iGb+LsqzHuznrXqbyUQgQT9kn8ZYFNW 7tf+LNxXuwedzRag4fxtR+5GVvJ41Oh/eygp8VqiMAtnFYaSlb9sjia1Mh+m+OBFeuXjgGlG VvQFzsBNBFnVga8BCACqU+th4Esy/c8BnvliFAjAfpzhI1wH76FD1MJPmAhA3DnX5JDORcga CbPEwhLj1xlwTgpeT+QfDmGJ5B5BlrrQFZVE1fChEjiJvyiSAO4yQPkrPVYTI7Xj34FnscPj /IrRUUka68MlHxPtFnAHr25VIuOS41lmYKYNwPNLRz9Ik6DmeTG3WJO2BQRNvXA0pXrJH1fN GSsRb+pKEKHKtL1803x71zQxCwLh+zLP1iXHVM5j8gX9zqupigQR/Cel2XPS44zWcDW8r7B0 q1eW4Jrv0x19p4P923voqn+joIAostyNTUjCeSrUdKth9jcdlam9X2DziA/DHDFfS5eq4fEv ABEBAAHCwHwEGAEIACYCGwwWIQQt33LlpaVbqJ2qQuHCPZHzoSX+qAUCZxF1gQUJEP5a0gAK CRDCPZHzoSX+qHGpB/kB8A7M7KGL5qzat+jBRoLwB0Y3Zax0QWuANVdZM3eJDlKJKJ4HKzjo B2Pcn4JXL2apSan2uJftaMbNQbwotvabLXkE7cPpnppnBq7iovmBw++/d8zQjLQLWInQ5kNq Vmi36kmq8o5c0f97QVjMryHlmSlEZ2Wwc1kURAe4lsRG2dNeAd4CAqmTw0cMIrR6R/Dpt3ma +8oGXJOmwWuDFKNV4G2XLKcghqrtcRf2zAGNogg3KulCykHHripG3kPKsb7fYVcSQtlt5R6v HZStaZBzw4PcDiaAF3pPDBd+0fIKS6BlpeNRSFG94RYrt84Qw77JWDOAZsyNfEIEE0J6LSR/ In-Reply-To: <20260131001118.GA1432933@zen.localdomain> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:fys7eqLGLh5MXBCxzacNymvPOnk8WHWrjhlUoQAn5mMv0ilCW5m BzUtRrg8WR1yQD3vOnqyB+rrSn8M49bhFdWW11qJGzfrx/8g/vsRD0NNNhXq1dABfpv1ACT gBhbiKJMEO+TJPW52Fjts1LpcGKNCLAZKUfeFZwOHC4grQQKgewD9W2KjCjl6ibyh5IpfWG obWihpcuJVOjccZn/dBbQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:ZX7lwr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2026/1/31 10:41, Boris Burkov =E5=86=99=E9=81=93: > On Sat, Jan 31, 2026 at 09:04:03AM +1030, Qu Wenruo wrote: >> >> >> =E5=9C=A8 2026/1/31 08:13, Leo Martins =E5=86=99=E9=81=93: >>> On Fri, 30 Jan 2026 12:49:55 +0000 Filipe Manana = wrote: >>> >> [...] >>> >>>> >>>> This was before a recent refactoring of should_cow_block(), but you >>>> should get the ideia. >>>> IIRC all fstests were passing back then, except for one or two which = I >>>> never spent time debugging. >>>> >>>> And as that attempt was before the tree checker existed, we would nee= d >>>> to make sure we don't change and eb while the tree checker is >>>> verifying it - making sure the tree checker read locks the eb should >>>> be enough. >> >> That may still be racy not just to tree-checker, but with the extent bu= ffer >> writeback path. >> >> Even we locked the eb for tree-checker, but someone still modified the = the >> eb after tree-checker but before submission, it can still be very >> problematic. >=20 > Agreed that it feels very fishy, like we can write an eb with bad csum, > much like DIO and unstable pages. But do we think it *actually* matters? >=20 > In principle, if I buffered an eb, wrote total garbage to the disk durin= g > the transaction, but then during the commit wrote out the correct eb, I > think that is still OK. If we crash, that bad eb isn't reachable from > any root when we mount again, right? Yes, that's correct, however still I'd prefer a more consistent behavior= =20 that doesn't introduce any bad csum at any timing. Causing temporary unreachable bad csum seems harmless, but it brings a=20 much bigger opening, that may or may not lead to bad csums for valid=20 tree blocks in the future. [...] >> Although before all the new ideas/attempts, I'm wondering the following= two >> points: >> >> - With the AS_KERNEL_FILE flag, how frequent we're re-dirtying COWed eb= s >> We need extra benchmarks on this first. >=20 > As far as I am concerned, any amount more than zero is a bug when you > consider it from the perspective of the transaction block_rsv. If you > had an 8 deep tree doing splitting, then a single re-cow you didn't plan > on will use space not in the block_rsv. I also have one question related to the exhausted block_rsv. If we COWed a tree block (the old is eb A, older than the current=20 trans), write the new one (eb B) back to disk, the space of eb A will=20 not be available until a full transaction is committed. But if we need to re-dirty eb B and COW it to eb C, shouldn't the space=20 of eb B be available again? So from the perspective of space usage, re-dirtying a COWed block (in=20 the current transaction, except log trees) should not cause extra space=20 usage except the temporary usage before freeing eb B and copy its=20 content to eb C. It should always be the space of the original old on-disk eb, and the=20 new COWed eb, no matter how many times we redirtied it. Or is the problem exactly at the space reservation for such eb B? >=20 > In practice today we see 30x amplification at least. To flip it around, > what amount is "OK"? An amount that doesn't happen to cause ENOSPCs on > most machines? 30x amplification itself should not be the cause of exhausted space, but= =20 whether we can reuse the space of eb B of the above example. Although I agree 30x re-dirtying is very bad, but re-using the eb=20 in-place also means we will still see the same 30x write amplification,=20 and more chance to screw up the writeback handling. I'd like to know more about the source of such aggressive writeback first. Especially if the risk of chances of data race/bad csum is really worthy= =20 after the AS_KERNEL_FILE feature. Thanks, Qu >=20 > I don't think it's responsible to let it slide and hope it doesn't happe= n > too much. There's always systems in global reclaim to worry about as wel= l.. >=20 > I do, however, completely agree that this argument means we should try > to avoid inventing some really wild and costly solution. Ideally we can > find something tidy to plug up the hole :) >=20 >> >> - Is there any pattern of the re-dirtying COWed ebs >> E.g. which trees are re-drity the most frequently? Extent or csum or >> log trees? >=20 > In the Meta fleet data, the subvol trees and the csum tree see by far > the most lock contention, which I think is likely going to be correlated > with COW amplification. But we don't have detailed COW re-dirtying data > yet. >=20 >> >> Can we take advantage of such patterns if they exist? >> >=20 > That is why I wasted everyone's time and brain-cells on those very trick= y > csum commit root patches I kept messing up for like nine iterations :D >=20 > If there are other heuristic improvements I think it's a good idea, but > I think also doesn't change the reality of the transaction block_rsv > over-spend bug. >=20 >> - Is there any less invasive alternatives to changing COW basics? >> E.g. Changing btree_writepages() to utilize some LRU so only the >> oldest/least frequent accessed dirty ebs are written back first. >=20 > With sufficient sustained memory pressure I am not sure that something > like this will work, even to satisfactorily reduce the problem, > but I have not yet reproduced it without resorting to small cgroups > and no AS_KERNEL_FILE (as we have discussed elsewhere) >=20 > Ideas we have considered, which I think would fully solve the bug: > (in no particular order, and I'm sure there are others) >=20 > - Leo's xarray to block writeback on the shortest scope > - Block writeback on a longer but easier to manage scope (e.g. trans_han= dle) > - Block writeback to the whole tree while it's being cow-ed. > - Have writeback also take a new type of tree lock which cow paths do no= t release > - Relax the strictness of the transaction block rsv guarantee >=20 > Personally, I am still quite excited about Filipe's idea and hope we can > make it work. That would be really slick. >=20 > Thanks, > Boris >=20 >> >> Thanks, >> Qu >> >>>> >>>> Thanks. >>>> >>>>> >>>>> Please let me know if you see any issues with this approach or >>>>> if you can think of a better method. >>>>> >>>>> Thanks, >>>>> Leo >=20