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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0364C433DB for ; Wed, 10 Mar 2021 17:13:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77A1564FC6 for ; Wed, 10 Mar 2021 17:13:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232799AbhCJRMb (ORCPT ); Wed, 10 Mar 2021 12:12:31 -0500 Received: from james.kirk.hungrycats.org ([174.142.39.145]:33552 "EHLO james.kirk.hungrycats.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232727AbhCJRMW (ORCPT ); Wed, 10 Mar 2021 12:12:22 -0500 Received: by james.kirk.hungrycats.org (Postfix, from userid 1002) id 8CF779C41DF; Wed, 10 Mar 2021 12:12:21 -0500 (EST) Date: Wed, 10 Mar 2021 12:12:21 -0500 From: Zygo Blaxell To: telsch Cc: linux-btrfs@vger.kernel.org Subject: Re: no memory is freed after snapshots are deleted Message-ID: <20210310171221.GN32440@hungrycats.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Wed, Mar 10, 2021 at 01:07:47PM +0100, telsch wrote: > Dear devs, > > after my root partiton was full, i deleted the last monthly snapshots. however, no memory was freed. > so far rebalancing helped: > > btrfs balance start -v -musage=0 / > btrfs balance start -v -dusage=0 / > > i have deleted all snapshots, but no memory is being freed this time. > > du -hcsx / > 16G / > 16G total > > btrfs-progs v5.10.1 > Linux arch-server 5.10.21-1-lts #1 SMP Sun, 07 Mar 2021 11:56:15 +0000 x86_64 GNU/Linux > > btrfs fi show / > Label: none uuid: 3d242677-6a15-4ce7-853a-5c82f0427769 > Total devices 1 FS bytes used 37.24GiB > devid 1 size 39.95GiB used 39.95GiB path /dev/mapper/root > > btrfs fi df / > Data, single: total=36.45GiB, used=35.86GiB > System, DUP: total=32.00MiB, used=16.00KiB > Metadata, DUP: total=1.72GiB, used=1.38GiB > GlobalReserve, single: total=215.94MiB, used=0.00B Check btrfs sub list -d / to make sure there are no deleted snapshots pending. If a snapshot has a single open file on it (or a bind mount or similar equivalent to an open file), the cleaner will not delete it until the last open file descriptor is closed. You'll have to find the process with the open file and convince it to close the file (or kill the process). This can be tricky since lsof and fuser are not able to identify open files on deleted snapshots, so these tools are not usable. Rebooting will force all the files to be closed. You can also use 'compsize' and measure the difference in size between 'referenced' and 'usage' columns. If referenced is below usage then you have some big extents with small references (this can be caused by prealloc and some database write patterns, or by using a non-btrfs-extent-aware dedupe tool). Defrag will get rid of those if you have no snapshots. You will have to start at the top of the filesystem tree and work your way down until you find the offending files, as compsize can only give you a summary. > any ideas how to solve this without recreating filesystem? > > thx!