Skip to content

Commit 041fae9

Browse files
committed
Merge tag 'f2fs-for-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs updates from Jaegeuk Kim: "In this round, we've added two features: F2FS_IOC_START_ATOMIC_REPLACE and a per-block age-based extent cache. F2FS_IOC_START_ATOMIC_REPLACE is a variant of the previous atomic write feature which guarantees a per-file atomicity. It would be more efficient than AtomicFile implementation in Android framework. The per-block age-based extent cache implements another type of extent cache in memory which keeps the per-block age in a file, so that block allocator could split the hot and cold data blocks more accurately. Enhancements: - introduce F2FS_IOC_START_ATOMIC_REPLACE - refactor extent_cache to add a new per-block-age-based extent cache support - introduce discard_urgent_util, gc_mode, max_ordered_discard sysfs knobs - add proc entry to show discard_plist info - optimize iteration over sparse directories - add barrier mount option Bug fixes: - avoid victim selection from previous victim section - fix to enable compress for newly created file if extension matches - set zstd compress level correctly - initialize locks early in f2fs_fill_super() to fix bugs reported by syzbot - correct i_size change for atomic writes - allow to read node block after shutdown - allow to set compression for inlined file - fix gc mode when gc_urgent_high_remaining is 1 - should put a page when checking the summary info Minor fixes and various clean-ups in GC, discard, debugfs, sysfs, and doc" * tag 'f2fs-for-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (63 commits) f2fs: reset wait_ms to default if any of the victims have been selected f2fs: fix some format WARNING in debug.c and sysfs.c f2fs: don't call f2fs_issue_discard_timeout() when discard_cmd_cnt is 0 in f2fs_put_super() f2fs: fix iostat parameter for discard f2fs: Fix spelling mistake in label: free_bio_enrty_cache -> free_bio_entry_cache f2fs: add block_age-based extent cache f2fs: allocate the extent_cache by default f2fs: refactor extent_cache to support for read and more f2fs: remove unnecessary __init_extent_tree f2fs: move internal functions into extent_cache.c f2fs: specify extent cache for read explicitly f2fs: introduce f2fs_is_readonly() for readability f2fs: remove F2FS_SET_FEATURE() and F2FS_CLEAR_FEATURE() macro f2fs: do some cleanup for f2fs module init MAINTAINERS: Add f2fs bug tracker link f2fs: remove the unused flush argument to change_curseg f2fs: open code allocate_segment_by_default f2fs: remove struct segment_allocation default_salloc_ops f2fs: introduce discard_urgent_util sysfs node f2fs: define MIN_DISCARD_GRANULARITY macro ...
2 parents eb67d23 + 26a8057 commit 041fae9

File tree

24 files changed

+1643
-928
lines changed

24 files changed

+1643
-928
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ Description: Controls the issue rate of discard commands that consist of small
9999
checkpoint is triggered, and issued during the checkpoint.
100100
By default, it is disabled with 0.
101101

102+
What: /sys/fs/f2fs/<disk>/max_ordered_discard
103+
Date: October 2022
104+
Contact: "Yangtao Li" <[email protected]>
105+
Description: Controls the maximum ordered discard, the unit size is one block(4KB).
106+
Set it to 16 by default.
107+
102108
What: /sys/fs/f2fs/<disk>/max_discard_request
103109
Date: December 2021
104110
Contact: "Konstantin Vyshetsky" <[email protected]>
@@ -132,7 +138,8 @@ Contact: "Chao Yu" <[email protected]>
132138
Description: Controls discard granularity of inner discard thread. Inner thread
133139
will not issue discards with size that is smaller than granularity.
134140
The unit size is one block(4KB), now only support configuring
135-
in range of [1, 512]. Default value is 4(=16KB).
141+
in range of [1, 512]. Default value is 16.
142+
For small devices, default value is 1.
136143

137144
What: /sys/fs/f2fs/<disk>/umount_discard_timeout
138145
Date: January 2019
@@ -235,7 +242,7 @@ Description: Shows total written kbytes issued to disk.
235242
What: /sys/fs/f2fs/<disk>/features
236243
Date: July 2017
237244
Contact: "Jaegeuk Kim" <[email protected]>
238-
Description: <deprecated: should use /sys/fs/f2fs/<disk>/feature_list/
245+
Description: <deprecated: should use /sys/fs/f2fs/<disk>/feature_list/>
239246
Shows all enabled features in current device.
240247
Supported features:
241248
encryption, blkzoned, extra_attr, projquota, inode_checksum,
@@ -592,10 +599,10 @@ Description: With "mode=fragment:block" mount options, we can scatter block allo
592599
in the length of 1..<max_fragment_hole> by turns. This value can be set
593600
between 1..512 and the default value is 4.
594601

595-
What: /sys/fs/f2fs/<disk>/gc_urgent_high_remaining
596-
Date: December 2021
597-
Contact: "Daeho Jeong" <daehojeong@google.com>
598-
Description: You can set the trial count limit for GC urgent high mode with this value.
602+
What: /sys/fs/f2fs/<disk>/gc_remaining_trials
603+
Date: October 2022
604+
Contact: "Yangtao Li" <frank.li@vivo.com>
605+
Description: You can set the trial count limit for GC urgent and idle mode with this value.
599606
If GC thread gets to the limit, the mode will turn back to GC normal mode.
600607
By default, the value is zero, which means there is no limit like before.
601608

@@ -634,3 +641,31 @@ Date: July 2022
634641
Contact: "Daeho Jeong" <[email protected]>
635642
Description: Show the accumulated total revoked atomic write block count after boot.
636643
If you write "0" here, you can initialize to "0".
644+
645+
What: /sys/fs/f2fs/<disk>/gc_mode
646+
Date: October 2022
647+
Contact: "Yangtao Li" <[email protected]>
648+
Description: Show the current gc_mode as a string.
649+
This is a read-only entry.
650+
651+
What: /sys/fs/f2fs/<disk>/discard_urgent_util
652+
Date: November 2022
653+
Contact: "Yangtao Li" <[email protected]>
654+
Description: When space utilization exceeds this, do background DISCARD aggressively.
655+
Does DISCARD forcibly in a period of given min_discard_issue_time when the number
656+
of discards is not 0 and set discard granularity to 1.
657+
Default: 80
658+
659+
What: /sys/fs/f2fs/<disk>/hot_data_age_threshold
660+
Date: November 2022
661+
Contact: "Ping Xiong" <[email protected]>
662+
Description: When DATA SEPARATION is on, it controls the age threshold to indicate
663+
the data blocks as hot. By default it was initialized as 262144 blocks
664+
(equals to 1GB).
665+
666+
What: /sys/fs/f2fs/<disk>/warm_data_age_threshold
667+
Date: November 2022
668+
Contact: "Ping Xiong" <[email protected]>
669+
Description: When DATA SEPARATION is on, it controls the age threshold to indicate
670+
the data blocks as warm. By default it was initialized as 2621440 blocks
671+
(equals to 10GB).

Documentation/filesystems/f2fs.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ a consistency checking tool (fsck.f2fs), and a debugging tool (dump.f2fs).
2525

2626
- git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git
2727

28-
For reporting bugs and sending patches, please use the following mailing list:
28+
For sending patches, please use the following mailing list:
2929

3030
3131

32+
For reporting bugs, please use the following f2fs bug tracker link:
33+
34+
- https://bugzilla.kernel.org/enter_bug.cgi?product=File%20System&component=f2fs
35+
3236
Background and Design issues
3337
============================
3438

@@ -154,6 +158,8 @@ nobarrier This option can be used if underlying storage guarantees
154158
If this option is set, no cache_flush commands are issued
155159
but f2fs still guarantees the write ordering of all the
156160
data writes.
161+
barrier If this option is set, cache_flush commands are allowed to be
162+
issued.
157163
fastboot This option is used when a system wants to reduce mount
158164
time as much as possible, even though normal performance
159165
can be sacrificed.
@@ -199,6 +205,7 @@ fault_type=%d Support configuring fault injection type, should be
199205
FAULT_SLAB_ALLOC 0x000008000
200206
FAULT_DQUOT_INIT 0x000010000
201207
FAULT_LOCK_OP 0x000020000
208+
FAULT_BLKADDR 0x000040000
202209
=================== ===========
203210
mode=%s Control block allocation mode which supports "adaptive"
204211
and "lfs". In "lfs" mode, there should be no random
@@ -340,6 +347,10 @@ memory=%s Control memory mode. This supports "normal" and "low" modes.
340347
Because of the nature of low memory devices, in this mode, f2fs
341348
will try to save memory sometimes by sacrificing performance.
342349
"normal" mode is the default mode and same as before.
350+
age_extent_cache Enable an age extent cache based on rb-tree. It records
351+
data block update frequency of the extent per inode, in
352+
order to provide better temperature hints for data block
353+
allocation.
343354
======================== ============================================================
344355

345356
Debugfs Entries

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7889,6 +7889,7 @@ M: Chao Yu <[email protected]>
78897889
78907890
S: Maintained
78917891
W: https://f2fs.wiki.kernel.org/
7892+
B: https://bugzilla.kernel.org/enter_bug.cgi?product=File%20System&component=f2fs
78927893
T: git git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git
78937894
F: Documentation/ABI/testing/sysfs-fs-f2fs
78947895
F: Documentation/filesystems/f2fs.rst

fs/f2fs/checkpoint.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
171171
bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
172172
block_t blkaddr, int type)
173173
{
174+
if (time_to_inject(sbi, FAULT_BLKADDR)) {
175+
f2fs_show_injection_info(sbi, FAULT_BLKADDR);
176+
return false;
177+
}
178+
174179
switch (type) {
175180
case META_NAT:
176181
break;
@@ -1897,8 +1902,10 @@ int f2fs_start_ckpt_thread(struct f2fs_sb_info *sbi)
18971902
cprc->f2fs_issue_ckpt = kthread_run(issue_checkpoint_thread, sbi,
18981903
"f2fs_ckpt-%u:%u", MAJOR(dev), MINOR(dev));
18991904
if (IS_ERR(cprc->f2fs_issue_ckpt)) {
1905+
int err = PTR_ERR(cprc->f2fs_issue_ckpt);
1906+
19001907
cprc->f2fs_issue_ckpt = NULL;
1901-
return -ENOMEM;
1908+
return err;
19021909
}
19031910

19041911
set_task_ioprio(cprc->f2fs_issue_ckpt, cprc->ckpt_thread_ioprio);

fs/f2fs/compress.c

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ static int zstd_init_compress_ctx(struct compress_ctx *cc)
346346
if (!level)
347347
level = F2FS_ZSTD_DEFAULT_CLEVEL;
348348

349-
params = zstd_get_params(F2FS_ZSTD_DEFAULT_CLEVEL, cc->rlen);
349+
params = zstd_get_params(level, cc->rlen);
350350
workspace_size = zstd_cstream_workspace_bound(&params.cParams);
351351

352352
workspace = f2fs_kvmalloc(F2FS_I_SB(cc->inode),
@@ -567,10 +567,7 @@ MODULE_PARM_DESC(num_compress_pages,
567567
int f2fs_init_compress_mempool(void)
568568
{
569569
compress_page_pool = mempool_create_page_pool(num_compress_pages, 0);
570-
if (!compress_page_pool)
571-
return -ENOMEM;
572-
573-
return 0;
570+
return compress_page_pool ? 0 : -ENOMEM;
574571
}
575572

576573
void f2fs_destroy_compress_mempool(void)
@@ -1981,63 +1978,32 @@ int f2fs_init_page_array_cache(struct f2fs_sb_info *sbi)
19811978

19821979
sbi->page_array_slab = f2fs_kmem_cache_create(slab_name,
19831980
sbi->page_array_slab_size);
1984-
if (!sbi->page_array_slab)
1985-
return -ENOMEM;
1986-
return 0;
1981+
return sbi->page_array_slab ? 0 : -ENOMEM;
19871982
}
19881983

19891984
void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi)
19901985
{
19911986
kmem_cache_destroy(sbi->page_array_slab);
19921987
}
19931988

1994-
static int __init f2fs_init_cic_cache(void)
1989+
int __init f2fs_init_compress_cache(void)
19951990
{
19961991
cic_entry_slab = f2fs_kmem_cache_create("f2fs_cic_entry",
19971992
sizeof(struct compress_io_ctx));
19981993
if (!cic_entry_slab)
19991994
return -ENOMEM;
2000-
return 0;
2001-
}
2002-
2003-
static void f2fs_destroy_cic_cache(void)
2004-
{
2005-
kmem_cache_destroy(cic_entry_slab);
2006-
}
2007-
2008-
static int __init f2fs_init_dic_cache(void)
2009-
{
20101995
dic_entry_slab = f2fs_kmem_cache_create("f2fs_dic_entry",
20111996
sizeof(struct decompress_io_ctx));
20121997
if (!dic_entry_slab)
2013-
return -ENOMEM;
2014-
return 0;
2015-
}
2016-
2017-
static void f2fs_destroy_dic_cache(void)
2018-
{
2019-
kmem_cache_destroy(dic_entry_slab);
2020-
}
2021-
2022-
int __init f2fs_init_compress_cache(void)
2023-
{
2024-
int err;
2025-
2026-
err = f2fs_init_cic_cache();
2027-
if (err)
2028-
goto out;
2029-
err = f2fs_init_dic_cache();
2030-
if (err)
20311998
goto free_cic;
20321999
return 0;
20332000
free_cic:
2034-
f2fs_destroy_cic_cache();
2035-
out:
2001+
kmem_cache_destroy(cic_entry_slab);
20362002
return -ENOMEM;
20372003
}
20382004

20392005
void f2fs_destroy_compress_cache(void)
20402006
{
2041-
f2fs_destroy_dic_cache();
2042-
f2fs_destroy_cic_cache();
2007+
kmem_cache_destroy(dic_entry_slab);
2008+
kmem_cache_destroy(cic_entry_slab);
20432009
}

0 commit comments

Comments
 (0)