From owner-freebsd-questions@freebsd.org Thu Aug 24 09:40:42 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE298DDB130 for ; Thu, 24 Aug 2017 09:40:42 +0000 (UTC) (envelope-from frank2@fjl.co.uk) Received: from bs1.fjl.org.uk (bs1.fjl.org.uk [84.45.41.196]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "bs1.fjl.org.uk", Issuer "bs1.fjl.org.uk" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 632E271A14 for ; Thu, 24 Aug 2017 09:40:41 +0000 (UTC) (envelope-from frank2@fjl.co.uk) Received: from [192.168.1.35] (host86-191-18-76.range86-191.btcentralplus.com [86.191.18.76]) (authenticated bits=0) by bs1.fjl.org.uk (8.14.4/8.14.4) with ESMTP id v7O9ecJk072893 for ; Thu, 24 Aug 2017 10:40:38 +0100 (BST) (envelope-from frank2@fjl.co.uk) Subject: Re: ZFS question re: deletion during compression To: freebsd-questions@freebsd.org References: <20170824022356.19730.qmail@ary.lan> From: Frank Leonhardt Message-ID: <8628b50b-68d8-49f8-6f3e-83a372a05884@fjl.co.uk> Date: Thu, 24 Aug 2017 10:40:38 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170824022356.19730.qmail@ary.lan> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 09:40:42 -0000 On 24/08/2017 03:23, John Levine wrote: > In article you write: >> I'm curious if ZFS didn't allow the file to be deleted while gzip was >> working on it. Merely removing it from the directory listing. Meaning my >> compressed file is fine. > This isn't ZFS, this is the way Unix works. So long as a file has a > link in any directory or is open, it's still live. It's only deleted > and its space reclaimed when it has no names and is not open. > > Look at the library routine tmpfile() which returns a FILE pointer to > a freshly created file with no name. You can write stuff to it, > rewind it, read it, seek around, read or write, just like any other > file. It goes away and its space is reclaimed when the it's closed, > either explicitly or automatically when your program exits. > WHS and remember that a directory entry is just a pointer to the inode. The inode controls the file. Each inode has a reference count telling it how many directory entries point to it. When this drops to zero, the file is deleted. (There are in-memory and on-disk inodes but I'm keeping it simple). The file is opened using the directory to get the inode number of the file. After this you can do what you like with the directory entry, including deleting it, moving it to another place (on the same FS), rename it, link it. You can also rename/move the output file while it's being written. Windoze heads freak when they come across this. To Microsoft is to Limit. Regards, Frank.