我使用加密文件系统时遇到速度缓慢的问题。详情如下:
# /dev/sdd: TOSHIBA PX05SVQ192B AX02 /dev/sdd
# gdisk -l /dev/sdd
GPT fdisk (gdisk) version 0.7.1
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Disk /dev/sdd: 3750748848 sectors, 1.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 51E5679B-EFA3-446F-8D55-8FAC33EB8322
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 3750748814
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 3750748814 1.7 TiB FD00 Linux RAID
我这样设置加密:
cryptsetup -y create -c aes-cbc-plain -s 256 -h ripemd160 data_crypt /dev/sdd1
以下是使用 hdparm 的测试结果(在实际负载下也会感觉到速度缓慢):
# hdparm -t /dev/sdd1 /dev/mapper/data_crypt
/dev/sdd1:
Timing buffered disk reads: 2362 MB in 3.00 seconds = 787.18 MB/sec
/dev/mapper/data_crypt:
Timing buffered disk reads: 1458 MB in 3.00 seconds = 485.34 MB/sec
我正在运行内核 3.18.7。
CPU(2)是:
model name : Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz
我知道加密可能会使速度变慢,但这比我预期的要大。我使用过 cryptsetup 很多次,没有遇到过这种问题。
有人能提供关于如何解决此问题的建议吗?
编辑:我也尝试通过 RAM 中的环回设备做同样的事情:
[root@testsedbd tmp]# hdparm -t /dev/loop0 /dev/mapper/ram_crypt
/dev/loop0:
Timing buffered disk reads: 4094 MB in 2.16 seconds = 1892.83 MB/sec
/dev/mapper/ram_crypt:
Timing buffered disk reads: 1606 MB in 3.00 seconds = 534.89 MB/sec