Skip to contentSkip to conversation

nocow and compression

DISCUSSION Marc Dietrich 2 participants 4 messages Oct 27, 2014 Btrfs file system

lore
Share & tools
lore
#0 lore raw

Hi,

I created a filesystem and mounted it with compress-force=lzo. Then I did:

# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      100M  4.1M   96M   5% /mnt
# yes "Hello World" | dd of=/mnt/test iflag=fullblock bs=1M count=20 
status=none
yes: standard output: Broken pipe
yes: write error

# sync; ls -l ; df -h .
total 20480
-rw-r--r-- 1 root root 20971520 Oct 27 13:48 test

Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      100M  4.7M   96M   5% /mnt

so far so good ...

# touch test2; chattr +C test2
# dd if=test of=test2 conv=notrunc bs=1M iflag=fullblock oflag=append 
status=none
# sync; ls -l ; df -h .
total 40960
-rw-r--r-- 1 root root 20971520 Oct 27 13:51 test
-rw-r--r-- 1 root root 20971520 Oct 27 13:51 test2
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      100M   25M   76M  25% /mnt

oops, no compression.

Is this intended?

Marc

#1 lore raw
Quoted 2 lines · Le lundi 27 octobre 2014, 13:56:07 Marc Dietrich a écrit :

oops, no compression.
Is this intended?

« Compression does not work for NOCOW files » is clearly stated in

https://btrfs.wiki.kernel.org/index.php/Compression#How_does_compression_interact_with_direct_IO_or_COW.3F

Kind regards.

Signature · 5 lines
Swâmi Petaramesh <[email protected]> http://petaramesh.org PGP 9076E32E

Quand les doutes sont balayés, la foi véritable réapparaît, confirmée et 
redressée. Plus rien ne demeure, rien qu'il faille se remémorer.
-- Seng-Ts'an, Troisième Patriarche, Le Sin-sin-ming (VIIe s)
#3 lore raw

As far as I understood, "NOCOW" means that modified parts of files be rewritten into place, whereas compression causes compressed blocks of variable sizes to be created (depending upon their compression ratio). Changing a block in a file will most probably change its compressed size, and then you see why it cannot be rewritten into place...

Somebody correct me if I'm wrong ;-)

Quoted 11 lines · Le lundi 27 octobre 2014, 14:06:36 Marc Dietrich a écrit :
Quoted 5 lines

« Compression does not work for NOCOW files » is clearly stated in

https://btrfs.wiki.kernel.org/index.php/Compression#How_does_compression_i
nt eract_with_direct_IO_or_COW.3F

ah, sorry, I somehow overlooked this.

Thanks

Marc

Signature · 4 lines
Swâmi Petaramesh <[email protected]> http://petaramesh.org PGP 9076E32E

Tout être manifesté est là pour embaumer, pour exprimer la Présence.
-- Jean-Marc Mantel