Skip to content

Commit 79952bd

Browse files
committed
Merge tag 'f2fs-for-6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs updates from Jaegeuk Kim: "The main changes include converting major IO paths to use folio, and adding various knobs to control GC more flexibly for Zoned devices. In addition, there are several patches to address corner cases of atomic file operations and better support for file pinning on zoned device. Enhancement: - add knobs to tune foreground/background GCs for Zoned devices - convert IO paths to use folio - reduce expensive checkpoint trigger frequency - allow F2FS_IPU_NOCACHE for pinned file - forcibly migrate to secure space for zoned device file pinning - get rid of buffer_head use - add write priority option based on zone UFS - get rid of online repair on corrupted directory Bug fixes: - fix to don't panic system for no free segment fault injection - fix to don't set SB_RDONLY in f2fs_handle_critical_error() - avoid unused block when dio write in LFS mode - compress: don't redirty sparse cluster during {,de}compress - check discard support for conventional zones - atomic: prevent atomic file from being dirtied before commit - atomic: fix to check atomic_file in f2fs ioctl interfaces - atomic: fix to forbid dio in atomic_file - atomic: fix to truncate pagecache before on-disk metadata truncation - atomic: create COW inode from parent dentry - atomic: fix to avoid racing w/ GC - atomic: require FMODE_WRITE for atomic write ioctls - fix to wait page writeback before setting gcing flag - fix to avoid racing in between read and OPU dio write, dio completion - fix several potential integer overflows in file offsets and dir_block_index - fix to avoid use-after-free in f2fs_stop_gc_thread() As usual, there are several code clean-ups and refactorings" * tag 'f2fs-for-6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (60 commits) f2fs: allow F2FS_IPU_NOCACHE for pinned file f2fs: forcibly migrate to secure space for zoned device file pinning f2fs: remove unused parameters f2fs: fix to don't panic system for no free segment fault injection f2fs: fix to don't set SB_RDONLY in f2fs_handle_critical_error() f2fs: add valid block ratio not to do excessive GC for one time GC f2fs: create gc_no_zoned_gc_percent and gc_boost_zoned_gc_percent f2fs: do FG_GC when GC boosting is required for zoned devices f2fs: increase BG GC migration window granularity when boosted for zoned devices f2fs: add reserved_segments sysfs node f2fs: introduce migration_window_granularity f2fs: make BG GC more aggressive for zoned devices f2fs: avoid unused block when dio write in LFS mode f2fs: fix to check atomic_file in f2fs ioctl interfaces f2fs: get rid of online repaire on corrupted directory f2fs: prevent atomic file from being dirtied before commit f2fs: get rid of page->index f2fs: convert read_node_page() to use folio f2fs: convert __write_node_page() to use folio f2fs: convert f2fs_write_data_page() to use folio ...
2 parents fa8380a + ae87b9c commit 79952bd

File tree

23 files changed

+798
-463
lines changed

23 files changed

+798
-463
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,12 @@ Description: When ATGC is on, it controls age threshold to bypass GCing young
579579
candidates whose age is not beyond the threshold, by default it was
580580
initialized as 604800 seconds (equals to 7 days).
581581

582+
What: /sys/fs/f2fs/<disk>/atgc_enabled
583+
Date: Feb 2024
584+
Contact: "Jinbao Liu" <liujinbao1@xiaomi.com>
585+
Description: It represents whether ATGC is on or off. The value is 1 which
586+
indicates that ATGC is on, and 0 indicates that it is off.
587+
582588
What: /sys/fs/f2fs/<disk>/gc_reclaimed_segments
583589
Date: July 2021
584590
Contact: "Daeho Jeong" <daehojeong@google.com>
@@ -763,3 +769,53 @@ Date: November 2023
763769
Contact: "Chao Yu" <chao@kernel.org>
764770
Description: It controls to enable/disable IO aware feature for background discard.
765771
By default, the value is 1 which indicates IO aware is on.
772+
773+
What: /sys/fs/f2fs/<disk>/blkzone_alloc_policy
774+
Date: July 2024
775+
Contact: "Yuanhong Liao" <liaoyuanhong@vivo.com>
776+
Description: The zone UFS we are currently using consists of two parts:
777+
conventional zones and sequential zones. It can be used to control which part
778+
to prioritize for writes, with a default value of 0.
779+
780+
======================== =========================================
781+
value description
782+
blkzone_alloc_policy = 0 Prioritize writing to sequential zones
783+
blkzone_alloc_policy = 1 Only allow writing to sequential zones
784+
blkzone_alloc_policy = 2 Prioritize writing to conventional zones
785+
======================== =========================================
786+
787+
What: /sys/fs/f2fs/<disk>/migration_window_granularity
788+
Date: September 2024
789+
Contact: "Daeho Jeong" <daehojeong@google.com>
790+
Description: Controls migration window granularity of garbage collection on large
791+
section. it can control the scanning window granularity for GC migration
792+
in a unit of segment, while migration_granularity controls the number
793+
of segments which can be migrated at the same turn.
794+
795+
What: /sys/fs/f2fs/<disk>/reserved_segments
796+
Date: September 2024
797+
Contact: "Daeho Jeong" <daehojeong@google.com>
798+
Description: In order to fine tune GC behavior, we can control the number of
799+
reserved segments.
800+
801+
What: /sys/fs/f2fs/<disk>/gc_no_zoned_gc_percent
802+
Date: September 2024
803+
Contact: "Daeho Jeong" <daehojeong@google.com>
804+
Description: If the percentage of free sections over total sections is above this
805+
number, F2FS do not garbage collection for zoned devices through the
806+
background GC thread. the default number is "60".
807+
808+
What: /sys/fs/f2fs/<disk>/gc_boost_zoned_gc_percent
809+
Date: September 2024
810+
Contact: "Daeho Jeong" <daehojeong@google.com>
811+
Description: If the percentage of free sections over total sections is under this
812+
number, F2FS boosts garbage collection for zoned devices through the
813+
background GC thread. the default number is "25".
814+
815+
What: /sys/fs/f2fs/<disk>/gc_valid_thresh_ratio
816+
Date: September 2024
817+
Contact: "Daeho Jeong" <daehojeong@google.com>
818+
Description: It controls the valid block ratio threshold not to trigger excessive GC
819+
for zoned deivces. The initial value of it is 95(%). F2FS will stop the
820+
background GC thread from intiating GC for sections having valid blocks
821+
exceeding the ratio.

fs/f2fs/checkpoint.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
9999
}
100100

101101
if (unlikely(!PageUptodate(page))) {
102-
f2fs_handle_page_eio(sbi, page->index, META);
102+
f2fs_handle_page_eio(sbi, page_folio(page), META);
103103
f2fs_put_page(page, 1);
104104
return ERR_PTR(-EIO);
105105
}
@@ -345,30 +345,31 @@ static int __f2fs_write_meta_page(struct page *page,
345345
enum iostat_type io_type)
346346
{
347347
struct f2fs_sb_info *sbi = F2FS_P_SB(page);
348+
struct folio *folio = page_folio(page);
348349

349-
trace_f2fs_writepage(page_folio(page), META);
350+
trace_f2fs_writepage(folio, META);
350351

351352
if (unlikely(f2fs_cp_error(sbi))) {
352353
if (is_sbi_flag_set(sbi, SBI_IS_CLOSE)) {
353-
ClearPageUptodate(page);
354+
folio_clear_uptodate(folio);
354355
dec_page_count(sbi, F2FS_DIRTY_META);
355-
unlock_page(page);
356+
folio_unlock(folio);
356357
return 0;
357358
}
358359
goto redirty_out;
359360
}
360361
if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
361362
goto redirty_out;
362-
if (wbc->for_reclaim && page->index < GET_SUM_BLOCK(sbi, 0))
363+
if (wbc->for_reclaim && folio->index < GET_SUM_BLOCK(sbi, 0))
363364
goto redirty_out;
364365

365-
f2fs_do_write_meta_page(sbi, page, io_type);
366+
f2fs_do_write_meta_page(sbi, folio, io_type);
366367
dec_page_count(sbi, F2FS_DIRTY_META);
367368

368369
if (wbc->for_reclaim)
369370
f2fs_submit_merged_write_cond(sbi, NULL, page, 0, META);
370371

371-
unlock_page(page);
372+
folio_unlock(folio);
372373

373374
if (unlikely(f2fs_cp_error(sbi)))
374375
f2fs_submit_merged_write(sbi, META);
@@ -1551,7 +1552,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
15511552
blk = start_blk + BLKS_PER_SEG(sbi) - nm_i->nat_bits_blocks;
15521553
for (i = 0; i < nm_i->nat_bits_blocks; i++)
15531554
f2fs_update_meta_page(sbi, nm_i->nat_bits +
1554-
(i << F2FS_BLKSIZE_BITS), blk + i);
1555+
F2FS_BLK_TO_BYTES(i), blk + i);
15551556
}
15561557

15571558
/* write out checkpoint buffer at block 0 */

fs/f2fs/compress.c

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ bool f2fs_is_compressed_page(struct page *page)
9090
static void f2fs_set_compressed_page(struct page *page,
9191
struct inode *inode, pgoff_t index, void *data)
9292
{
93-
attach_page_private(page, (void *)data);
93+
struct folio *folio = page_folio(page);
94+
95+
folio_attach_private(folio, (void *)data);
9496

9597
/* i_crypto_info and iv index */
96-
page->index = index;
97-
page->mapping = inode->i_mapping;
98+
folio->index = index;
99+
folio->mapping = inode->i_mapping;
98100
}
99101

100102
static void f2fs_drop_rpages(struct compress_ctx *cc, int len, bool unlock)
@@ -160,17 +162,17 @@ void f2fs_destroy_compress_ctx(struct compress_ctx *cc, bool reuse)
160162
cc->cluster_idx = NULL_CLUSTER;
161163
}
162164

163-
void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct page *page)
165+
void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct folio *folio)
164166
{
165167
unsigned int cluster_ofs;
166168

167-
if (!f2fs_cluster_can_merge_page(cc, page->index))
169+
if (!f2fs_cluster_can_merge_page(cc, folio->index))
168170
f2fs_bug_on(F2FS_I_SB(cc->inode), 1);
169171

170-
cluster_ofs = offset_in_cluster(cc, page->index);
171-
cc->rpages[cluster_ofs] = page;
172+
cluster_ofs = offset_in_cluster(cc, folio->index);
173+
cc->rpages[cluster_ofs] = folio_page(folio, 0);
172174
cc->nr_rpages++;
173-
cc->cluster_idx = cluster_idx(cc, page->index);
175+
cc->cluster_idx = cluster_idx(cc, folio->index);
174176
}
175177

176178
#ifdef CONFIG_F2FS_FS_LZO
@@ -879,7 +881,7 @@ static bool cluster_has_invalid_data(struct compress_ctx *cc)
879881
f2fs_bug_on(F2FS_I_SB(cc->inode), !page);
880882

881883
/* beyond EOF */
882-
if (page->index >= nr_pages)
884+
if (page_folio(page)->index >= nr_pages)
883885
return true;
884886
}
885887
return false;
@@ -945,7 +947,7 @@ static int __f2fs_get_cluster_blocks(struct inode *inode,
945947
unsigned int cluster_size = F2FS_I(inode)->i_cluster_size;
946948
int count, i;
947949

948-
for (i = 1, count = 1; i < cluster_size; i++) {
950+
for (i = 0, count = 0; i < cluster_size; i++) {
949951
block_t blkaddr = data_blkaddr(dn->inode, dn->node_page,
950952
dn->ofs_in_node + i);
951953

@@ -956,8 +958,8 @@ static int __f2fs_get_cluster_blocks(struct inode *inode,
956958
return count;
957959
}
958960

959-
static int __f2fs_cluster_blocks(struct inode *inode,
960-
unsigned int cluster_idx, bool compr_blks)
961+
static int __f2fs_cluster_blocks(struct inode *inode, unsigned int cluster_idx,
962+
enum cluster_check_type type)
961963
{
962964
struct dnode_of_data dn;
963965
unsigned int start_idx = cluster_idx <<
@@ -978,10 +980,12 @@ static int __f2fs_cluster_blocks(struct inode *inode,
978980
}
979981

980982
if (dn.data_blkaddr == COMPRESS_ADDR) {
981-
if (compr_blks)
982-
ret = __f2fs_get_cluster_blocks(inode, &dn);
983-
else
983+
if (type == CLUSTER_COMPR_BLKS)
984+
ret = 1 + __f2fs_get_cluster_blocks(inode, &dn);
985+
else if (type == CLUSTER_IS_COMPR)
984986
ret = 1;
987+
} else if (type == CLUSTER_RAW_BLKS) {
988+
ret = __f2fs_get_cluster_blocks(inode, &dn);
985989
}
986990
fail:
987991
f2fs_put_dnode(&dn);
@@ -991,15 +995,33 @@ static int __f2fs_cluster_blocks(struct inode *inode,
991995
/* return # of compressed blocks in compressed cluster */
992996
static int f2fs_compressed_blocks(struct compress_ctx *cc)
993997
{
994-
return __f2fs_cluster_blocks(cc->inode, cc->cluster_idx, true);
998+
return __f2fs_cluster_blocks(cc->inode, cc->cluster_idx,
999+
CLUSTER_COMPR_BLKS);
1000+
}
1001+
1002+
/* return # of raw blocks in non-compressed cluster */
1003+
static int f2fs_decompressed_blocks(struct inode *inode,
1004+
unsigned int cluster_idx)
1005+
{
1006+
return __f2fs_cluster_blocks(inode, cluster_idx,
1007+
CLUSTER_RAW_BLKS);
9951008
}
9961009

9971010
/* return whether cluster is compressed one or not */
9981011
int f2fs_is_compressed_cluster(struct inode *inode, pgoff_t index)
9991012
{
10001013
return __f2fs_cluster_blocks(inode,
10011014
index >> F2FS_I(inode)->i_log_cluster_size,
1002-
false);
1015+
CLUSTER_IS_COMPR);
1016+
}
1017+
1018+
/* return whether cluster contains non raw blocks or not */
1019+
bool f2fs_is_sparse_cluster(struct inode *inode, pgoff_t index)
1020+
{
1021+
unsigned int cluster_idx = index >> F2FS_I(inode)->i_log_cluster_size;
1022+
1023+
return f2fs_decompressed_blocks(inode, cluster_idx) !=
1024+
F2FS_I(inode)->i_cluster_size;
10031025
}
10041026

10051027
static bool cluster_may_compress(struct compress_ctx *cc)
@@ -1093,7 +1115,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
10931115
if (PageUptodate(page))
10941116
f2fs_put_page(page, 1);
10951117
else
1096-
f2fs_compress_ctx_add_page(cc, page);
1118+
f2fs_compress_ctx_add_page(cc, page_folio(page));
10971119
}
10981120

10991121
if (!f2fs_cluster_is_empty(cc)) {
@@ -1123,7 +1145,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
11231145
}
11241146

11251147
f2fs_wait_on_page_writeback(page, DATA, true, true);
1126-
f2fs_compress_ctx_add_page(cc, page);
1148+
f2fs_compress_ctx_add_page(cc, page_folio(page));
11271149

11281150
if (!PageUptodate(page)) {
11291151
release_and_retry:
@@ -1523,7 +1545,8 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,
15231545
if (!clear_page_dirty_for_io(cc->rpages[i]))
15241546
goto continue_unlock;
15251547

1526-
ret = f2fs_write_single_data_page(cc->rpages[i], &submitted,
1548+
ret = f2fs_write_single_data_page(page_folio(cc->rpages[i]),
1549+
&submitted,
15271550
NULL, NULL, wbc, io_type,
15281551
compr_blocks, false);
15291552
if (ret) {

0 commit comments

Comments
 (0)