"btrfs filesystem defrag -c"(압축 옵션)는 압축을 강제합니까?

"btrfs filesystem defrag -c"(압축 옵션)는 압축을 강제합니까?

압축이 활성화된 BTRFS는 경험적 방법을 사용하여 압축하기 어려운 파일을 압축하지 않습니다. "btrfs filesystem defrag -c"를 사용하여 기존 파일을 압축하면 휴리스틱도 사용됩니까, 아니면 압축이 잘 안되는 경우에도 모든 파일을 압축합니까?

답변1

btrfs filesystem defrag -c압축을 강제하는 것으로 보이며, 초기 압축 시도가 성과가 없고 파일 시스템이 compress-force.

이를 증명하기 위해 처음 1M의 비압축 데이터와 그 뒤를 이어 128K의 압축 가능한 데이터(예: 텍스트 파일)를 포함하는 파일을 만들었습니다. 파일은 /tmp다양한 옵션을 사용하여 btrfs 마운트 지점에 저장되고 복사되었습니다.

# compress=lzo: no actual compression
root@debian12:~# mount /dev/zvol/tank/vol1 /mnt/ -o compress=lzo
root@debian12:~# cp /tmp/random.img /mnt/
root@debian12:~# sync
root@debian12:~# compsize /mnt/random.img
Processed 1 file, 1 regular extents (1 refs), 0 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL      100%      1.1M         1.1M         1.1M
none       100%      1.1M         1.1M         1.1M

# compress=lzo + defrag: compressed, but 'm' (incompressible) flag set
root@debian12:~# btrfs filesystem defrag -c -r /mnt/
root@debian12:~# sync
root@debian12:~# compsize /mnt/random.img
Processed 1 file, 3 regular extents (3 refs), 0 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL       90%      1.0M         1.1M         1.1M
none       100%      1.0M         1.0M         1.0M
zlib        15%       20K         128K         128K
root@debian12:~# lsattr /mnt/random.img
---------------------m /mnt/random.img

# compress-force=lzo: some limited compression 
root@debian12:~# mount /dev/zvol/tank/vol1 /mnt/ -o compress-force=lzo
root@debian12:~# cp /tmp/random.img /mnt/
root@debian12:~# sync
root@debian12:~# compsize /mnt/random.img
Processed 1 file, 3 regular extents (3 refs), 0 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL       96%      1.0M         1.1M         1.1M
none       100%      1.0M         1.0M         1.0M
lzo         68%       88K         128K         128K

# compress-force=lzo + defrag: better compression and no 'm' flag
root@debian12:~# compsize /mnt/random.img
Processed 1 file, 3 regular extents (3 refs), 0 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL       90%      1.0M         1.1M         1.1M
none       100%      1.0M         1.0M         1.0M
zlib        15%       20K         128K         128K
root@debian12:~# lsattr /mnt/random.img
---------------------- /mnt/random.img

관련 정보