Skip to content

Commit 8e42c9a

Browse files
committed
Merge branch 'upstream-f2fs-stable-linux-4.19.y' of https://mirrors.bfsu.edu.cn/git/AOSP/kernel/common into ack
2 parents 6548c87 + b9aeb14 commit 8e42c9a

31 files changed

+2408
-1160
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

+89-6
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ Description: Controls the issue rate of discard commands that consist of small
9696
checkpoint is triggered, and issued during the checkpoint.
9797
By default, it is disabled with 0.
9898

99+
What: /sys/fs/f2fs/<disk>/max_ordered_discard
100+
Date: October 2022
101+
Contact: "Yangtao Li" <[email protected]>
102+
Description: Controls the maximum ordered discard, the unit size is one block(4KB).
103+
Set it to 16 by default.
104+
99105
What: /sys/fs/f2fs/<disk>/max_discard_request
100106
Date: December 2021
101107
Contact: "Konstantin Vyshetsky" <[email protected]>
@@ -129,7 +135,8 @@ Contact: "Chao Yu" <[email protected]>
129135
Description: Controls discard granularity of inner discard thread. Inner thread
130136
will not issue discards with size that is smaller than granularity.
131137
The unit size is one block(4KB), now only support configuring
132-
in range of [1, 512]. Default value is 4(=16KB).
138+
in range of [1, 512]. Default value is 16.
139+
For small devices, default value is 1.
133140

134141
What: /sys/fs/f2fs/<disk>/umount_discard_timeout
135142
Date: January 2019
@@ -232,7 +239,7 @@ Description: Shows total written kbytes issued to disk.
232239
What: /sys/fs/f2fs/<disk>/features
233240
Date: July 2017
234241
Contact: "Jaegeuk Kim" <[email protected]>
235-
Description: <deprecated: should use /sys/fs/f2fs/<disk>/feature_list/
242+
Description: <deprecated: should use /sys/fs/f2fs/<disk>/feature_list/>
236243
Shows all enabled features in current device.
237244
Supported features:
238245
encryption, blkzoned, extra_attr, projquota, inode_checksum,
@@ -453,6 +460,30 @@ Description: Show status of f2fs superblock in real time.
453460
0x4000 SBI_IS_FREEZING freefs is in process
454461
====== ===================== =================================
455462

463+
What: /sys/fs/f2fs/<disk>/stat/cp_status
464+
Date: September 2022
465+
Contact: "Chao Yu" <[email protected]>
466+
Description: Show status of f2fs checkpoint in real time.
467+
468+
=============================== ==============================
469+
cp flag value
470+
CP_UMOUNT_FLAG 0x00000001
471+
CP_ORPHAN_PRESENT_FLAG 0x00000002
472+
CP_COMPACT_SUM_FLAG 0x00000004
473+
CP_ERROR_FLAG 0x00000008
474+
CP_FSCK_FLAG 0x00000010
475+
CP_FASTBOOT_FLAG 0x00000020
476+
CP_CRC_RECOVERY_FLAG 0x00000040
477+
CP_NAT_BITS_FLAG 0x00000080
478+
CP_TRIMMED_FLAG 0x00000100
479+
CP_NOCRC_RECOVERY_FLAG 0x00000200
480+
CP_LARGE_NAT_BITMAP_FLAG 0x00000400
481+
CP_QUOTA_NEED_FSCK_FLAG 0x00000800
482+
CP_DISABLED_FLAG 0x00001000
483+
CP_DISABLED_QUICK_FLAG 0x00002000
484+
CP_RESIZEFS_FLAG 0x00004000
485+
=============================== ==============================
486+
456487
What: /sys/fs/f2fs/<disk>/ckpt_thread_ioprio
457488
Date: January 2021
458489
Contact: "Daeho Jeong" <[email protected]>
@@ -549,10 +580,10 @@ Description: With "mode=fragment:block" mount options, we can scatter block allo
549580
in the length of 1..<max_fragment_hole> by turns. This value can be set
550581
between 1..512 and the default value is 4.
551582

552-
What: /sys/fs/f2fs/<disk>/gc_urgent_high_remaining
553-
Date: December 2021
554-
Contact: "Daeho Jeong" <daehojeong@google.com>
555-
Description: You can set the trial count limit for GC urgent high mode with this value.
583+
What: /sys/fs/f2fs/<disk>/gc_remaining_trials
584+
Date: October 2022
585+
Contact: "Yangtao Li" <frank.li@vivo.com>
586+
Description: You can set the trial count limit for GC urgent and idle mode with this value.
556587
If GC thread gets to the limit, the mode will turn back to GC normal mode.
557588
By default, the value is zero, which means there is no limit like before.
558589

@@ -561,3 +592,55 @@ Date: January 2022
561592
Contact: "Jaegeuk Kim" <[email protected]>
562593
Description: Controls max # of node block writes to be used for roll forward
563594
recovery. This can limit the roll forward recovery time.
595+
596+
What: /sys/fs/f2fs/<disk>/current_atomic_write
597+
Date: July 2022
598+
Contact: "Daeho Jeong" <[email protected]>
599+
Description: Show the total current atomic write block count, which is not committed yet.
600+
This is a read-only entry.
601+
602+
What: /sys/fs/f2fs/<disk>/peak_atomic_write
603+
Date: July 2022
604+
Contact: "Daeho Jeong" <[email protected]>
605+
Description: Show the peak value of total current atomic write block count after boot.
606+
If you write "0" here, you can initialize to "0".
607+
608+
What: /sys/fs/f2fs/<disk>/committed_atomic_block
609+
Date: July 2022
610+
Contact: "Daeho Jeong" <[email protected]>
611+
Description: Show the accumulated total committed atomic write block count after boot.
612+
If you write "0" here, you can initialize to "0".
613+
614+
What: /sys/fs/f2fs/<disk>/revoked_atomic_block
615+
Date: July 2022
616+
Contact: "Daeho Jeong" <[email protected]>
617+
Description: Show the accumulated total revoked atomic write block count after boot.
618+
If you write "0" here, you can initialize to "0".
619+
620+
What: /sys/fs/f2fs/<disk>/gc_mode
621+
Date: October 2022
622+
Contact: "Yangtao Li" <[email protected]>
623+
Description: Show the current gc_mode as a string.
624+
This is a read-only entry.
625+
626+
What: /sys/fs/f2fs/<disk>/discard_urgent_util
627+
Date: November 2022
628+
Contact: "Yangtao Li" <[email protected]>
629+
Description: When space utilization exceeds this, do background DISCARD aggressively.
630+
Does DISCARD forcibly in a period of given min_discard_issue_time when the number
631+
of discards is not 0 and set discard granularity to 1.
632+
Default: 80
633+
634+
What: /sys/fs/f2fs/<disk>/hot_data_age_threshold
635+
Date: November 2022
636+
Contact: "Ping Xiong" <[email protected]>
637+
Description: When DATA SEPARATION is on, it controls the age threshold to indicate
638+
the data blocks as hot. By default it was initialized as 262144 blocks
639+
(equals to 1GB).
640+
641+
What: /sys/fs/f2fs/<disk>/warm_data_age_threshold
642+
Date: November 2022
643+
Contact: "Ping Xiong" <[email protected]>
644+
Description: When DATA SEPARATION is on, it controls the age threshold to indicate
645+
the data blocks as warm. By default it was initialized as 2621440 blocks
646+
(equals to 10GB).

Documentation/filesystems/f2fs.rst

+12-1
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
@@ -341,6 +348,10 @@ memory=%s Control memory mode. This supports "normal" and "low" modes.
341348
Because of the nature of low memory devices, in this mode, f2fs
342349
will try to save memory sometimes by sacrificing performance.
343350
"normal" mode is the default mode and same as before.
351+
age_extent_cache Enable an age extent cache based on rb-tree. It records
352+
data block update frequency of the extent per inode, in
353+
order to provide better temperature hints for data block
354+
allocation.
344355
======================== ============================================================
345356

346357
Debugfs Entries

MAINTAINERS

+1
Original file line numberDiff line numberDiff line change
@@ -5612,6 +5612,7 @@ M: Jaegeuk Kim <[email protected]>
56125612
M: Chao Yu <[email protected]>
56135613
56145614
W: https://f2fs.wiki.kernel.org/
5615+
B: https://bugzilla.kernel.org/enter_bug.cgi?product=File%20System&component=f2fs
56155616
T: git git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git
56165617
S: Maintained
56175618
F: Documentation/filesystems/f2fs.txt

fs/f2fs/checkpoint.c

+52-17
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@
2626
static struct kmem_cache *ino_entry_slab;
2727
struct kmem_cache *f2fs_inode_entry_slab;
2828

29-
void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
29+
void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io,
30+
unsigned char reason)
3031
{
3132
f2fs_build_fault_attr(sbi, 0, 0);
3233
set_ckpt_flags(sbi, CP_ERROR_FLAG);
33-
if (!end_io)
34+
if (!end_io) {
3435
f2fs_flush_merged_writes(sbi);
36+
37+
f2fs_handle_stop(sbi, reason);
38+
}
3539
}
3640

3741
/*
@@ -122,7 +126,7 @@ struct page *f2fs_get_meta_page_retry(struct f2fs_sb_info *sbi, pgoff_t index)
122126
if (PTR_ERR(page) == -EIO &&
123127
++count <= DEFAULT_RETRY_IO_COUNT)
124128
goto retry;
125-
f2fs_stop_checkpoint(sbi, false);
129+
f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_META_PAGE);
126130
}
127131
return page;
128132
}
@@ -140,14 +144,21 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
140144
unsigned int segno, offset;
141145
bool exist;
142146

143-
if (type != DATA_GENERIC_ENHANCE && type != DATA_GENERIC_ENHANCE_READ)
147+
if (type == DATA_GENERIC)
144148
return true;
145149

146150
segno = GET_SEGNO(sbi, blkaddr);
147151
offset = GET_BLKOFF_FROM_SEG0(sbi, blkaddr);
148152
se = get_seg_entry(sbi, segno);
149153

150154
exist = f2fs_test_bit(offset, se->cur_valid_map);
155+
if (exist && type == DATA_GENERIC_ENHANCE_UPDATE) {
156+
f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
157+
blkaddr, exist);
158+
set_sbi_flag(sbi, SBI_NEED_FSCK);
159+
return exist;
160+
}
161+
151162
if (!exist && type == DATA_GENERIC_ENHANCE) {
152163
f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
153164
blkaddr, exist);
@@ -160,6 +171,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
160171
bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
161172
block_t blkaddr, int type)
162173
{
174+
if (time_to_inject(sbi, FAULT_BLKADDR)) {
175+
f2fs_show_injection_info(sbi, FAULT_BLKADDR);
176+
return false;
177+
}
178+
163179
switch (type) {
164180
case META_NAT:
165181
break;
@@ -185,6 +201,7 @@ bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
185201
case DATA_GENERIC:
186202
case DATA_GENERIC_ENHANCE:
187203
case DATA_GENERIC_ENHANCE_READ:
204+
case DATA_GENERIC_ENHANCE_UPDATE:
188205
if (unlikely(blkaddr >= MAX_BLKADDR(sbi) ||
189206
blkaddr < MAIN_BLKADDR(sbi))) {
190207
f2fs_warn(sbi, "access invalid blkaddr:%u",
@@ -447,8 +464,7 @@ static int f2fs_set_meta_page_dirty(struct page *page)
447464

448465
if (!PageUptodate(page))
449466
SetPageUptodate(page);
450-
if (!PageDirty(page)) {
451-
__set_page_dirty_nobuffers(page);
467+
if (__set_page_dirty_nobuffers(page)) {
452468
inc_page_count(F2FS_P_SB(page), F2FS_DIRTY_META);
453469
set_page_private_reference(page);
454470
return 1;
@@ -1054,7 +1070,8 @@ void f2fs_remove_dirty_inode(struct inode *inode)
10541070
spin_unlock(&sbi->inode_lock[type]);
10551071
}
10561072

1057-
int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
1073+
int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type,
1074+
bool from_cp)
10581075
{
10591076
struct list_head *head;
10601077
struct inode *inode;
@@ -1089,11 +1106,15 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
10891106
if (inode) {
10901107
unsigned long cur_ino = inode->i_ino;
10911108

1092-
F2FS_I(inode)->cp_task = current;
1109+
if (from_cp)
1110+
F2FS_I(inode)->cp_task = current;
1111+
F2FS_I(inode)->wb_task = current;
10931112

10941113
filemap_fdatawrite(inode->i_mapping);
10951114

1096-
F2FS_I(inode)->cp_task = NULL;
1115+
F2FS_I(inode)->wb_task = NULL;
1116+
if (from_cp)
1117+
F2FS_I(inode)->cp_task = NULL;
10971118

10981119
iput(inode);
10991120
/* We need to give cpu to another writers. */
@@ -1222,7 +1243,7 @@ static int block_operations(struct f2fs_sb_info *sbi)
12221243
/* write all the dirty dentry pages */
12231244
if (get_pages(sbi, F2FS_DIRTY_DENTS)) {
12241245
f2fs_unlock_all(sbi);
1225-
err = f2fs_sync_dirty_inodes(sbi, DIR_INODE);
1246+
err = f2fs_sync_dirty_inodes(sbi, DIR_INODE, true);
12261247
if (err)
12271248
return err;
12281249
cond_resched();
@@ -1889,8 +1910,10 @@ int f2fs_start_ckpt_thread(struct f2fs_sb_info *sbi)
18891910
cprc->f2fs_issue_ckpt = kthread_run(issue_checkpoint_thread, sbi,
18901911
"f2fs_ckpt-%u:%u", MAJOR(dev), MINOR(dev));
18911912
if (IS_ERR(cprc->f2fs_issue_ckpt)) {
1913+
int err = PTR_ERR(cprc->f2fs_issue_ckpt);
1914+
18921915
cprc->f2fs_issue_ckpt = NULL;
1893-
return -ENOMEM;
1916+
return err;
18941917
}
18951918

18961919
set_task_ioprio(cprc->f2fs_issue_ckpt, cprc->ckpt_thread_ioprio);
@@ -1901,15 +1924,27 @@ int f2fs_start_ckpt_thread(struct f2fs_sb_info *sbi)
19011924
void f2fs_stop_ckpt_thread(struct f2fs_sb_info *sbi)
19021925
{
19031926
struct ckpt_req_control *cprc = &sbi->cprc_info;
1927+
struct task_struct *ckpt_task;
19041928

1905-
if (cprc->f2fs_issue_ckpt) {
1906-
struct task_struct *ckpt_task = cprc->f2fs_issue_ckpt;
1929+
if (!cprc->f2fs_issue_ckpt)
1930+
return;
19071931

1908-
cprc->f2fs_issue_ckpt = NULL;
1909-
kthread_stop(ckpt_task);
1932+
ckpt_task = cprc->f2fs_issue_ckpt;
1933+
cprc->f2fs_issue_ckpt = NULL;
1934+
kthread_stop(ckpt_task);
19101935

1911-
flush_remained_ckpt_reqs(sbi, NULL);
1912-
}
1936+
f2fs_flush_ckpt_thread(sbi);
1937+
}
1938+
1939+
void f2fs_flush_ckpt_thread(struct f2fs_sb_info *sbi)
1940+
{
1941+
struct ckpt_req_control *cprc = &sbi->cprc_info;
1942+
1943+
flush_remained_ckpt_reqs(sbi, NULL);
1944+
1945+
/* Let's wait for the previous dispatched checkpoint. */
1946+
while (atomic_read(&cprc->queued_ckpt))
1947+
io_schedule_timeout(DEFAULT_IO_TIMEOUT);
19131948
}
19141949

19151950
void f2fs_init_ckpt_req_control(struct f2fs_sb_info *sbi)

0 commit comments

Comments
 (0)