zfs-fuse:启用压缩没有效果

zfs-fuse:启用压缩没有效果

我安装在 Debian Wheezy zfs-fuse 文件系统上,并在一个数据集(“存储/备份”)上启用了压缩 gzip-9。当我检查此数据集是否启用压缩时,它显示“是”:

$: zfs get compression storage/backup
NAME         PROPERTY     VALUE     SOURCE
storage/backup  compression  gzip-9    local

du -ah但是,当我检查有或没有任何压缩的压缩率时,sfx get compressratio可以看到。

所有文件,包括可良好压缩的文件(例如文本文件),占用的磁盘大小与未压缩的文件完全相同:

$: zfs get compressratio storage/backup
NAME         PROPERTY       VALUE  SOURCE
stor/backup  compressratio  1.00x  -

为什么会出现这种情况呢?

zfs get all以下是有关数据集的一些信息:

compressratio         1.00x                  -
mounted               yes                    -
quota                 none                   default
reservation           none                   default
recordsize            128K                   default
mountpoint            /storage/backup        default
sharenfs              off                    default
checksum              on                     default
compression           gzip-9                 local
atime                 on                     default
devices               on                     default

答案1

看起来zfs-fuse会每 30 秒更新一次compressratio数据,并且发生的 IO 有限,但还有另一个触发更新的因素,因为后台 IO 或非常大的文件会导致数据更新更快发生。

我已经放了一些测试功能的要点。它们需要一个以 1.00x 启动的干净(无文件)文件系统。

如果脚本在第一次测试时永远暂停,那么您的压缩计数器永远不会更新,并且您的安装有问题。

在 Debian wheezy 机器上运行脚本:

$ uname -a
Linux zfs-fuse 3.2.0-4-686-pae #1 SMP Debian 3.2.54-2 i686 GNU/Linux

结果如下:

$ test_compression compress
Testing [compress]

Testing size [4096]
Waited 0 seconds for [compressratio_is_one]
4096 bytes made up of 1*4096 blocks
Waited 20 seconds for [compresstario_is_not_one]
1.12x

Testing size [16384]
Waited 30 seconds for [compressratio_is_one]
16384 bytes made up of 1*16384 blocks
Waited 30 seconds for [compresstario_is_not_one]
1.53x

Testing size [1048576]
Waited 30 seconds for [compressratio_is_one]
1048576 bytes made up of 1*131072 blocks
Waited 30 seconds for [compresstario_is_not_one]
31.44x

Testing size [33161216]
Waited 30 seconds for [compressratio_is_one]
33161216 bytes made up of 255*131072 blocks
Waited 0 seconds for [compresstario_is_not_one]
202.31x

您可以通过在后台执行一些可能会触发计数器更新的密集操作来将其减少,通常减少一半左右。

在后台

$ while true; do touch somefile; rm somefile; done

然后再次测试:

$ test_compression compress
Testing [compress]

Testing size [4096]
Waited 0 seconds for [compressratio_is_one]
4096 bytes made up of 1*4096 blocks
Waited 5 seconds for [compresstario_is_not_one]
1.11x

Testing size [16384]
Waited 17 seconds for [compressratio_is_one]
16384 bytes made up of 1*16384 blocks
Waited 17 seconds for [compresstario_is_not_one]
1.50x

Testing size [1048576]
Waited 16 seconds for [compressratio_is_one]
1048576 bytes made up of 1*131072 blocks
Waited 10 seconds for [compresstario_is_not_one]
29.73x

Testing size [33161216]
Waited 0 seconds for [compressratio_is_one]
33161216 bytes made up of 244*131072 blocks
Waited 0 seconds for [compresstario_is_not_one]
201.35x

值得注意的是,在 FreeBSD 上大约每 5 秒更新一次:

$ test_compression giggidy/compress
Testing [giggidy/compress]

Testing size [4096]
Waited 0 seconds for [compressratio_is_one]
4096 bytes made up of 1*4096 blocks
Waited 4 seconds for [compresstario_is_not_one]
1.21x

Testing size [16384]
Waited 5 seconds for [compressratio_is_one]
16384 bytes made up of 1*16384 blocks
Waited 5 seconds for [compresstario_is_not_one]
1.91x

Testing size [1048576]
Waited 5 seconds for [compressratio_is_one]
1048576 bytes made up of 1*131072 blocks
Waited 5 seconds for [compresstario_is_not_one]
39.33x

Testing size [33161216]
Waited 5 seconds for [compressratio_is_one]
33161216 bytes made up of 1*131072 blocks
Waited 4 seconds for [compresstario_is_not_one]
114.25x

当我可以得到一个盒子时,我将添加一个基于 Solaris 的示例。

相关内容