Odd block-count behaviour
Hi,
I've just been copying large quantities of data from one btrfs
volume to another, and while watching the progress of the copy, I've noticed something odd.
$ mv source-dir dest-dir $ watch du -ms source-dir dest-dir
This gives me a count of the size of the source and target
directories, every 2 seconds. As expected, the size of the source dir stays constant, and the size of the destination directory increases. Except when it doesn't.
Occasionally, while copying, the size of the dest-dir *drops* by
several (tens of) megabytes. I'm not too worried about this, as it all seems to be copying the data OK, but it just seems a bit odd, and was wondering of there was a sane explanation for this behaviour.
I'm running a linux.org 2.6.32.2 kernel, and the destination
filesystem has just been created using the most recent btrfs tools.
Hugo.
Signature · 3 lines
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
--- There's many a slip 'twixt wicket-keeper and gully. --- Quoted 14 lines · Hugo Mills
Hi,
I've just been copying large quantities of data from one btrfs
volume to another, and while watching the progress of the copy, I've noticed something odd.$ mv source-dir dest-dir $ watch du -ms source-dir dest-dirThis gives me a count of the size of the source and target
directories, every 2 seconds. As expected, the size of the source dir stays constant, and the size of the destination directory increases. Except when it doesn't.
Quoted 4 lines
Occasionally, while copying, the size of the dest-dir *drops* by
several (tens of) megabytes. I'm not too worried about this, as it all seems to be copying the data OK, but it just seems a bit odd, and was wondering of there was a sane explanation for this behaviour.
If the files are small, they can be packed into the metadata btree. But this doesn't happen until the file is actually written.
So we start with a worst case estimate on the number of blocks the file will consume (4k) and then when it is actually written we update the metadata to reflect the number of blocks it is actually using (maybe 1 or 2).
You can see this with a test:
mkdir testdir
cd testdir
dd if=/dev/zero of=foo bs=512 count=1
du -k .
sync
du -k .
-chris