Re: Zero-clearing all zero-clearable bytes.

From: Tetsuo Handa
Date: Sun Nov 23 2008 - 00:03:40 EST


Hello.

Phillip Lougher wrote:
> Most filesystems will not create a sparse file if zero-byte filled
> blocks are written. To create a sparse file you normally have to seek
> beyond the file end and then write blocks, leaving a hole in-between the
> positions.
>
> The information from stat can tell you if a file has been stored
> sparsely, because the blocks used count will be less than the file size
> suggests.
>
Then, I can use "dd if=/dev/zero" without worrying sparse files.

Phillip Lougher wrote:
> You don't mention what you're using to compress the ext3 image file. If
> you're using Squashfs then it's much better to zero-fill the blocks
> rather than use 255, because Squashfs detects zero-filled blocks and
> stores them sparsely. This not only gets slightly better compression
> (than a compressed zero-filled block), but reading is also slightly faster.
>
Yes, I use squashfs.



What I wanted to do is "Zero-clearing *all zero-clearable* bytes".
Suppose blocks for inode are 8192 bytes and only 128 bytes are in use,
I think there are 8064 bytes I can zero-fill.
Suppose blocks for file data are 8192 bytes and a file's size is 1 byte,
I think there are 8191 bytes I can zero-fill.
Such bytes may have non-zero values because directory entries can be
unlink()ed and file data can be truncate()d.
I wished there is a utility to zero-fill such bytes.


Thanks a lot.
--
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/