From owner-freebsd-stable@FreeBSD.ORG Sat May 29 20:07:57 2010 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 EC4ED1065674 for ; Sat, 29 May 2010 20:07:57 +0000 (UTC) (envelope-from kirk@strauser.com) Received: from kanga.honeypot.net (kanga.honeypot.net [IPv6:2001:470:a80a:1:21f:d0ff:fe22:b8a8]) by mx1.freebsd.org (Postfix) with ESMTP id 960748FC12 for ; Sat, 29 May 2010 20:07:57 +0000 (UTC) Received: from kanga.honeypot.net (localhost [127.0.0.1]) by kanga.honeypot.net (Postfix) with ESMTP id 5D0448245D for ; Sat, 29 May 2010 15:07:56 -0500 (CDT) X-Virus-Scanned: amavisd-new at honeypot.net Received: from kanga.honeypot.net ([127.0.0.1]) by kanga.honeypot.net (kanga.honeypot.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Kr1ZP9aibtCC for ; Sat, 29 May 2010 15:07:54 -0500 (CDT) Received: from [10.0.7.105] (wlan2-105.honeypot.net [10.0.7.105]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by kanga.honeypot.net (Postfix) with ESMTPSA id 9A4FE8244F for ; Sat, 29 May 2010 15:07:54 -0500 (CDT) Message-ID: <4C017419.9010909@strauser.com> Date: Sat, 29 May 2010 15:07:53 -0500 From: Kirk Strauser User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 To: FreeBSD-STABLE Mailing List Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Make ZFS auto-destroy snapshots when the out of space? 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: Sat, 29 May 2010 20:07:58 -0000 I found some nice scripts to regularly snapshot all the filesystems in my ZFS pool at http://www.neces.com/blog/technology/integrating-freebsd-zfs-and-periodic-snapshots-and-scrubs . One thing bothers me, though: I have to intentionally set how many months' worth of snapshots I want to keep. Too many and I run out of room. Too few and I lose some of the benefits of easy recovery of deleted data. My computer is better at bookkeeping than I am, so why not let it? I'd propose standardizing on an attribute like org.freebsd:allowautodestroy. Modify ZFS's disk full behavior to scan for snapshots with that attribute set and destroy the oldest one, and continue until there's enough free space to complete a write requests or until out of "expendable" snapshots to destroy (at which time the normal disk full handler would run). Also run a daily periodic script to ensure that the free space stays below a configurable threshold each day so that ZFS isn't constantly butting up against completely full drives. This would take all configuration guesswork out of the equation and would let me keep as many snapshots as I have space to maintain. If I want to extend my reach back in time, I can add another drive to the pool and the rest is handled automatically. At the same time, should I suddenly *want* to store massive amounts of new data, the snapshots can be easily and automatically cleared out to make room for the stuff I want to hold. What do you think? It seems like this should be pretty easy to implement without requiring any upstream changes or new FreeBSD-only data structures. The whole thing could possibly be implemented in userspace, but I don't know that ZFS has any exception handling callbacks that would make it easy. An unused resource is a wasted resource, right?