Skip to content

Commit 86d563a

Browse files
committed
Merge tag 'f2fs-for-6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs updates from Jaegeuk Kim: "This focuses on two primary updates for Android devices. First, it sets hash-based file name lookup as the default method to improve performance, while retaining an option to fall back to a linear lookup. Second, it resolves a persistent issue with the 'checkpoint=enable' feature. The update further boosts performance by prefetching node blocks, merging FUA writes more efficiently, and optimizing block allocation policies. The release is rounded out by a comprehensive set of bug fixes that address memory safety, data integrity, and potential system hangs, along with minor documentation and code clean-ups. Enhancements: - add mount option and sysfs entry to tune the lookup mode - dump more information and add a timeout when enabling/disabling checkpoints - readahead node blocks in F2FS_GET_BLOCK_PRECACHE mode - merge FUA command with the existing writes - allocate HOT_DATA for IPU writes - Use allocate_section_policy to control write priority in multi-devices setups - add reserved nodes for privileged users - Add bggc_io_aware to adjust the priority of BG_GC when issuing IO - show the list of donation files Bug fixes: - add missing dput() when printing the donation list - fix UAF issue in f2fs_merge_page_bio() - add sanity check on ei.len in __update_extent_tree_range() - fix infinite loop in __insert_extent_tree() - fix zero-sized extent for precache extents - fix to mitigate overhead of f2fs_zero_post_eof_page() - fix to avoid migrating empty section - fix to truncate first page in error path of f2fs_truncate() - fix to update map->m_next_extent correctly in f2fs_map_blocks() - fix wrong layout information on 16KB page - fix to do sanity check on node footer for non inode dnode - fix to avoid NULL pointer dereference in f2fs_check_quota_consistency() - fix to detect potential corrupted nid in free_nid_list - fix to clear unusable_cap for checkpoint=enable - fix to zero data after EOF for compressed file correctly - fix to avoid overflow while left shift operation - fix condition in __allow_reserved_blocks()" * tag 'f2fs-for-6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (43 commits) f2fs: add missing dput() when printing the donation list f2fs: fix UAF issue in f2fs_merge_page_bio() f2fs: readahead node blocks in F2FS_GET_BLOCK_PRECACHE mode f2fs: add sanity check on ei.len in __update_extent_tree_range() f2fs: fix infinite loop in __insert_extent_tree() f2fs: fix zero-sized extent for precache extents f2fs: fix to mitigate overhead of f2fs_zero_post_eof_page() f2fs: fix to avoid migrating empty section f2fs: fix to truncate first page in error path of f2fs_truncate() f2fs: fix to update map->m_next_extent correctly in f2fs_map_blocks() f2fs: fix wrong layout information on 16KB page f2fs: clean up error handing of f2fs_submit_page_read() f2fs: avoid unnecessary folio_clear_uptodate() for cleanup f2fs: merge FUA command with the existing writes f2fs: allocate HOT_DATA for IPU writes f2fs: Use allocate_section_policy to control write priority in multi-devices setups Documentation: f2fs: Reword title Documentation: f2fs: Indent compression_mode option list Documentation: f2fs: Wrap snippets in literal code blocks Documentation: f2fs: Span write hint table section rows ...
2 parents f0712c2 + 4e71574 commit 86d563a

File tree

18 files changed

+702
-204
lines changed

18 files changed

+702
-204
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,8 @@ What: /sys/fs/f2fs/<disk>/gc_valid_thresh_ratio
822822
Date: September 2024
823823
Contact: "Daeho Jeong" <[email protected]>
824824
Description: It controls the valid block ratio threshold not to trigger excessive GC
825-
for zoned deivces. The initial value of it is 95(%). F2FS will stop the
826-
background GC thread from intiating GC for sections having valid blocks
825+
for zoned devices. The initial value of it is 95(%). F2FS will stop the
826+
background GC thread from initiating GC for sections having valid blocks
827827
exceeding the ratio.
828828

829829
What: /sys/fs/f2fs/<disk>/max_read_extent_count
@@ -847,7 +847,7 @@ Description: For several zoned storage devices, vendors will provide extra space
847847
filesystem level GC. To do that, we can reserve the space using
848848
reserved_blocks. However, it is not enough, since this extra space should
849849
not be shown to users. So, with this new sysfs node, we can hide the space
850-
by substracting reserved_blocks from total bytes.
850+
by subtracting reserved_blocks from total bytes.
851851

852852
What: /sys/fs/f2fs/<disk>/encoding_flags
853853
Date: April 2025
@@ -883,3 +883,53 @@ Date: June 2025
883883
Contact: "Daeho Jeong" <[email protected]>
884884
Description: Control GC algorithm for boost GC. 0: cost benefit, 1: greedy
885885
Default: 1
886+
887+
What: /sys/fs/f2fs/<disk>/effective_lookup_mode
888+
Date: August 2025
889+
Contact: "Daniel Lee" <[email protected]>
890+
Description:
891+
This is a read-only entry to show the effective directory lookup mode
892+
F2FS is currently using for casefolded directories.
893+
This considers both the "lookup_mode" mount option and the on-disk
894+
encoding flag, SB_ENC_NO_COMPAT_FALLBACK_FL.
895+
896+
Possible values are:
897+
- "perf": Hash-only lookup.
898+
- "compat": Hash-based lookup with a linear search fallback enabled
899+
- "auto:perf": lookup_mode is auto and fallback is disabled on-disk
900+
- "auto:compat": lookup_mode is auto and fallback is enabled on-disk
901+
902+
What: /sys/fs/f2fs/<disk>/bggc_io_aware
903+
Date: August 2025
904+
Contact: "Liao Yuanhong" <[email protected]>
905+
Description: Used to adjust the BG_GC priority when pending IO, with a default value
906+
of 0. Specifically, for ZUFS, the default value is 1.
907+
908+
================== ======================================================
909+
value description
910+
bggc_io_aware = 0 skip background GC if there is any kind of pending IO
911+
bggc_io_aware = 1 skip background GC if there is pending read IO
912+
bggc_io_aware = 2 don't aware IO for background GC
913+
================== ======================================================
914+
915+
What: /sys/fs/f2fs/<disk>/allocate_section_hint
916+
Date: August 2025
917+
Contact: "Liao Yuanhong" <[email protected]>
918+
Description: Indicates the hint section between the first device and others in multi-devices
919+
setup. It defaults to the end of the first device in sections. For a single storage
920+
device, it defaults to the total number of sections. It can be manually set to match
921+
scenarios where multi-devices are mapped to the same dm device.
922+
923+
What: /sys/fs/f2fs/<disk>/allocate_section_policy
924+
Date: August 2025
925+
Contact: "Liao Yuanhong" <[email protected]>
926+
Description: Controls write priority in multi-devices setups. A value of 0 means normal writing.
927+
A value of 1 prioritizes writing to devices before the allocate_section_hint. A value of 2
928+
prioritizes writing to devices after the allocate_section_hint. The default is 0.
929+
930+
=========================== ==========================================================
931+
value description
932+
allocate_section_policy = 0 Normal writing
933+
allocate_section_policy = 1 Prioritize writing to section before allocate_section_hint
934+
allocate_section_policy = 2 Prioritize writing to section after allocate_section_hint
935+
=========================== ==========================================================

Documentation/filesystems/f2fs.rst

Lines changed: 78 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
.. SPDX-License-Identifier: GPL-2.0
22
3-
==========================================
4-
WHAT IS Flash-Friendly File System (F2FS)?
5-
==========================================
3+
=================================
4+
Flash-Friendly File System (F2FS)
5+
=================================
6+
7+
Overview
8+
========
69

710
NAND flash memory-based storage devices, such as SSD, eMMC, and SD cards, have
811
been equipped on a variety systems ranging from mobile to server systems. Since
@@ -173,9 +176,12 @@ data_flush Enable data flushing before checkpoint in order to
173176
persist data of regular and symlink.
174177
reserve_root=%d Support configuring reserved space which is used for
175178
allocation from a privileged user with specified uid or
176-
gid, unit: 4KB, the default limit is 0.2% of user blocks.
177-
resuid=%d The user ID which may use the reserved blocks.
178-
resgid=%d The group ID which may use the reserved blocks.
179+
gid, unit: 4KB, the default limit is 12.5% of user blocks.
180+
reserve_node=%d Support configuring reserved nodes which are used for
181+
allocation from a privileged user with specified uid or
182+
gid, the default limit is 12.5% of all nodes.
183+
resuid=%d The user ID which may use the reserved blocks and nodes.
184+
resgid=%d The group ID which may use the reserved blocks and nodes.
179185
fault_injection=%d Enable fault injection in all supported types with
180186
specified injection rate.
181187
fault_type=%d Support configuring fault injection type, should be
@@ -291,9 +297,13 @@ compress_algorithm=%s Control compress algorithm, currently f2fs supports "lzo"
291297
"lz4", "zstd" and "lzo-rle" algorithm.
292298
compress_algorithm=%s:%d Control compress algorithm and its compress level, now, only
293299
"lz4" and "zstd" support compress level config.
300+
301+
========= ===========
294302
algorithm level range
303+
========= ===========
295304
lz4 3 - 16
296305
zstd 1 - 22
306+
========= ===========
297307
compress_log_size=%u Support configuring compress cluster size. The size will
298308
be 4KB * (1 << %u). The default and minimum sizes are 16KB.
299309
compress_extension=%s Support adding specified extension, so that f2fs can enable
@@ -357,6 +367,7 @@ errors=%s Specify f2fs behavior on critical errors. This supports modes:
357367
panic immediately, continue without doing anything, and remount
358368
the partition in read-only mode. By default it uses "continue"
359369
mode.
370+
360371
====================== =============== =============== ========
361372
mode continue remount-ro panic
362373
====================== =============== =============== ========
@@ -370,6 +381,25 @@ errors=%s Specify f2fs behavior on critical errors. This supports modes:
370381
====================== =============== =============== ========
371382
nat_bits Enable nat_bits feature to enhance full/empty nat blocks access,
372383
by default it's disabled.
384+
lookup_mode=%s Control the directory lookup behavior for casefolded
385+
directories. This option has no effect on directories
386+
that do not have the casefold feature enabled.
387+
388+
================== ========================================
389+
Value Description
390+
================== ========================================
391+
perf (Default) Enforces a hash-only lookup.
392+
The linear search fallback is always
393+
disabled, ignoring the on-disk flag.
394+
compat Enables the linear search fallback for
395+
compatibility with directory entries
396+
created by older kernel that used a
397+
different case-folding algorithm.
398+
This mode ignores the on-disk flag.
399+
auto F2FS determines the mode based on the
400+
on-disk `SB_ENC_NO_COMPAT_FALLBACK_FL`
401+
flag.
402+
================== ========================================
373403
======================== ============================================================
374404

375405
Debugfs Entries
@@ -795,11 +825,13 @@ ioctl(COLD) COLD_DATA WRITE_LIFE_EXTREME
795825
extension list " "
796826

797827
-- buffered io
828+
------------------------------------------------------------------
798829
N/A COLD_DATA WRITE_LIFE_EXTREME
799830
N/A HOT_DATA WRITE_LIFE_SHORT
800831
N/A WARM_DATA WRITE_LIFE_NOT_SET
801832

802833
-- direct io
834+
------------------------------------------------------------------
803835
WRITE_LIFE_EXTREME COLD_DATA WRITE_LIFE_EXTREME
804836
WRITE_LIFE_SHORT HOT_DATA WRITE_LIFE_SHORT
805837
WRITE_LIFE_NOT_SET WARM_DATA WRITE_LIFE_NOT_SET
@@ -915,24 +947,26 @@ compression enabled files (refer to "Compression implementation" section for how
915947
enable compression on a regular inode).
916948

917949
1) compress_mode=fs
918-
This is the default option. f2fs does automatic compression in the writeback of the
919-
compression enabled files.
950+
951+
This is the default option. f2fs does automatic compression in the writeback of the
952+
compression enabled files.
920953

921954
2) compress_mode=user
922-
This disables the automatic compression and gives the user discretion of choosing the
923-
target file and the timing. The user can do manual compression/decompression on the
924-
compression enabled files using F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE
925-
ioctls like the below.
926955

927-
To decompress a file,
956+
This disables the automatic compression and gives the user discretion of choosing the
957+
target file and the timing. The user can do manual compression/decompression on the
958+
compression enabled files using F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE
959+
ioctls like the below.
960+
961+
To decompress a file::
928962

929-
fd = open(filename, O_WRONLY, 0);
930-
ret = ioctl(fd, F2FS_IOC_DECOMPRESS_FILE);
963+
fd = open(filename, O_WRONLY, 0);
964+
ret = ioctl(fd, F2FS_IOC_DECOMPRESS_FILE);
931965

932-
To compress a file,
966+
To compress a file::
933967

934-
fd = open(filename, O_WRONLY, 0);
935-
ret = ioctl(fd, F2FS_IOC_COMPRESS_FILE);
968+
fd = open(filename, O_WRONLY, 0);
969+
ret = ioctl(fd, F2FS_IOC_COMPRESS_FILE);
936970

937971
NVMe Zoned Namespace devices
938972
----------------------------
@@ -962,32 +996,32 @@ reserved and used by another filesystem or for different purposes. Once that
962996
external usage is complete, the device aliasing file can be deleted, releasing
963997
the reserved space back to F2FS for its own use.
964998

965-
<use-case>
966-
967-
# ls /dev/vd*
968-
/dev/vdb (32GB) /dev/vdc (32GB)
969-
# mkfs.ext4 /dev/vdc
970-
# mkfs.f2fs -c /dev/[email protected] /dev/vdb
971-
# mount /dev/vdb /mnt/f2fs
972-
# ls -l /mnt/f2fs
973-
vdc.file
974-
# df -h
975-
/dev/vdb 64G 33G 32G 52% /mnt/f2fs
976-
977-
# mount -o loop /dev/vdc /mnt/ext4
978-
# df -h
979-
/dev/vdb 64G 33G 32G 52% /mnt/f2fs
980-
/dev/loop7 32G 24K 30G 1% /mnt/ext4
981-
# umount /mnt/ext4
982-
983-
# f2fs_io getflags /mnt/f2fs/vdc.file
984-
get a flag on /mnt/f2fs/vdc.file ret=0, flags=nocow(pinned),immutable
985-
# f2fs_io setflags noimmutable /mnt/f2fs/vdc.file
986-
get a flag on noimmutable ret=0, flags=800010
987-
set a flag on /mnt/f2fs/vdc.file ret=0, flags=noimmutable
988-
# rm /mnt/f2fs/vdc.file
989-
# df -h
990-
/dev/vdb 64G 753M 64G 2% /mnt/f2fs
999+
.. code-block::
1000+
1001+
# ls /dev/vd*
1002+
/dev/vdb (32GB) /dev/vdc (32GB)
1003+
# mkfs.ext4 /dev/vdc
1004+
# mkfs.f2fs -c /dev/[email protected] /dev/vdb
1005+
# mount /dev/vdb /mnt/f2fs
1006+
# ls -l /mnt/f2fs
1007+
vdc.file
1008+
# df -h
1009+
/dev/vdb 64G 33G 32G 52% /mnt/f2fs
1010+
1011+
# mount -o loop /dev/vdc /mnt/ext4
1012+
# df -h
1013+
/dev/vdb 64G 33G 32G 52% /mnt/f2fs
1014+
/dev/loop7 32G 24K 30G 1% /mnt/ext4
1015+
# umount /mnt/ext4
1016+
1017+
# f2fs_io getflags /mnt/f2fs/vdc.file
1018+
get a flag on /mnt/f2fs/vdc.file ret=0, flags=nocow(pinned),immutable
1019+
# f2fs_io setflags noimmutable /mnt/f2fs/vdc.file
1020+
get a flag on noimmutable ret=0, flags=800010
1021+
set a flag on /mnt/f2fs/vdc.file ret=0, flags=noimmutable
1022+
# rm /mnt/f2fs/vdc.file
1023+
# df -h
1024+
/dev/vdb 64G 753M 64G 2% /mnt/f2fs
9911025
9921026
So, the key idea is, user can do any file operations on /dev/vdc, and
9931027
reclaim the space after the use, while the space is counted as /data.

0 commit comments

Comments
 (0)