Skip to contentSkip to conversation

Why does f2fs not reduce disk space when compression is on?

f2fs-dev Fengnan Chang 2 participants 3 messages Apr 12, 2021 – Apr 13, 2021

lore
Share & tools
lore
#0 lore raw

I'm testing the f2fs data compression feature. I created a new FS with the flags extra_attr and compression, use chattr -R +c on the test dir to enable compression for the directory.
I found that when compression was turned on, the files did not take up any less space. Using trace, I see that the data is indeed compressed.
Is there a mistake in my testing method, or is this how it was designed and why?

This is my test method:

# mount
/dev/nvme0n1 on /mnt type f2fs (rw,lazytime,relatime,background_gc=on,discard,no_heap,user_xattr,inline_xattr,acl,inline_data,inline_dentry,flush_merge,extent_cache,mode=adaptive,active_logs=6,alloc_mode=reuse,fsync_mode=posix,compress_algorithm=lz4,compress_log_size=2)
# df 
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root               114901    112444         0 100% /
devtmpfs                497436         0    497436   0% /dev
tmpfs                   500060         0    500060   0% /dev/shm
tmpfs                   500060        52    500008   0% /tmp
tmpfs                   500060        20    500040   0% /run
/dev/nvme0n1          10483712    499724   9983988   5% /mnt
# mkdir test
# chattr -R +c test/
# dd if=/dev/zero of=/mnt/test/file bs=1M count=100
# sync
# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root               114901    112444         0 100% /
devtmpfs                497436         0    497436   0% /dev
tmpfs                   500060         0    500060   0% /dev/shm
tmpfs                   500060       368    499692   0% /tmp
tmpfs                   500060        20    500040   0% /run
/dev/nvme0n1          10483712    602232   9881480   6% /mnt

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#1 lore raw
Quoted 5 lines · Fengnan Chang

I'm testing the f2fs data compression feature. I created a new FS with the flags extra_attr and compression, use chattr -R +c on the test dir to enable compression for the directory.
I found that when compression was turned on, the files did not take up any less space. Using trace, I see that the data is indeed compressed.
Is there a mistake in my testing method, or is this how it was designed and why?

https://lore.kernel.org/lkml/[email protected]/

I guess we should document it well in f2fs.rst to avoid any confusion, let me post a patch for that soon.

Thanks,

Quoted 27 lines

This is my test method:

# mount
/dev/nvme0n1 on /mnt type f2fs (rw,lazytime,relatime,background_gc=on,discard,no_heap,user_xattr,inline_xattr,acl,inline_data,inline_dentry,flush_merge,extent_cache,mode=adaptive,active_logs=6,alloc_mode=reuse,fsync_mode=posix,compress_algorithm=lz4,compress_log_size=2)
# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root               114901    112444         0 100% /
devtmpfs                497436         0    497436   0% /dev
tmpfs                   500060         0    500060   0% /dev/shm
tmpfs                   500060        52    500008   0% /tmp
tmpfs                   500060        20    500040   0% /run
/dev/nvme0n1          10483712    499724   9983988   5% /mnt
# mkdir test
# chattr -R +c test/
# dd if=/dev/zero of=/mnt/test/file bs=1M count=100
# sync
# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root               114901    112444         0 100% /
devtmpfs                497436         0    497436   0% /dev
tmpfs                   500060         0    500060   0% /dev/shm
tmpfs                   500060       368    499692   0% /tmp
tmpfs                   500060        20    500040   0% /run
/dev/nvme0n1          10483712    602232   9881480   6% /mnt
Quoted 6 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#2 lore raw

Thanks, I got it.

-----邮件原件-----
发件人: Chao Yu <[email protected]>
发送时间: 2021年4月13日 9:16
收件人: Fengnan Chang <[email protected]>
抄送: [email protected]; [email protected]; [email protected]
主题: Re: [f2fs-dev] [f2fs-devel] Why does f2fs not reduce disk space when compression is on?

Quoted 2 lines · Fengnan Chang

I'm testing the f2fs data compression feature. I created a new FS with the flags extra_attr and compression, use chattr -R +c on the test dir

to enable compression for the directory.

Quoted 1 line

I found that when compression was turned on, the files did not take up

any less space.

Quoted 2 lines

Using trace, I see that the data is indeed compressed.
Is there a mistake in my testing method, or is this how it was designed

and why?

https://lore.kernel.org/lkml/[email protected]/

I guess we should document it well in f2fs.rst to avoid any confusion, let me post a patch for that soon.

Thanks,

Quoted 29 lines

This is my test method:

# mount
/dev/nvme0n1 on /mnt type f2fs
(rw,lazytime,relatime,background_gc=on,discard,no_heap,user_xattr,inli
ne_xattr,acl,inline_data,inline_dentry,flush_merge,extent_cache,mode=a
daptive,active_logs=6,alloc_mode=reuse,fsync_mode=posix,compress_algor
ithm=lz4,compress_log_size=2)
# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root               114901    112444         0 100% /
devtmpfs                497436         0    497436   0% /dev
tmpfs                   500060         0    500060   0% /dev/shm
tmpfs                   500060        52    500008   0% /tmp
tmpfs                   500060        20    500040   0% /run
/dev/nvme0n1          10483712    499724   9983988   5% /mnt
# mkdir test
# chattr -R +c test/
# dd if=/dev/zero of=/mnt/test/file bs=1M count=100 # sync # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root               114901    112444         0 100% /
devtmpfs                497436         0    497436   0% /dev
tmpfs                   500060         0    500060   0% /dev/shm
tmpfs                   500060       368    499692   0% /tmp
tmpfs                   500060        20    500040   0% /run
/dev/nvme0n1          10483712    602232   9881480   6% /mnt
Quoted 6 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel