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

From: Måns Rullgård
Date: Fri Dec 05 2003 - 07:12:18 EST

Szakacsits Szabolcs <szaka@xxxxxxxxx> writes:

>> What are the downsides of holes? [...] is there a performance penalty to
>> having a file with 1000 4k holes in it, etc...)
> Depends what you do, what fs you use. Using XFS XFS_IOC_GETBMAPX you might
> get a huge improvement, see e.g. some numbers,
> The problem is, 0 general purpose (like cp, tar, cat, etc) util supports
> it, you have to code your app accordingly.

I found this paragraph in the man page of GNU cp:

A `sparse file' contains `holes' - sequences of
zero bytes that do not occupy any physical disk
blocks; the `read' system call reads these as
zeroes. This can both save considerable disk space
and increase speed, since many binary files contain
lots of consecutive zero bytes. By default, cp
detects holes in input source files via a crude
heuristic and makes the corresponding output file
sparse as well.

The WHEN value can be one of the following:

auto The default behavior: the output file is
sparse if the input file is sparse.

always Always make the output file sparse. This is
useful when the input file resides on a
filesystem that does not support sparse
files, but the output file is on a filesys-
tem that does.

never Never make the output file sparse. If you
find an application for this option, let us

Måns Rullgård

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at