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 063FEC433EF for ; Mon, 14 Mar 2022 20:06:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244921AbiCNUHS (ORCPT ); Mon, 14 Mar 2022 16:07:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244917AbiCNUHR (ORCPT ); Mon, 14 Mar 2022 16:07:17 -0400 Received: from vps.thesusis.net (vps.thesusis.net [34.202.238.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED247403E6 for ; Mon, 14 Mar 2022 13:06:03 -0700 (PDT) Received: by vps.thesusis.net (Postfix, from userid 1000) id 19022835E1; Mon, 14 Mar 2022 16:05:33 -0400 (EDT) References: <87tuc9q1fc.fsf@vps.thesusis.net> <87tuc7gdzp.fsf@vps.thesusis.net> User-agent: mu4e 1.7.0; emacs 27.1 From: Phillip Susi To: Jan Ziak <0xe2.0x9a.0x9b@gmail.com> Cc: linux-btrfs@vger.kernel.org Subject: Re: Btrfs autodefrag wrote 5TB in one day to a 0.5TB SSD without a measurable benefit Date: Mon, 14 Mar 2022 16:02:41 -0400 In-reply-to: Message-ID: <87ee34cnaq.fsf@vps.thesusis.net> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Jan Ziak <0xe2.0x9a.0x9b@gmail.com> writes: > The actual disk usage of a file in a copy-on-write filesystem can be > much larger than sb.st_size obtained via fstat(fd, &sb) if, for > example, a program performs many (millions) single-byte file changes > using write(fd, buf, 1) to distinct/random offsets in the file. How? I mean if you write to part of the file a new block is written somewhere else but the original one is then freed, so the overall size should not change. Just because all of the blocks of the file are not contiguous does not mean that the file has more of them, and making them contiguous does not reduce the number of them.