All of lore.kernel.org
 help / color / mirror / Atom feed
* Question about fallocate
@ 2014-07-01 10:16 Gionatan Danti
  2014-07-02  8:04 ` Duncan
  0 siblings, 1 reply; 5+ messages in thread
From: Gionatan Danti @ 2014-07-01 10:16 UTC (permalink / raw)
  To: linux-btrfs; +Cc: g.danti

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

^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <20140702014130.47a5ba75@ws>]

end of thread, other threads:[~2014-07-02 14:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-01 10:16 Question about fallocate Gionatan Danti
2014-07-02  8:04 ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.