From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EED9EC433EF for ; Wed, 16 Mar 2022 19:04:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241626AbiCPTFt (ORCPT ); Wed, 16 Mar 2022 15:05:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239926AbiCPTFs (ORCPT ); Wed, 16 Mar 2022 15:05:48 -0400 Received: from drax.kayaks.hungrycats.org (drax.kayaks.hungrycats.org [174.142.148.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7B87539164 for ; Wed, 16 Mar 2022 12:04:31 -0700 (PDT) Received: by drax.kayaks.hungrycats.org (Postfix, from userid 1002) id 73A0C2607F4; Wed, 16 Mar 2022 15:04:28 -0400 (EDT) Date: Wed, 16 Mar 2022 15:04:26 -0400 From: Zygo Blaxell To: Phillip Susi Cc: Andrei Borzenkov , Jan Ziak <0xe2.0x9a.0x9b@gmail.com>, linux-btrfs@vger.kernel.org Subject: Re: Btrfs autodefrag wrote 5TB in one day to a 0.5TB SSD without a measurable benefit Message-ID: References: <87tuc9q1fc.fsf@vps.thesusis.net> <87tuc7gdzp.fsf@vps.thesusis.net> <87ee34cnaq.fsf@vps.thesusis.net> <5bfd9f15-c696-3962-aaf9-7d0eb4a79694@gmail.com> <87bky5wxt6.fsf@vps.thesusis.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87bky5wxt6.fsf@vps.thesusis.net> Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Wed, Mar 16, 2022 at 02:31:34PM -0400, Phillip Susi wrote: > > Andrei Borzenkov writes: > > > btrfs manages space in variable size extents. If you change 999 bytes in > > 1000 bytes extent, original extent remains allocated because 1 byte is > > still referenced. So actual space consumption is now 1999 bytes. > > Huh? You can't really do that because the page cache manages files in > 4k pages. You can get a 1-byte file reference if you make a reflink of the last block of a 4097-byte file, or punch a hole in the first 4096 bytes of a 4097-byte file. This creates a file containing only a reference to the last byte of the original extent. In theory you could create a 4098-byte file, then make reflinks from that file to two other files covering the last 1 and last 2 bytes; however, that's disallowed in the kernel to make sure that assorted dedupe data leak shenanigans with shared reflinks that don't all end at the same byte in the page can't ever happen.