Skip to content

Commit 81d8e5e

Browse files
committed
Merge tag 'f2fs-for-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs updates from Jaegeuk Kim: "In this round, there are three major updates: (1) folio conversion, (2) refactoring for mount API conversion, (3) some performance improvement such as direct IO, checkpoint speed, and IO priority hints. For stability, there are patches which add more sanity checks and fixes some major issues like i_size in atomic write operations and write pointer recovery in zoned devices. Enhancements: - huge folio converion work by Matthew Wilcox - clean up for mount API conversion by Eric Sandeen - improve direct IO speed in the overwrite case - add some sanity check on node consistency - set highest IO priority for checkpoint thread - keep POSIX_FADV_NOREUSE ranges and add sysfs entry to reclaim pages - add ioctl to get IO priority hint - add carve_out sysfs node for fsstat Bug fixes: - disable nat_bits during umount to avoid potential nat entry corruption - fix missing i_size update on atomic writes - fix missing discard for active segments - fix running out of free segments - fix out-of-bounds access in f2fs_truncate_inode_blocks() - call f2fs_recover_quota_end() correctly - fix potential deadloop in prepare_compress_overwrite() - fix the missing write pointer correction for zoned device - fix to avoid panic once fallocation fails for pinfile - don't retry IO for corrupted data scenario There are many other clean up patches and minor bug fixes as usual" * tag 'f2fs-for-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (68 commits) f2fs: fix missing discard for active segments f2fs: optimize f2fs DIO overwrites f2fs: fix to avoid atomicity corruption of atomic file f2fs: pass sbi rather than sb to parse_options() f2fs: pass sbi rather than sb to quota qf_name helpers f2fs: defer readonly check vs norecovery f2fs: Pass sbi rather than sb to f2fs_set_test_dummy_encryption f2fs: make LAZYTIME a mount option flag f2fs: make INLINECRYPT a mount option flag f2fs: factor out an f2fs_default_check function f2fs: consolidate unsupported option handling errors f2fs: use f2fs_sb_has_device_alias during option parsing f2fs: add carve_out sysfs node f2fs: fix to avoid running out of free segments f2fs: Remove f2fs_write_node_page() f2fs: Remove f2fs_write_meta_page() f2fs: Remove f2fs_write_data_page() f2fs: Remove check for ->writepage Revert "f2fs: rebuild nat_bits during umount" f2fs: fix to avoid accessing uninitialized curseg ...
2 parents fd71def + 21263d0 commit 81d8e5e

File tree

25 files changed

+1059
-604
lines changed

25 files changed

+1059
-604
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ Description: Support configuring fault injection type, should be
734734
FAULT_BLKADDR_VALIDITY 0x000040000
735735
FAULT_BLKADDR_CONSISTENCE 0x000080000
736736
FAULT_NO_SEGMENT 0x000100000
737+
FAULT_INCONSISTENT_FOOTER 0x000200000
737738
=========================== ===========
738739

739740
What: /sys/fs/f2fs/<disk>/discard_io_aware_gran
@@ -828,3 +829,20 @@ Date: November 2024
828829
Contact: "Chao Yu" <[email protected]>
829830
Description: It controls max read extent count for per-inode, the value of threshold
830831
is 10240 by default.
832+
833+
What: /sys/fs/f2fs/tuning/reclaim_caches_kb
834+
Date: February 2025
835+
Contact: "Jaegeuk Kim" <[email protected]>
836+
Description: It reclaims the given KBs of file-backed pages registered by
837+
ioctl(F2FS_IOC_DONATE_RANGE).
838+
For example, writing N tries to drop N KBs spaces in LRU.
839+
840+
What: /sys/fs/f2fs/<disk>/carve_out
841+
Date: March 2025
842+
Contact: "Daeho Jeong" <[email protected]>
843+
Description: For several zoned storage devices, vendors will provide extra space which
844+
was used for device level GC than specs and F2FS can use this space for
845+
filesystem level GC. To do that, we can reserve the space using
846+
reserved_blocks. However, it is not enough, since this extra space should
847+
not be shown to users. So, with this new sysfs node, we can hide the space
848+
by substracting reserved_blocks from total bytes.

Documentation/filesystems/f2fs.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ fault_type=%d Support configuring fault injection type, should be
206206
FAULT_BLKADDR_VALIDITY 0x000040000
207207
FAULT_BLKADDR_CONSISTENCE 0x000080000
208208
FAULT_NO_SEGMENT 0x000100000
209+
FAULT_INCONSISTENT_FOOTER 0x000200000
209210
=========================== ===========
210211
mode=%s Control block allocation mode which supports "adaptive"
211212
and "lfs". In "lfs" mode, there should be no random
@@ -365,6 +366,8 @@ errors=%s Specify f2fs behavior on critical errors. This supports modes:
365366
pending node write drop keep N/A
366367
pending meta write keep keep N/A
367368
====================== =============== =============== ========
369+
nat_bits Enable nat_bits feature to enhance full/empty nat blocks access,
370+
by default it's disabled.
368371
======================== ============================================================
369372

370373
Debugfs Entries

fs/f2fs/checkpoint.c

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "iostat.h"
2222
#include <trace/events/f2fs.h>
2323

24-
#define DEFAULT_CHECKPOINT_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
24+
#define DEFAULT_CHECKPOINT_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_RT, 3))
2525

2626
static struct kmem_cache *ino_entry_slab;
2727
struct kmem_cache *f2fs_inode_entry_slab;
@@ -58,7 +58,7 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
5858
bool is_meta)
5959
{
6060
struct address_space *mapping = META_MAPPING(sbi);
61-
struct page *page;
61+
struct folio *folio;
6262
struct f2fs_io_info fio = {
6363
.sbi = sbi,
6464
.type = META,
@@ -74,37 +74,37 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
7474
if (unlikely(!is_meta))
7575
fio.op_flags &= ~REQ_META;
7676
repeat:
77-
page = f2fs_grab_cache_page(mapping, index, false);
78-
if (!page) {
77+
folio = f2fs_grab_cache_folio(mapping, index, false);
78+
if (IS_ERR(folio)) {
7979
cond_resched();
8080
goto repeat;
8181
}
82-
if (PageUptodate(page))
82+
if (folio_test_uptodate(folio))
8383
goto out;
8484

85-
fio.page = page;
85+
fio.page = &folio->page;
8686

8787
err = f2fs_submit_page_bio(&fio);
8888
if (err) {
89-
f2fs_put_page(page, 1);
89+
f2fs_folio_put(folio, true);
9090
return ERR_PTR(err);
9191
}
9292

9393
f2fs_update_iostat(sbi, NULL, FS_META_READ_IO, F2FS_BLKSIZE);
9494

95-
lock_page(page);
96-
if (unlikely(page->mapping != mapping)) {
97-
f2fs_put_page(page, 1);
95+
folio_lock(folio);
96+
if (unlikely(folio->mapping != mapping)) {
97+
f2fs_folio_put(folio, true);
9898
goto repeat;
9999
}
100100

101-
if (unlikely(!PageUptodate(page))) {
102-
f2fs_handle_page_eio(sbi, page_folio(page), META);
103-
f2fs_put_page(page, 1);
101+
if (unlikely(!folio_test_uptodate(folio))) {
102+
f2fs_handle_page_eio(sbi, folio, META);
103+
f2fs_folio_put(folio, true);
104104
return ERR_PTR(-EIO);
105105
}
106106
out:
107-
return page;
107+
return &folio->page;
108108
}
109109

110110
struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
@@ -381,12 +381,6 @@ static int __f2fs_write_meta_page(struct page *page,
381381
return AOP_WRITEPAGE_ACTIVATE;
382382
}
383383

384-
static int f2fs_write_meta_page(struct page *page,
385-
struct writeback_control *wbc)
386-
{
387-
return __f2fs_write_meta_page(page, wbc, FS_META_IO);
388-
}
389-
390384
static int f2fs_write_meta_pages(struct address_space *mapping,
391385
struct writeback_control *wbc)
392386
{
@@ -507,7 +501,6 @@ static bool f2fs_dirty_meta_folio(struct address_space *mapping,
507501
}
508502

509503
const struct address_space_operations f2fs_meta_aops = {
510-
.writepage = f2fs_write_meta_page,
511504
.writepages = f2fs_write_meta_pages,
512505
.dirty_folio = f2fs_dirty_meta_folio,
513506
.invalidate_folio = f2fs_invalidate_folio,
@@ -1237,7 +1230,7 @@ static int block_operations(struct f2fs_sb_info *sbi)
12371230
retry_flush_quotas:
12381231
f2fs_lock_all(sbi);
12391232
if (__need_flush_quota(sbi)) {
1240-
int locked;
1233+
bool need_lock = sbi->umount_lock_holder != current;
12411234

12421235
if (++cnt > DEFAULT_RETRY_QUOTA_FLUSH_COUNT) {
12431236
set_sbi_flag(sbi, SBI_QUOTA_SKIP_FLUSH);
@@ -1246,11 +1239,13 @@ static int block_operations(struct f2fs_sb_info *sbi)
12461239
}
12471240
f2fs_unlock_all(sbi);
12481241

1249-
/* only failed during mount/umount/freeze/quotactl */
1250-
locked = down_read_trylock(&sbi->sb->s_umount);
1251-
f2fs_quota_sync(sbi->sb, -1);
1252-
if (locked)
1242+
/* don't grab s_umount lock during mount/umount/remount/freeze/quotactl */
1243+
if (!need_lock) {
1244+
f2fs_do_quota_sync(sbi->sb, -1);
1245+
} else if (down_read_trylock(&sbi->sb->s_umount)) {
1246+
f2fs_do_quota_sync(sbi->sb, -1);
12531247
up_read(&sbi->sb->s_umount);
1248+
}
12541249
cond_resched();
12551250
goto retry_flush_quotas;
12561251
}
@@ -1344,21 +1339,13 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)
13441339
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
13451340
unsigned long flags;
13461341

1347-
if (cpc->reason & CP_UMOUNT) {
1348-
if (le32_to_cpu(ckpt->cp_pack_total_block_count) +
1349-
NM_I(sbi)->nat_bits_blocks > BLKS_PER_SEG(sbi)) {
1350-
clear_ckpt_flags(sbi, CP_NAT_BITS_FLAG);
1351-
f2fs_notice(sbi, "Disable nat_bits due to no space");
1352-
} else if (!is_set_ckpt_flags(sbi, CP_NAT_BITS_FLAG) &&
1353-
f2fs_nat_bitmap_enabled(sbi)) {
1354-
f2fs_enable_nat_bits(sbi);
1355-
set_ckpt_flags(sbi, CP_NAT_BITS_FLAG);
1356-
f2fs_notice(sbi, "Rebuild and enable nat_bits");
1357-
}
1358-
}
1359-
13601342
spin_lock_irqsave(&sbi->cp_lock, flags);
13611343

1344+
if ((cpc->reason & CP_UMOUNT) &&
1345+
le32_to_cpu(ckpt->cp_pack_total_block_count) >
1346+
sbi->blocks_per_seg - NM_I(sbi)->nat_bits_blocks)
1347+
disable_nat_bits(sbi, false);
1348+
13621349
if (cpc->reason & CP_TRIMMED)
13631350
__set_ckpt_flags(ckpt, CP_TRIMMED_FLAG);
13641351
else
@@ -1541,8 +1528,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
15411528
start_blk = __start_cp_next_addr(sbi);
15421529

15431530
/* write nat bits */
1544-
if ((cpc->reason & CP_UMOUNT) &&
1545-
is_set_ckpt_flags(sbi, CP_NAT_BITS_FLAG)) {
1531+
if (enabled_nat_bits(sbi, cpc)) {
15461532
__u64 cp_ver = cur_cp_version(ckpt);
15471533
block_t blk;
15481534

@@ -1867,7 +1853,8 @@ int f2fs_issue_checkpoint(struct f2fs_sb_info *sbi)
18671853
struct cp_control cpc;
18681854

18691855
cpc.reason = __get_cp_reason(sbi);
1870-
if (!test_opt(sbi, MERGE_CHECKPOINT) || cpc.reason != CP_SYNC) {
1856+
if (!test_opt(sbi, MERGE_CHECKPOINT) || cpc.reason != CP_SYNC ||
1857+
sbi->umount_lock_holder == current) {
18711858
int ret;
18721859

18731860
f2fs_down_write(&sbi->gc_lock);

fs/f2fs/compress.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
11501150
f2fs_compress_ctx_add_page(cc, page_folio(page));
11511151

11521152
if (!PageUptodate(page)) {
1153+
f2fs_handle_page_eio(sbi, page_folio(page), DATA);
11531154
release_and_retry:
11541155
f2fs_put_rpages(cc);
11551156
f2fs_unlock_rpages(cc, i + 1);

0 commit comments

Comments
 (0)