Re: Is there a "make hole" (truncate in middle) syscall?

From: Rob Landley
Date: Thu Dec 04 2003 - 19:00:07 EST


On Thursday 04 December 2003 15:48, Mike Fedyk wrote:
> On Thu, Dec 04, 2003 at 02:32:23PM -0600, Rob Landley wrote:
> > You can make a file with a hole by seeking past it and never writing to
> > that bit, but is there any way to punch a hole in a file after the fact?
> > (I mean other with lseek and write. Having a sparse file as the
> > result....)
>
> No, Linux doesn't have this feature.
>
> > What are the downsides of holes? (How big do they have to be to actually
> > save space, is there a performance penalty to having a file with 1000 4k
> > holes in it, etc...)
>
> When you copy them, you need to use tools that know about sparse files and
> how to deal with them. Also, you will only save space on block aligned
> contiguous zeros at least the length of one block.

I knew that bit.

I was thinking of making a toy that would run periodically against a
seldom-changed filesystem, find runs of zeroes of a certain minimum size, and
turn 'em into holes. The fragmentation might not be worth it, though...

Rob
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/