为什么我的btrfs / dm-crypt RAID1设置太慢?

我有一个基于btrfs的四磁盘RAID1arrays的系统。 两个磁盘是1TB传统硬盘,另外两个是128GB固态硬盘。 每个磁盘的大部分都装满了一个LUKS容器。 在所有的四个LUKS容器里面,我有一个用于RAID1的btrfs文件系统。

上面的configuration应该会有相当不错的performance,但不幸的是,它超慢。 以下是一些基准testing,通常在同一时间运行:

% dd if=/dev/zero of=tmpfile bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 1.18302 s, 908 MB/s % dd if=/dev/zero of=tmpfile bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 1.66737 s, 644 MB/s % dd if=tmpfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 1.61369 s, 665 MB/s % echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null % dd if=tmpfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 8.05449 s, 133 MB/s % echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null % dd if=/dev/zero of=tmpfile bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 2.66874 s, 402 MB/s % echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null % dd if=tmpfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 5.164 s, 208 MB/s 

不知道该怎么做,但磁盘当然看起来很慢。 一般来说,当我看着iotop ,我看到写入吞吐量为5-10 MB / s左右。 不太好。

这里有一些更多的信息:

 % cryptsetup benchmark # Tests are approximate using memory only (no storage IO). PBKDF2-sha1 834853 iterations per second PBKDF2-sha256 548418 iterations per second PBKDF2-sha512 366122 iterations per second PBKDF2-ripemd160 508031 iterations per second PBKDF2-whirlpool 175229 iterations per second # Algorithm | Key | Encryption | Decryption aes-cbc 128b 379.4 MiB/s 1552.0 MiB/s serpent-cbc 128b 49.3 MiB/s 216.5 MiB/s twofish-cbc 128b 129.3 MiB/s 258.3 MiB/s aes-cbc 256b 325.3 MiB/s 1158.4 MiB/s serpent-cbc 256b 65.0 MiB/s 213.1 MiB/s twofish-cbc 256b 136.3 MiB/s 259.8 MiB/s aes-xts 256b 1326.8 MiB/s 1333.5 MiB/s serpent-xts 256b 224.4 MiB/s 216.7 MiB/s twofish-xts 256b 255.5 MiB/s 257.2 MiB/s aes-xts 512b 1034.8 MiB/s 1009.7 MiB/s serpent-xts 512b 225.8 MiB/s 214.1 MiB/s twofish-xts 512b 255.1 MiB/s 257.1 MiB/s % lsmod | grep aes aesni_intel 167936 18 aes_x86_64 20480 1 aesni_intel lrw 16384 5 serpent_sse2_x86_64,aesni_intel,serpent_avx_x86_64,twofish_avx_x86_64,twofish_x86_64_3way glue_helper 16384 5 serpent_sse2_x86_64,aesni_intel,serpent_avx_x86_64,twofish_avx_x86_64,twofish_x86_64_3way ablk_helper 16384 4 serpent_sse2_x86_64,aesni_intel,serpent_avx_x86_64,twofish_avx_x86_64 cryptd 20480 9 ghash_clmulni_intel,aesni_intel,ablk_helper % uname -a Linux steevie 4.7.0-0.bpo.1-amd64 #1 SMP Debian 4.7.5-1~bpo8+1 (2016-09-30) x86_64 GNU/Linux 

正如你所看到的,我在Debian 8上运行一个来自jessie-backports的内核。

此外,在https://askubuntu.com/questions/246102/slow-ssd-dm-crypt-with-luks-encryption-in-ubuntu-12-10的build议,我有initramfs加载cryptdaes_x86_64 ,和aesni_intel模块在早期启动。 然而,重新启动和基准再次给了几乎完全相同的速度。

任何想法,可怕的performance可能来自哪里?