From: Gionatan Danti <g.danti@assyoma.it>
To: linux-btrfs@vger.kernel.org
Cc: g.danti@assyoma.it
Subject: Question about fallocate
Date: Tue, 01 Jul 2014 12:16:34 +0200 [thread overview]
Message-ID: <53B28A82.2000907@assyoma.it> (raw)
Hi all,
I'm doing some test using a small BTRFS volume on CentOS 6.5 x86_64 (I
know that CentOS 6 use an old kernel and btrfs version and I plan to
replicate the same test on Fedora 20).
From my understanding, disabling CoW and fallocate a file should give a
non-fragmented file. The followind commands show that:
[root@blackhole test]# fallocate test.img -l 1G
[root@blackhole test]# sync
[root@blackhole test]# filefrag -v test.img
Filesystem type is: 9123683e
File size of test.img is 1073741824 (262144 blocks, blocksize 4096)
ext logical physical expected length flags
0 0 269312 262144 eof
test.img: 1 extent found
As you can see, I have a single, continuous block stream.
However, write some 4k blocks into the file leads to fragmentation:
[root@blackhole test]# for id in `seq 1 32`; do dd if=/dev/zero
of=test.img bs=4k count=1 seek=$id conv=notrunc,nocreat
oflag=direct,sync; done
...
[root@blackhole test]# filefrag -v test.img
Filesystem type is: 9123683e
File size of test.img is 1073741824 (262144 blocks, blocksize 4096)
ext logical physical expected length flags
0 0 269312 1
1 1 269313 1
2 2 531456 269314 31
3 33 269345 531487 262111 eof
test.img: 3 extents found
If I don't use fallocate to reserve space, using a simple dd to write 0s
to the target file, the fragmentation do not occour:
[root@blackhole test]# dd if=/dev/zero of=test.img bs=2M count=512
[root@blackhole test]# sync
[root@blackhole test]# for id in `seq 1 32`; do dd if=/dev/zero
of=test.img bs=4k count=1 seek=$id conv=notrunc,nocreat
oflag=direct,sync; done
...
[root@blackhole test]# filefrag -v test.img
Filesystem type is: 9123683e
File size of test.img is 1073741824 (262144 blocks, blocksize 4096)
ext logical physical expected length flags
0 0 269312 262144 eof
test.img: 1 extent found
So, my question is: why writing to a fallocated file produce
fragmentation, even with CoW disabled?
Regards.
--
Danti Gionatan
Supporto Tecnico
Assyoma S.r.l. - www.assyoma.it
email: g.danti@assyoma.it - info@assyoma.it
GPG public key ID: FF5F32A8
next reply other threads:[~2014-07-01 10:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-01 10:16 Gionatan Danti [this message]
2014-07-02 8:04 ` Question about fallocate Duncan
[not found] <20140702014130.47a5ba75@ws>
2014-07-02 10:36 ` Gionatan Danti
2014-07-02 10:52 ` Maurizio Lombardi
2014-07-02 14:04 ` Gionatan Danti
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=53B28A82.2000907@assyoma.it \
--to=g.danti@assyoma.it \
--cc=linux-btrfs@vger.kernel.org \
/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