From owner-freebsd-hackers@FreeBSD.ORG Sat Jun 16 20:34:56 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B77FC1065741 for ; Sat, 16 Jun 2012 20:34:56 +0000 (UTC) (envelope-from mwm@mired.org) Received: from mail-qc0-f182.google.com (mail-qc0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 55B2F8FC0A for ; Sat, 16 Jun 2012 20:34:56 +0000 (UTC) Received: by qcsg15 with SMTP id g15so2740271qcs.13 for ; Sat, 16 Jun 2012 13:34:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:subject:message-id:in-reply-to:references:organization :x-mailer:face:mime-version:content-type:content-transfer-encoding :x-gm-message-state; bh=PUdMTyMSNs2DM8q8AfOZCl1RmuQdsSJwQ7FQuVjNJCo=; b=AGMM+TwYF527OWqEBXEqucWfhCv1I1N+aFlUvWltLKmc36Oxo9TgECUcrX0Ntps8NR ZWFQQhXsv2NUAPW+r7aA5aFllI9nf65tfUb/wn8SKwTHduR3q/DhC+z/bydNN00gLXSZ vrbCAFP22GPESAn4nns9XUbmm1lMgQaUtpPx/XK2u0sym5pjlYO6l22nRO+7NDgPr8G7 Mn+5xZAENQg9s4C10RfU874x9vP3ITeQ7cbewRGvjFGTT4QhNT53MevXrfry8G2eBb2y Mr/GDoc5lJ4Mkcr/yJjM4PJ8n4Hrklh5sa5qkSVqYmZKuR12qXA/Dh+yuuUS61vHTHQl x51g== Received: by 10.224.105.79 with SMTP id s15mr16725343qao.28.1339878895768; Sat, 16 Jun 2012 13:34:55 -0700 (PDT) Received: from bhuda.mired.org (74-140-201-117.dhcp.insightbb.com. [74.140.201.117]) by mx.google.com with ESMTPS id fe8sm30700079qab.11.2012.06.16.13.34.54 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 16 Jun 2012 13:34:55 -0700 (PDT) Date: Sat, 16 Jun 2012 16:34:50 -0400 From: Mike Meyer To: freebsd-hackers@freebsd.org Message-ID: <20120616163450.2d0fa3c7@bhuda.mired.org> In-Reply-To: References: <4FD94240.6060806@delphij.net> Organization: Meyer Consulting X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.6; amd64-portbld-freebsd8.3) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAG1BMVEXguIzRkGnhyaz069mXhW0WHRnbrnR9WCQ6LB0CchNMAAACSUlEQVQ4jV2TQW7jMAxFGaPQOgQEdZaGMsgBrAvUA03dCxj1Uu4U2gfwQD7AGNax51NK07RcxXz6/CSl0Ij450vkPG1jzpIZM1UwDCl/xB14TWnNX8A00Qj5a0mnVFVbVUz4MeErea2HikSRqZzY894zwg9p2+/AtO8LzxFED+tNAUFeU29iFOLRxlZAcdo9A8wi8ZBMV4BKPde82Oxrvs6BTkulQIClte0DLFzzsKk9j1MBex8iUaP00Bd78S/muyFScrTXz6zLkEUxJp+SabQfNOs4f4Jpx5qSZ/304PWwlEWP1cOn/mJQR7EOD+uKhjcBLziuL7xoY5Xm+VFAUSw/LwwwsHEHxihpwV4EJH0xXRkbw1PkRw+X4pEuSJwBggqk+HEYKkiL5/74/nQkogigzQsAFrakxZyfw3wMIEEZPv4AWMfxwqE5GNxGaERjmH+PG8AE0L4/w9g0lsp1raLYAN5azQa+AOoO9NwcpFkTrG2VKNMNEL5UKUUAw34tha0z7onUG0oBoNtczE04GwFE3wCHc0ChezAJ6A1WMV81AtY7wDAJSlXwV+4cwBvsOsrQMRawfQEBz0deEZ7WNpV2szckIKo5VpDHDSDvF1GItwqqAlG01Hh50BGtVhuUkjkasg/14bYFGCgWg1fSWHvmOoJck2xdp9ZvZBHzDVTzX23TkrOn7qe5U2COEw5D4Vx3qEQpFY2Z/3QFnJxzp7YCmSMG19nOUoe869zZfOQb5ywQuWu0yCn5+8gxZz+BE7vG3j4/wbf4D/sXN9Wug1s7AAAAAElFTkSuQmCC Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQkfMge1gyRAWJ0KpZJYl305yx7RKKZXKhCkPKfZjBfFyKpAd/v8MuB5YJnGprvz+QLqPE8w Subject: Re: BIO_DELETE equivalent for file on FFS filesystem X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jun 2012 20:34:56 -0000 On Sat, 16 Jun 2012 21:04:26 +0100 Chris Rees wrote: > On Jun 16, 2012 8:37 PM, "Xin LI" wrote: > > > > On Sat, Jun 16, 2012 at 12:01 PM, Chris Rees wrote: > > > On Jun 14, 2012 5:49 AM, "Wojciech Puchar" < > wojtek@wojtek.tensor.gdynia.pl> > > > wrote: > > >>>> > > >>>> file to take 900MB or... can i call some system function to "punch" > > >>>> holes? > > >>> > > >>> > > >>> I think you can only truncate the file at this time, pretty much like > > >>> brk() works for memory. > > >> > > >> > > >> > > >> BAD. suppose i keep windoze VM image on filesystem which takes 10GB but > > > uses 5GB. > > >> > > >> i could write simple program to find out what blocks are unused and > > > then...do nothing. > > >> > > > > > > What if you cp it? > > > > That would be a dd(1) unless we teach cp(1) how to do sparse. I think > > what he wanted is to tell the OS "I don't need block XX - YY anymore" > > and the OS creates a sparse hole, which is not available at this time. > > Sorry, I must have misread. I take it cp would take a file with holes and > only copy the data part? i.e. take a 10G file of which 5G is a hole, you'd > end up with a 5G file? No, cp just does read()s. Reading data from a hole returns a block full of zeros. A quick test (after writing a program to create the file) shows this: bhuda% df -h . Filesystem Size Used Avail Capacity Mounted on /dev/md0 123M 1.2M 112M 1% /tmp bhuda% ls -lh holey.test -rwxr-xr-x 1 mwm wheel 953M Jun 16 16:22 holey.test Ok, I've got a file that's 953M on an FS with 1.2 meg used. It's got holes. bhuda% cp holey.test foobar /tmp: write failed, filesystem is full cp: foobar: No space left on device And doing a cp fails. Use dd conv=sparse to get the effect you want. http://www.mired.org/ Independent Software developer/SCM consultant, email for more information. O< ascii ribbon campaign - stop html mail - www.asciiribbon.org