linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Landley <rob@landley.net>
To: Vladimir Saveliev <vs@namesys.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Is there a "make hole" (truncate in middle) syscall?
Date: Fri, 12 Dec 2003 15:35:22 -0600	[thread overview]
Message-ID: <200312121535.22375.rob@landley.net> (raw)
In-Reply-To: <1071237719.27730.158.camel@tribesman.namesys.com>

On Friday 12 December 2003 08:01, Vladimir Saveliev wrote:
> On Fri, 2003-12-12 at 16:53, Rob Landley wrote:
> > On Friday 12 December 2003 07:28, Vladimir Saveliev wrote:
> > > Hi
> > >
> > > On Fri, 2003-12-12 at 15:55, Jörn Engel wrote:
> > > > On Thu, 11 December 2003 14:32:12 -0600, Rob Landley wrote:
> > > > > On Thursday 11 December 2003 13:48, Jörn Engel wrote:
> > > > > > If you really do it, please don't add a syscall for it.  Simply
> > > > > > check each written page if it is completely filled with zero. 
> > > > > > (This will be a very quick check for most pages, as they will
> > > > > > contain something nonzero in the first couple of words)
> > > > >
> > > > > Cache poisoning, streaming writes to large RAID arrays...  There
> > > > > are about 8 zllion reasons not to do this.  Really.  (It defeats
> > > > > the whole purpose of DMA, doesn't it?)
> > >
> > > Sorry,
> > > but doesn't truncate do almost exactly what "make hole" is supposed to
> > > do?
> >
> > I have a 2 gigabyte file.  I want to punch a hole from 257 megabytes to
> > 364 megabytes, saving over 100 megs of disk space.  I do NOT want to have
> > to copy off and rewrite 1.6 gigabytes of data from the end of the file. 
> > (There may not even be enough room on the disk, and it would take a long
> > time anyway.)
>
> ok.
> But I asked why would "make hole" have problems you list (8 zillions)
> and truncate would not have them?

Ah.

Truncate doesn't look at the contents of the file, it just frees the space 
regardless of what the data was.  (It doesn't have to load the contents of 
the blocks into memory and look at them in order to make the file's length 
shorter in the metadata and de-allocate those blocks.)

What was suggested a bit earlier was automatically looking at the contents of 
the data being written to disk, and not allocating actual blocks if the data 
is all zeroes.  (A bit like looking at pages of memory and copy-on-write 
aliasing them to the zero page whenever the page is entirely zeroes.)

Truncate doesn't do any of that.  Truncate only plays with metadata, and 
doesn't care about the contents of the file.

Rob

  reply	other threads:[~2003-12-12 21:37 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-04 20:32 Is there a "make hole" (truncate in middle) syscall? Rob Landley
2003-12-04 20:55 ` Måns Rullgård
2003-12-04 21:10 ` Szakacsits Szabolcs
2003-12-05  0:02   ` Rob Landley
2003-12-04 22:33     ` Szakacsits Szabolcs
2003-12-05 11:22     ` Helge Hafting
2003-12-05 12:11   ` Måns Rullgård
2003-12-05 22:41     ` Mike Fedyk
2003-12-05 23:25       ` Måns Rullgård
2003-12-05 23:33       ` Szakacsits Szabolcs
2003-12-05 23:25     ` Szakacsits Szabolcs
2003-12-04 21:48 ` Mike Fedyk
2003-12-04 23:59   ` Rob Landley
2003-12-05 22:42     ` Olaf Titz
2003-12-04 22:53 ` Peter Chubb
2003-12-05  1:04   ` Philippe Troin
2003-12-05  2:39     ` Peter Chubb
2003-12-08  4:03     ` bill davidsen
2003-12-04 23:23 ` Andy Isaacson
2003-12-04 23:42   ` Szakacsits Szabolcs
2003-12-05  2:03     ` Mike Fedyk
2003-12-05  7:09       ` Ville Herva
2003-12-05 11:22   ` Anton Altaparmakov
2003-12-05 11:44     ` viro
2003-12-05 14:27       ` Anton Altaparmakov
2003-12-05 21:00   ` sparse file performance (was Re: Is there a "make hole" (truncate in middle) syscall?) Andy Isaacson
2003-12-05 21:12     ` Linus Torvalds
2003-12-08 20:43       ` Andy Isaacson
2003-12-11  5:13 ` Is there a "make hole" (truncate in middle) syscall? Hua Zhong
2003-12-11  6:19   ` Rob Landley
2003-12-11 18:58   ` Andy Isaacson
2003-12-11 19:15     ` Hua Zhong
2003-12-11 19:43       ` Andreas Dilger
2003-12-12 21:37         ` Daniel Phillips
2003-12-11 19:48       ` Jörn Engel
2003-12-11 19:55         ` Hua Zhong
2003-12-11 19:58         ` Andy Isaacson
2003-12-12 12:18           ` Jörn Engel
2003-12-12 15:40             ` Andy Isaacson
2003-12-12 16:03               ` Jörn Engel
2003-12-11 20:32         ` Rob Landley
2003-12-12 12:55           ` Jörn Engel
2003-12-12 13:28             ` Vladimir Saveliev
2003-12-12 13:43               ` Jörn Engel
2003-12-12 13:52                 ` Vladimir Saveliev
2003-12-12 14:04                   ` Jörn Engel
2003-12-12 13:53               ` Rob Landley
2003-12-12 14:01                 ` Vladimir Saveliev
2003-12-12 21:35                   ` Rob Landley [this message]
2003-12-15 10:00                     ` Vladimir Saveliev
2003-12-15 11:52                       ` Rob Landley
2003-12-15 13:26                         ` Jörn Engel
2003-12-12 13:39             ` Rob Landley
2003-12-12 13:56               ` Jörn Engel
2003-12-12 14:24                 ` Jörn Engel
2003-12-12 21:37                   ` Rob Landley
2003-12-15 12:47                     ` Jörn Engel
2003-12-16  5:43                       ` Rob Landley
2003-12-16 11:05                         ` Jörn Engel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200312121535.22375.rob@landley.net \
    --to=rob@landley.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vs@namesys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).