From owner-freebsd-stable@FreeBSD.ORG Sun Sep 7 19:55:39 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 85A84106566B for ; Sun, 7 Sep 2008 19:55:39 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.freebsd.org (Postfix) with ESMTP id 59B478FC0A for ; Sun, 7 Sep 2008 19:55:39 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.3/8.14.3) with ESMTP id m87JtbYG038474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 7 Sep 2008 14:55:37 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.3/8.14.2/Submit) id m87JtZjn038468; Sun, 7 Sep 2008 14:55:35 -0500 (CDT) (envelope-from dan) Date: Sun, 7 Sep 2008 14:55:35 -0500 From: Dan Nelson To: Stefan `Sec` Zehl Message-ID: <20080907195535.GA30343@dan.emsphone.com> References: <20080907113045.GA11293@ice.42.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080907113045.GA11293@ice.42.org> X-OS: FreeBSD 7.0-STABLE User-Agent: Mutt/1.5.18 (2008-05-17) Cc: freebsd-stable@freebsd.org Subject: Re: snapshots and disk usage X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Sep 2008 19:55:39 -0000 In the last episode (Sep 07), Stefan `Sec` Zehl said: > Hi, > > I am using ufs snapshots on RELENG_7 for some time now, and am generally > happy with it. I have noticed a strange behaviour when removing large > amount of files, and wanted to ask if this is expected. > > Before starting, we check the free space on /usr: > > | ice:/usr>df -h . > | Filesystem Size Used Avail Capacity Mounted on > | /dev/ad4s2.elid 9.7G 7.6G 1.3G 64% /usr > > Then delete /usr/obj and run df again: > > | ice:/usr>sudo rm -rf obj 2>/dev/null > | ice:/usr>df -h . > | Filesystem Size Used Avail Capacity Mounted on > | /dev/ad4s2.elid 9.7G 5.7G 3.2G 64% /usr > > This is unexpected. With snapshots, removing something should not > release space. > > Sure enough, in the course of the next minute, the fake free space > vanishes.... > > | ice:/usr>df -h . > | Filesystem Size Used Avail Capacity Mounted on > | /dev/ad4s2.elid 9.7G 5.9G 3.0G 66% /usr > | ice:/usr>df -h . > | Filesystem Size Used Avail Capacity Mounted on > | /dev/ad4s2.elid 9.7G 6.6G 2.3G 74% /usr > | ice:/usr>df -h . > | Filesystem Size Used Avail Capacity Mounted on > | /dev/ad4s2.elid 9.7G 8.6G 269M 97% /usr > > and all the free space is allocated in the snapshot: > > | ice:~>sudo snapshot list > | Filesystem User User% Snap Snap% Snapshot > | /usr 8GB 89.3% 2GB 21.5% daily.1 > | /usr 8GB 89.3% 344MB 3.5% daily.0 > | /usr 8GB 89.3% 344MB 3.5% weekly.0 > | /usr 8GB 89.3% 344MB 3.5% hourly.1 > | /usr 8GB 89.3% 7MB 0.1% hourly.0 > > My understanding so far was that df may underreport free space, but i > find overreporting it a bit troublesome. -- What would happen if I tried > to use that space before it was allocated to the snapshot? I think you're running into the softupdates delay. When you delete a file on a SU-enabled filessytem, the space isn't actually freed until sync. But applications expect that statfs() info is updated immediately, so the kernel pretends that the space is available. That doesn't really work with a snapshot, since if you delete a file that existed in the snapshot, no space will free up. So you see a jump in freespace as the kernel fakes the f_bfree statfs amount, then it slowly drops to the correct value as the deletions actually sync to disk. -- Dan Nelson dnelson@allantgroup.com