From: Phillip Lougher <phillip@lougher.demon.co.uk>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: adilger@sun.com, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: Zero-clearing all zero-clearable bytes.
Date: Sun, 23 Nov 2008 03:05:47 +0000 [thread overview]
Message-ID: <4928C88B.3040101@lougher.demon.co.uk> (raw)
In-Reply-To: <200811230915.CII90122.SFtOMFQHOVLOFJ@I-love.SAKURA.ne.jp>
Tetsuo Handa wrote:
> Hello.
>
> Andreas Dilger wrote:
>> Why would you fill the buffer with 0xff instead of 0?
>> In fact no such program is needed, just "dd if=/dev/zero of=/{fs}/tmp"
>> and then delete the file.
>>
> To avoid that the /{fs}/tmp is created as a sparse file.
>
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.
For example:
$ dd if=/dev/zero of=small-file bs=512 count=16
16+0 records in
16+0 records out
8192 bytes (8.2 kB) copied, 0.000187744 seconds, 43.6 MB/s
phillip@dylan:/tmp$ stat small-file
File: `small-file'
Size: 8192 Blocks: 16 IO Block: 4096 regular file
Device: 801h/2049d Inode: 847831 Links: 1
The zero filled file uses 16 blocks (16 * 512 bytes = 8K), and so we
know it isn't sparsely stored.
You can get dd to seek a number of blocks into the output file before
writing, this will create a sparse file...
$ dd if=/dev/zero of=small-file bs=512 count=16 seek=16
16+0 records in
16+0 records out
8192 bytes (8.2 kB) copied, 0.000212609 seconds, 38.5 MB/s
phillip@dylan:/tmp$ stat small-file
File: `small-file'
Size: 16384 Blocks: 16 IO Block: 4096 regular file
Device: 801h/2049d Inode: 847831 Links: 1
A 16K file is only using 16 blocks, and so 8K is stored sparsely.
Phillip
next prev parent reply other threads:[~2008-11-23 3:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-22 3:36 Zero-clearing all zero-clearable bytes Tetsuo Handa
2008-11-22 17:44 ` Andreas Dilger
2008-11-23 0:15 ` Tetsuo Handa
2008-11-23 3:05 ` Phillip Lougher [this message]
2008-11-23 4:27 ` Phillip Lougher
2008-11-23 5:03 ` Tetsuo Handa
2008-11-23 11:25 ` Henrique de Moraes Holschuh
2008-11-24 14:56 ` Martin Steigerwald
2008-11-25 10:59 ` Tetsuo Handa
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=4928C88B.3040101@lougher.demon.co.uk \
--to=phillip@lougher.demon.co.uk \
--cc=adilger@sun.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
/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