linux-f2fs-devel Mailing List for linux-f2fs (Page 3)
Brought to you by:
kjgkr
You can subscribe to this list here.
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(10) |
Dec
(98) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2013 |
Jan
(100) |
Feb
(72) |
Mar
(79) |
Apr
(122) |
May
(93) |
Jun
(97) |
Jul
(72) |
Aug
(72) |
Sep
(73) |
Oct
(121) |
Nov
(161) |
Dec
(206) |
2014 |
Jan
(75) |
Feb
(54) |
Mar
(82) |
Apr
(98) |
May
(67) |
Jun
(89) |
Jul
(136) |
Aug
(122) |
Sep
(136) |
Oct
(58) |
Nov
(87) |
Dec
(114) |
2015 |
Jan
(140) |
Feb
(129) |
Mar
(141) |
Apr
(71) |
May
(192) |
Jun
(52) |
Jul
(120) |
Aug
(125) |
Sep
(157) |
Oct
(100) |
Nov
(54) |
Dec
(248) |
2016 |
Jan
(301) |
Feb
(180) |
Mar
(138) |
Apr
(137) |
May
(145) |
Jun
(123) |
Jul
(98) |
Aug
(143) |
Sep
(196) |
Oct
(166) |
Nov
(205) |
Dec
(141) |
2017 |
Jan
(167) |
Feb
(275) |
Mar
(273) |
Apr
(239) |
May
(193) |
Jun
(171) |
Jul
(226) |
Aug
(153) |
Sep
(212) |
Oct
(311) |
Nov
(257) |
Dec
(418) |
2018 |
Jan
(474) |
Feb
(188) |
Mar
(252) |
Apr
(500) |
May
(176) |
Jun
(291) |
Jul
(361) |
Aug
(331) |
Sep
(355) |
Oct
(154) |
Nov
(209) |
Dec
(185) |
2019 |
Jan
(172) |
Feb
(214) |
Mar
(247) |
Apr
(425) |
May
(273) |
Jun
(360) |
Jul
(400) |
Aug
(409) |
Sep
(149) |
Oct
(218) |
Nov
(319) |
Dec
(225) |
2020 |
Jan
(231) |
Feb
(487) |
Mar
(411) |
Apr
(258) |
May
(292) |
Jun
(369) |
Jul
(407) |
Aug
(173) |
Sep
(266) |
Oct
(317) |
Nov
(273) |
Dec
(391) |
2021 |
Jan
(285) |
Feb
(130) |
Mar
(232) |
Apr
(156) |
May
(311) |
Jun
(252) |
Jul
(336) |
Aug
(326) |
Sep
(151) |
Oct
(86) |
Nov
(114) |
Dec
(125) |
2022 |
Jan
(132) |
Feb
(167) |
Mar
(230) |
Apr
(460) |
May
(334) |
Jun
(324) |
Jul
(147) |
Aug
(188) |
Sep
(262) |
Oct
(346) |
Nov
(314) |
Dec
(245) |
2023 |
Jan
(306) |
Feb
(190) |
Mar
(199) |
Apr
(444) |
May
(378) |
Jun
(441) |
Jul
(403) |
Aug
(464) |
Sep
(144) |
Oct
(98) |
Nov
(152) |
Dec
(212) |
2024 |
Jan
(288) |
Feb
(365) |
Mar
(218) |
Apr
(275) |
May
(200) |
Jun
(228) |
Jul
(255) |
Aug
(228) |
Sep
(280) |
Oct
(319) |
Nov
(241) |
Dec
(174) |
2025 |
Jan
(166) |
Feb
(171) |
Mar
(469) |
Apr
(235) |
May
(257) |
Jun
(342) |
Jul
(369) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Chao Yu <ch...@ke...> - 2025-07-25 02:35:21
|
On 7/24/2025 11:59 PM, mason.zhang wrote: > Otherwise, the filesystem may unaware of potential file corruption. > > Signed-off-by: mason.zhang <mas...@gm...> > --- > fs/f2fs/segment.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index ae1223ef648f..ce80ba226aed 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -3936,12 +3936,15 @@ static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio) > int seg_type = log_type_to_seg_type(type); > bool keep_order = (f2fs_lfs_mode(fio->sbi) && > seg_type == CURSEG_COLD_DATA); > + int err; > > if (keep_order) > f2fs_down_read(&fio->sbi->io_order_lock); > > - if (f2fs_allocate_data_block(fio->sbi, fio->page, fio->old_blkaddr, > - &fio->new_blkaddr, sum, type, fio)) { > + err = f2fs_allocate_data_block(fio->sbi, fio->page, fio->old_blkaddr, > + &fio->new_blkaddr, sum, type, fio); > + if (unlikely(err)) { > + f2fs_err(fio->sbi, "Failed to allocate data block(%d)", err); How about using f2fs_err_ratelimited() to avoid too many logs? Can you please dump more informations about inode, page, blkaddr...? Thanks, > if (fscrypt_inode_uses_fs_layer_crypto(folio->mapping->host)) > fscrypt_finalize_bounce_page(&fio->encrypted_page); > folio_end_writeback(folio); |
From: wangzijie <wan...@ho...> - 2025-07-25 02:17:47
|
> On 7/22/25 22:36, wangzijie wrote: > > When we need to alloc nat entry and set it dirty, we can directly add it to > > dirty set list(or initialize its list_head for new_ne) instead of adding it > > to clean list and make a move. Introduce init_dirty flag to do it. > > > > Signed-off-by: wangzijie <wan...@ho...> > > --- > > fs/f2fs/node.c | 37 ++++++++++++++++++++++++++++++------- > > 1 file changed, 30 insertions(+), 7 deletions(-) > > > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > > index a23db6238..20bcf8559 100644 > > --- a/fs/f2fs/node.c > > +++ b/fs/f2fs/node.c > > @@ -185,7 +185,7 @@ static void __free_nat_entry(struct nat_entry *e) > > > > /* must be locked by nat_tree_lock */ > > static struct nat_entry *__init_nat_entry(struct f2fs_nm_info *nm_i, > > - struct nat_entry *ne, struct f2fs_nat_entry *raw_ne, bool no_fail) > > + struct nat_entry *ne, struct f2fs_nat_entry *raw_ne, bool no_fail, bool init_dirty) > > { > > if (no_fail) > > f2fs_radix_tree_insert(&nm_i->nat_root, nat_get_nid(ne), ne); > > @@ -195,6 +195,11 @@ static struct nat_entry *__init_nat_entry(struct f2fs_nm_info *nm_i, > > if (raw_ne) > > node_info_from_raw_nat(&ne->ni, raw_ne); > > > > + if (init_dirty) { > > + nm_i->nat_cnt[TOTAL_NAT]++; > > + return ne; > > + } > > + > > spin_lock(&nm_i->nat_list_lock); > > list_add_tail(&ne->list, &nm_i->nat_entries); > > spin_unlock(&nm_i->nat_list_lock); > > @@ -256,7 +261,7 @@ static struct nat_entry_set *__grab_nat_entry_set(struct f2fs_nm_info *nm_i, > > } > > > > static void __set_nat_cache_dirty(struct f2fs_nm_info *nm_i, > > - struct nat_entry *ne) > > + struct nat_entry *ne, bool init_dirty) > > { > > struct nat_entry_set *head; > > bool new_ne = nat_get_blkaddr(ne) == NEW_ADDR; > > @@ -275,6 +280,18 @@ static void __set_nat_cache_dirty(struct f2fs_nm_info *nm_i, > > > > set_nat_flag(ne, IS_PREALLOC, new_ne); > > > > + if (init_dirty) { > > + nm_i->nat_cnt[DIRTY_NAT]++; > > + set_nat_flag(ne, IS_DIRTY, true); > > + spin_lock(&nm_i->nat_list_lock); > > + if (new_ne) > > + INIT_LIST_HEAD(&ne->list); > > + else > > + list_add_tail(&ne->list, &head->entry_list); > > + spin_unlock(&nm_i->nat_list_lock); > > + return; > > + } > > Nit issue, above blanks should be replaced w/ tab. Ah...my bad :-( > Can we clean up like this? > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > index de99b42437c6..60fc2c7b8e10 100644 > --- a/fs/f2fs/node.c > +++ b/fs/f2fs/node.c > @@ -280,30 +280,23 @@ static void __set_nat_cache_dirty(struct f2fs_nm_info *nm_i, > > set_nat_flag(ne, IS_PREALLOC, new_ne); > > - if (init_dirty) { > - nm_i->nat_cnt[DIRTY_NAT]++; > - set_nat_flag(ne, IS_DIRTY, true); > - spin_lock(&nm_i->nat_list_lock); > - if (new_ne) > - INIT_LIST_HEAD(&ne->list); > - else > - list_add_tail(&ne->list, &head->entry_list); > - spin_unlock(&nm_i->nat_list_lock); > - return; > - } > - > if (get_nat_flag(ne, IS_DIRTY)) > goto refresh_list; > > nm_i->nat_cnt[DIRTY_NAT]++; > - nm_i->nat_cnt[RECLAIMABLE_NAT]--; > + if (!init_dirty) > + nm_i->nat_cnt[RECLAIMABLE_NAT]--; > set_nat_flag(ne, IS_DIRTY, true); > refresh_list: > spin_lock(&nm_i->nat_list_lock); > - if (new_ne) > - list_del_init(&ne->list); > - else > + if (new_ne) { > + if (init_dirty) > + INIT_LIST_HEAD(&ne->list); > + else > + list_del_init(&ne->list); > + } else { > list_move_tail(&ne->list, &head->entry_list); > + } > spin_unlock(&nm_i->nat_list_lock); > } > > Thanks, We need to init list_head before using list_move_tail. I think we can do more clean up like this, keep refresh_list part code. diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 20bcf8559..ebb624fa1 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -196,6 +196,7 @@ static struct nat_entry *__init_nat_entry(struct f2fs_nm_info *nm_i, node_info_from_raw_nat(&ne->ni, raw_ne); if (init_dirty) { + INIT_LIST_HEAD(&ne->list); nm_i->nat_cnt[TOTAL_NAT]++; return ne; } @@ -280,23 +281,12 @@ static void __set_nat_cache_dirty(struct f2fs_nm_info *nm_i, set_nat_flag(ne, IS_PREALLOC, new_ne); - if (init_dirty) { - nm_i->nat_cnt[DIRTY_NAT]++; - set_nat_flag(ne, IS_DIRTY, true); - spin_lock(&nm_i->nat_list_lock); - if (new_ne) - INIT_LIST_HEAD(&ne->list); - else - list_add_tail(&ne->list, &head->entry_list); - spin_unlock(&nm_i->nat_list_lock); - return; - } - if (get_nat_flag(ne, IS_DIRTY)) goto refresh_list; nm_i->nat_cnt[DIRTY_NAT]++; - nm_i->nat_cnt[RECLAIMABLE_NAT]--; + if (!init_dirty) + nm_i->nat_cnt[RECLAIMABLE_NAT]--; set_nat_flag(ne, IS_DIRTY, true); refresh_list: spin_lock(&nm_i->nat_list_lock); > > + > > if (get_nat_flag(ne, IS_DIRTY)) > > goto refresh_list; > > > > @@ -441,7 +458,7 @@ static void cache_nat_entry(struct f2fs_sb_info *sbi, nid_t nid, > > f2fs_down_write(&nm_i->nat_tree_lock); > > e = __lookup_nat_cache(nm_i, nid, false); > > if (!e) > > - e = __init_nat_entry(nm_i, new, ne, false); > > + e = __init_nat_entry(nm_i, new, ne, false, false); > > else > > f2fs_bug_on(sbi, nat_get_ino(e) != le32_to_cpu(ne->ino) || > > nat_get_blkaddr(e) != > > @@ -458,11 +475,13 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni, > > struct f2fs_nm_info *nm_i = NM_I(sbi); > > struct nat_entry *e; > > struct nat_entry *new = __alloc_nat_entry(sbi, ni->nid, true); > > + bool init_dirty = false; > > > > f2fs_down_write(&nm_i->nat_tree_lock); > > e = __lookup_nat_cache(nm_i, ni->nid, true); > > if (!e) { > > - e = __init_nat_entry(nm_i, new, NULL, true); > > + init_dirty = true; > > + e = __init_nat_entry(nm_i, new, NULL, true, true); > > copy_node_info(&e->ni, ni); > > f2fs_bug_on(sbi, ni->blk_addr == NEW_ADDR); > > } else if (new_blkaddr == NEW_ADDR) { > > @@ -498,7 +517,7 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni, > > nat_set_blkaddr(e, new_blkaddr); > > if (!__is_valid_data_blkaddr(new_blkaddr)) > > set_nat_flag(e, IS_CHECKPOINTED, false); > > - __set_nat_cache_dirty(nm_i, e); > > + __set_nat_cache_dirty(nm_i, e, init_dirty); > > > > /* update fsync_mark if its inode nat entry is still alive */ > > if (ni->nid != ni->ino) > > @@ -2924,6 +2943,7 @@ static void remove_nats_in_journal(struct f2fs_sb_info *sbi) > > struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); > > struct f2fs_journal *journal = curseg->journal; > > int i; > > + bool init_dirty; > > > > down_write(&curseg->journal_rwsem); > > for (i = 0; i < nats_in_cursum(journal); i++) { > > @@ -2934,12 +2954,15 @@ static void remove_nats_in_journal(struct f2fs_sb_info *sbi) > > if (f2fs_check_nid_range(sbi, nid)) > > continue; > > > > + init_dirty = false; > > + > > raw_ne = nat_in_journal(journal, i); > > > > ne = __lookup_nat_cache(nm_i, nid, true); > > if (!ne) { > > + init_dirty = true; > > ne = __alloc_nat_entry(sbi, nid, true); > > - __init_nat_entry(nm_i, ne, &raw_ne, true); > > + __init_nat_entry(nm_i, ne, &raw_ne, true, true); > > } > > > > /* > > @@ -2954,7 +2977,7 @@ static void remove_nats_in_journal(struct f2fs_sb_info *sbi) > > spin_unlock(&nm_i->nid_list_lock); > > } > > > > - __set_nat_cache_dirty(nm_i, ne); > > + __set_nat_cache_dirty(nm_i, ne, init_dirty); > > } > > update_nats_in_cursum(journal, -i); > > up_write(&curseg->journal_rwsem); |
From: Zhiguo N. <niu...@gm...> - 2025-07-25 02:08:39
|
Chao Yu via Linux-f2fs-devel <lin...@li...> 于2025年7月25日周五 09:03写道: > > It provides a way to disable linear lookup fallback during mkfs. > > Behavior summary: > Android Distro > By default disabled enabled > Tune w/ [no]hashonly no yes > > Android case: > > 1.1) Disable linear lookup: > mkfs.f2fs -f -g android -O casefold -C utf8:hashonly /dev/vdb > dump.f2fs -d3 /dev/vdb |grep s_encoding_flags > s_encoding_flags [0x 2 : 2] > > 1.2) Enable linear lookup: > mkfs.f2fs -f -g android -O casefold -C utf8:nohashonly /dev/vdb > dump.f2fs -d3 /dev/vdb |grep s_encoding_flags > s_encoding_flags [0x 2 : 2] Hi Chao, Seems like a typo here? should be: s_encoding_flags [0x 0 : 0] ? thanks! > > 1.3) By default: > mkfs.f2fs -f -g android -O casefold -C utf8 /dev/vdb > dump.f2fs -d3 /dev/vdb |grep s_encoding_flags > s_encoding_flags [0x 2 : 2] > > Distro case: > > 2.1) Disable linear lookup: > mkfs.f2fs -f -O casefold -C utf8:hashonly /dev/vdb > dump.f2fs -d3 /dev/vdb |grep s_encoding_flags > s_encoding_flags [0x 2 : 2] > > 2.2) Enable linear lookup: > mkfs.f2fs -f -O casefold -C utf8:nohashonly /dev/vdb > dump.f2fs -d3 /dev/vdb |grep s_encoding_flags > s_encoding_flags [0x 0 : 0] > > 2.3) By default: > mkfs.f2fs -f -O casefold -C utf8 /dev/vdb > dump.f2fs -d3 /dev/vdb |grep s_encoding_flags > s_encoding_flags [0x 0 : 0] > > Signed-off-by: Chao Yu <ch...@ke...> > --- > v2: > - disable linear lookup by default for Android case > include/f2fs_fs.h | 3 ++- > lib/libf2fs.c | 1 + > man/mkfs.f2fs.8 | 10 ++++++++-- > mkfs/f2fs_format.c | 3 +++ > mkfs/f2fs_format_main.c | 3 ++- > 5 files changed, 16 insertions(+), 4 deletions(-) > > diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h > index f7268d1..a8da8fa 100644 > --- a/include/f2fs_fs.h > +++ b/include/f2fs_fs.h > @@ -1478,7 +1478,8 @@ enum { > > /* feature list in Android */ > enum { > - F2FS_FEATURE_NAT_BITS = 0x0001, > + F2FS_FEATURE_NAT_BITS = 0x0001, > + F2FS_FEATURE_LINEAR_LOOKUP = 0x0002, > }; > > /* nolinear lookup tune */ > diff --git a/lib/libf2fs.c b/lib/libf2fs.c > index 2f012c8..0e3e62a 100644 > --- a/lib/libf2fs.c > +++ b/lib/libf2fs.c > @@ -1424,6 +1424,7 @@ static const struct enc_flags { > char *param; > } encoding_flags[] = { > { F2FS_ENC_STRICT_MODE_FL, "strict" }, > + { F2FS_ENC_NO_COMPAT_FALLBACK_FL, "hashonly"} > }; > > /* Return a positive number < 0xff indicating the encoding magic number > diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8 > index 8b3b0cc..8cb7d32 100644 > --- a/man/mkfs.f2fs.8 > +++ b/man/mkfs.f2fs.8 > @@ -232,9 +232,15 @@ Use UTF-8 for casefolding. > .I flags: > .RS 1.2i > .TP 1.2i > -.B strict > +.B [no]strict > This flag specifies that invalid strings should be rejected by the filesystem. > -Default is disabled. > +For android case, it will disable linear lookup by default. > +.RE > +.RS 1.2i > +.TP 1.2i > +.B [no]hashonly > +This flag specifies that there is no linear lookup fallback during lookup. > +By default, linear lookup fallback is enabled. > .RE > .RE > .TP > diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c > index 2680bd3..a45bbcb 100644 > --- a/mkfs/f2fs_format.c > +++ b/mkfs/f2fs_format.c > @@ -671,6 +671,9 @@ static int f2fs_prepare_super_block(void) > memcpy(sb->init_version, c.version, VERSION_LEN); > > if (c.feature & F2FS_FEATURE_CASEFOLD) { > + if (!(c.s_encoding_flags & F2FS_ENC_NO_COMPAT_FALLBACK_FL) && > + (c.disabled_feature & F2FS_FEATURE_LINEAR_LOOKUP)) > + c.s_encoding_flags |= F2FS_ENC_NO_COMPAT_FALLBACK_FL; > set_sb(s_encoding, c.s_encoding); > set_sb(s_encoding_flags, c.s_encoding_flags); > } > diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c > index f0bec4f..8f8e975 100644 > --- a/mkfs/f2fs_format_main.c > +++ b/mkfs/f2fs_format_main.c > @@ -143,7 +143,8 @@ static void add_default_options(void) > force_overwrite = 1; > c.wanted_sector_size = F2FS_BLKSIZE; > c.root_uid = c.root_gid = 0; > - c.disabled_feature |= F2FS_FEATURE_NAT_BITS; > + c.disabled_feature |= F2FS_FEATURE_NAT_BITS | > + F2FS_FEATURE_LINEAR_LOOKUP; > > /* RO doesn't need any other features */ > if (c.feature & F2FS_FEATURE_RO) > -- > 2.49.0 > > > > _______________________________________________ > Linux-f2fs-devel mailing list > Lin...@li... > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel |
From: hanqi <ha...@vi...> - 2025-07-25 01:45:02
|
在 2025/7/24 21:09, Chao Yu 写道: > On 2025/7/16 16:27, hanqi wrote: >> >> >> 在 2025/7/16 11:43, Jens Axboe 写道: >>> On 7/15/25 9:34 PM, hanqi wrote: >>>> >>>> ? 2025/7/15 22:28, Jens Axboe ??: >>>>> On 7/14/25 9:10 PM, Qi Han wrote: >>>>>> Jens has already completed the development of uncached buffered I/O >>>>>> in git [1], and in f2fs, the feature can be enabled simply by >>>>>> setting >>>>>> the FOP_DONTCACHE flag in f2fs_file_operations. >>>>> You need to ensure that for any DONTCACHE IO that the completion is >>>>> routed via non-irq context, if applicable. I didn't verify that >>>>> this is >>>>> the case for f2fs. Generally you can deduce this as well through >>>>> testing, I'd say the following cases would be interesting to test: >>>>> >>>>> 1) Normal DONTCACHE buffered read >>>>> 2) Overwrite DONTCACHE buffered write >>>>> 3) Append DONTCACHE buffered write >>>>> >>>>> Test those with DEBUG_ATOMIC_SLEEP set in your config, and it that >>>>> doesn't complain, that's a great start. >>>>> >>>>> For the above test cases as well, verify that page cache doesn't >>>>> grow as >>>>> IO is performed. A bit is fine for things like meta data, but >>>>> generally >>>>> you want to see it remain basically flat in terms of page cache >>>>> usage. >>>>> >>>>> Maybe this is all fine, like I said I didn't verify. Just >>>>> mentioning it >>>>> for completeness sake. >>>> Hi, Jens >>>> Thanks for your suggestion. As I mentioned earlier in [1], in f2fs, >>>> the regular buffered write path invokes folio_end_writeback from a >>>> softirq context. Therefore, it seems that f2fs may not be suitable >>>> for DONTCACHE I/O writes. >>>> >>>> I?d like to ask a question: why is DONTCACHE I/O write restricted to >>>> non-interrupt context only? Is it because dropping the page might be >>>> too time-consuming to be done safely in interrupt context? This might >>>> be a naive question, but I?d really appreciate your clarification. >>>> Thanks in advance. >>> Because (as of right now, at least) the code doing the invalidation >>> needs process context. There are various reasons for this, which you'll >>> see if you follow the path off folio_end_writeback() -> >>> filemap_end_dropbehind_write() -> filemap_end_dropbehind() -> >>> folio_unmap_invalidate(). unmap_mapping_folio() is one case, and while >>> that may be doable, the inode i_lock is not IRQ safe. >>> >>> Most file systems have a need to punt some writeback completions to >>> non-irq context, eg for file extending etc. Hence for most file >>> systems, >>> the dontcache case just becomes another case that needs to go through >>> that path. >>> >>> It'd certainly be possible to improve upon this, for example by having >>> an opportunistic dontcache unmap from IRQ/soft-irq context, and then >>> punting to a workqueue if that doesn't pan out. But this doesn't exist >>> as of yet, hence the need for the workqueue punt. > > Thanks Jens for the detailed explanation. > >> >> Hi, Jens >> Thank you for your response. I tested uncached buffer I/O reads with >> a 50GB dataset on a local F2FS filesystem, and the page cache size >> only increased slightly, which I believe aligns with expectations. >> After clearing the page cache, the page cache size returned to its >> initial state. The test results are as follows: >> >> stat 50G.txt >> File: 50G.txt >> Size: 53687091200 Blocks: 104960712 IO Blocks: 512 >> regular file >> >> [read before]: >> echo 3 > /proc/sys/vm/drop_caches >> 01:48:17 kbmemfree kbavail kbmemused %memused >> kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty >> 01:50:59 6404648 8149508 2719384 23.40 512 1898092 >> 199384760 823.75 1846756 466832 44 >> >> ./uncached_io_test 8192 1 1 50G.txt >> Starting 1 threads >> reading bs 8192, uncached 1 >> 1s: 754MB/sec, MB=754 >> ... >> 64s: 844MB/sec, MB=262144 >> >> [read after]: >> 01:52:33 6326664 8121240 2747968 23.65 728 1947656 >> 199384788 823.75 1887896 502004 68 >> echo 3 > /proc/sys/vm/drop_caches >> 01:53:11 6351136 8096936 2772400 23.86 512 1900500 >> 199385216 823.75 1847252 533768 104 >> >> Hi Chao, >> Given that F2FS currently calls folio_end_writeback in the softirq >> context for normal write scenarios, could we first support uncached >> buffer I/O reads? For normal uncached buffer I/O writes, would it be >> feasible for F2FS to introduce an asynchronous workqueue to handle the >> page drop operation in the future? What are your thoughts on this? > > Qi, > > Sorry for the delay. > > I think it will be good to support uncached buffered I/O in read path > first, and then let's take a look what we can do for write path, anyway, > let's do this step by step. > > Can you please update the patch? > - support read path only > - include test data in commit message Chao I will re-submit a patch to first enable F2FS support for uncached buffer I/O reads. Following that, I will work on implementing asynchronous page dropping in F2FS. Thank you! > >> Thank you! >> >> |
From: Chao Yu <ch...@ke...> - 2025-07-25 00:59:40
|
It provides a way to disable linear lookup fallback during mkfs. Behavior summary: Android Distro By default disabled enabled Tune w/ [no]hashonly no yes Android case: 1.1) Disable linear lookup: mkfs.f2fs -f -g android -O casefold -C utf8:hashonly /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags s_encoding_flags [0x 2 : 2] 1.2) Enable linear lookup: mkfs.f2fs -f -g android -O casefold -C utf8:nohashonly /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags s_encoding_flags [0x 2 : 2] 1.3) By default: mkfs.f2fs -f -g android -O casefold -C utf8 /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags s_encoding_flags [0x 2 : 2] Distro case: 2.1) Disable linear lookup: mkfs.f2fs -f -O casefold -C utf8:hashonly /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags s_encoding_flags [0x 2 : 2] 2.2) Enable linear lookup: mkfs.f2fs -f -O casefold -C utf8:nohashonly /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags s_encoding_flags [0x 0 : 0] 2.3) By default: mkfs.f2fs -f -O casefold -C utf8 /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags s_encoding_flags [0x 0 : 0] Signed-off-by: Chao Yu <ch...@ke...> --- v2: - disable linear lookup by default for Android case include/f2fs_fs.h | 3 ++- lib/libf2fs.c | 1 + man/mkfs.f2fs.8 | 10 ++++++++-- mkfs/f2fs_format.c | 3 +++ mkfs/f2fs_format_main.c | 3 ++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index f7268d1..a8da8fa 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1478,7 +1478,8 @@ enum { /* feature list in Android */ enum { - F2FS_FEATURE_NAT_BITS = 0x0001, + F2FS_FEATURE_NAT_BITS = 0x0001, + F2FS_FEATURE_LINEAR_LOOKUP = 0x0002, }; /* nolinear lookup tune */ diff --git a/lib/libf2fs.c b/lib/libf2fs.c index 2f012c8..0e3e62a 100644 --- a/lib/libf2fs.c +++ b/lib/libf2fs.c @@ -1424,6 +1424,7 @@ static const struct enc_flags { char *param; } encoding_flags[] = { { F2FS_ENC_STRICT_MODE_FL, "strict" }, + { F2FS_ENC_NO_COMPAT_FALLBACK_FL, "hashonly"} }; /* Return a positive number < 0xff indicating the encoding magic number diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8 index 8b3b0cc..8cb7d32 100644 --- a/man/mkfs.f2fs.8 +++ b/man/mkfs.f2fs.8 @@ -232,9 +232,15 @@ Use UTF-8 for casefolding. .I flags: .RS 1.2i .TP 1.2i -.B strict +.B [no]strict This flag specifies that invalid strings should be rejected by the filesystem. -Default is disabled. +For android case, it will disable linear lookup by default. +.RE +.RS 1.2i +.TP 1.2i +.B [no]hashonly +This flag specifies that there is no linear lookup fallback during lookup. +By default, linear lookup fallback is enabled. .RE .RE .TP diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index 2680bd3..a45bbcb 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -671,6 +671,9 @@ static int f2fs_prepare_super_block(void) memcpy(sb->init_version, c.version, VERSION_LEN); if (c.feature & F2FS_FEATURE_CASEFOLD) { + if (!(c.s_encoding_flags & F2FS_ENC_NO_COMPAT_FALLBACK_FL) && + (c.disabled_feature & F2FS_FEATURE_LINEAR_LOOKUP)) + c.s_encoding_flags |= F2FS_ENC_NO_COMPAT_FALLBACK_FL; set_sb(s_encoding, c.s_encoding); set_sb(s_encoding_flags, c.s_encoding_flags); } diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c index f0bec4f..8f8e975 100644 --- a/mkfs/f2fs_format_main.c +++ b/mkfs/f2fs_format_main.c @@ -143,7 +143,8 @@ static void add_default_options(void) force_overwrite = 1; c.wanted_sector_size = F2FS_BLKSIZE; c.root_uid = c.root_gid = 0; - c.disabled_feature |= F2FS_FEATURE_NAT_BITS; + c.disabled_feature |= F2FS_FEATURE_NAT_BITS | + F2FS_FEATURE_LINEAR_LOOKUP; /* RO doesn't need any other features */ if (c.feature & F2FS_FEATURE_RO) -- 2.49.0 |
From: Daniel L. <ch...@go...> - 2025-07-24 23:28:50
|
Commit 84447ee7212e correctly relocated the zone alignment check to its proper location. However, this revealed that the original check's condition was incorrect for multi-device setups. This patch corrects the logic to check the alignment relative to the start of the segment0 and improves the error messages. Signed-off-by: Daniel Lee <ch...@go...> --- mkfs/f2fs_format.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index 2680bd3..18f6e34 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -339,17 +339,6 @@ static int f2fs_prepare_super_block(void) MSG(0, "Info: zone aligned segment0 blkaddr: %u\n", get_sb(segment0_blkaddr)); - if (c.zoned_mode && - ((c.ndevs == 1 && - (get_sb(segment0_blkaddr) + c.start_sector / - DEFAULT_SECTORS_PER_BLOCK) % c.zone_blocks) || - (c.ndevs > 1 && - c.devices[1].start_blkaddr % c.zone_blocks))) { - MSG(1, "\tError: Unaligned segment0 block address %u\n", - get_sb(segment0_blkaddr)); - return -1; - } - for (i = 0; i < c.ndevs; i++) { if (i == 0) { c.devices[i].total_segments = @@ -390,6 +379,33 @@ static int f2fs_prepare_super_block(void) c.total_segments += c.devices[i].total_segments; } + + if (c.zoned_mode) { + if (c.ndevs == 1 && + (get_sb(segment0_blkaddr) + c.start_sector / + DEFAULT_SECTORS_PER_BLOCK) % c.zone_blocks) { + /* + * With a sole zoned LU, segment0 start should be + * aligned at the zone. + */ + MSG(1, "\tError: Unaligned segment0 start (%u) for zoned LU (zone_blocks: %lu)\n", + get_sb(segment0_blkaddr), c.zone_blocks); + return -1; + } else if (c.ndevs > 1 && + (c.devices[1].start_blkaddr - get_sb(segment0_blkaddr)) % c.zone_blocks) { + /* + * With the first device as a conventional LU and the + * second as a zoned LU, the start address for the zoned + * LU should be aligned to the zone size, starting from + * segment0. + */ + MSG(1, "\tError: Unaligned start (%lu) for zoned LU from segment0 (%u) (zone_blocks: %lu)\n", + c.devices[1].start_blkaddr, + get_sb(segment0_blkaddr), c.zone_blocks); + return -1; + } + } + set_sb(segment_count, c.total_segments); set_sb(segment_count_ckpt, F2FS_NUMBER_OF_CHECKPOINT_PACK); -- 2.50.1.552.g942d659e1b-goog |
From: <pat...@ke...> - 2025-07-24 20:30:07
|
Hello: This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <ja...@ke...>: On Thu, 24 Jul 2025 17:31:15 +0200 you wrote: > When testing F2FS with xfstests using UFS backed virtual disks the > kernel complains sometimes that f2fs_release_decomp_mem() calls > vm_unmap_ram() from an invalid context. Example trace from > f2fs/007 test: > > f2fs/007 5s ... [12:59:38][ 8.902525] run fstests f2fs/007 > [ 11.468026] BUG: sleeping function called from invalid context at mm/vmalloc.c:2978 > [ 11.471849] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 68, name: irq/22-ufshcd > [ 11.475357] preempt_count: 1, expected: 0 > [ 11.476970] RCU nest depth: 0, expected: 0 > [ 11.478531] CPU: 0 UID: 0 PID: 68 Comm: irq/22-ufshcd Tainted: G W 6.16.0-rc5-xfstests-ufs-g40f92e79b0aa #9 PREEMPT(none) > [ 11.478535] Tainted: [W]=WARN > [ 11.478536] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 > [ 11.478537] Call Trace: > [ 11.478543] <TASK> > [ 11.478545] dump_stack_lvl+0x4e/0x70 > [ 11.478554] __might_resched.cold+0xaf/0xbe > [ 11.478557] vm_unmap_ram+0x21/0xb0 > [ 11.478560] f2fs_release_decomp_mem+0x59/0x80 > [ 11.478563] f2fs_free_dic+0x18/0x1a0 > [ 11.478565] f2fs_finish_read_bio+0xd7/0x290 > [ 11.478570] blk_update_request+0xec/0x3b0 > [ 11.478574] ? sbitmap_queue_clear+0x3b/0x60 > [ 11.478576] scsi_end_request+0x27/0x1a0 > [ 11.478582] scsi_io_completion+0x40/0x300 > [ 11.478583] ufshcd_mcq_poll_cqe_lock+0xa3/0xe0 > [ 11.478588] ufshcd_sl_intr+0x194/0x1f0 > [ 11.478592] ufshcd_threaded_intr+0x68/0xb0 > [ 11.478594] ? __pfx_irq_thread_fn+0x10/0x10 > [ 11.478599] irq_thread_fn+0x20/0x60 > [ 11.478602] ? __pfx_irq_thread_fn+0x10/0x10 > [ 11.478603] irq_thread+0xb9/0x180 > [ 11.478605] ? __pfx_irq_thread_dtor+0x10/0x10 > [ 11.478607] ? __pfx_irq_thread+0x10/0x10 > [ 11.478609] kthread+0x10a/0x230 > [ 11.478614] ? __pfx_kthread+0x10/0x10 > [ 11.478615] ret_from_fork+0x7e/0xd0 > [ 11.478619] ? __pfx_kthread+0x10/0x10 > [ 11.478621] ret_from_fork_asm+0x1a/0x30 > [ 11.478623] </TASK> > > [...] Here is the summary with links: - [f2fs-dev,v2] f2fs: vm_unmap_ram() may be called from an invalid context https://git.kernel.org/jaegeuk/f2fs/c/08a7efc5b02a You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html |
From: <pat...@ke...> - 2025-07-24 20:30:06
|
Hello: This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <ja...@ke...>: On Fri, 18 Jul 2025 15:04:31 -0700 you wrote: > From: Daeho Jeong <dae...@go...> > > Otherwise F2FS will not do GC in background in low free section. > > Signed-off-by: Daeho Jeong <dae...@go...> > --- > fs/f2fs/gc.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) Here is the summary with links: - [f2fs-dev] f2fs: ignore valid ratio when free section count is low https://git.kernel.org/jaegeuk/f2fs/c/e6d5e789c3b2 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html |
From: <pat...@ke...> - 2025-07-24 20:30:03
|
Hello: This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <ja...@ke...>: On Wed, 23 Jul 2025 22:58:37 +0800 you wrote: > No functional changes. > > Signed-off-by: mason.zhang <mas...@gm...> > --- > fs/f2fs/gc.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) Here is the summary with links: - [f2fs-dev] f2fs: merge the two conditions to avoid code duplication https://git.kernel.org/jaegeuk/f2fs/c/b93bf64e349b You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html |
From: <pat...@ke...> - 2025-07-24 20:30:00
|
Hello: This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <ja...@ke...>: On Wed, 23 Jul 2025 22:24:56 +0800 you wrote: > From: Sheng Yong <she...@xi...> > > There is no extra work before trace_f2fs_[dataread|datawrite]_end(), > so there is no need to check trace_<tracepoint>_enabled(). > > Signed-off-by: Sheng Yong <she...@xi...> > > [...] Here is the summary with links: - [f2fs-dev] f2fs: remove unnecessary tracepoint enabled check https://git.kernel.org/jaegeuk/f2fs/c/95d7c508b212 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html |
From: <pat...@ke...> - 2025-07-24 20:30:00
|
Hello: The following patches were marked "accepted", because they were applied to jaegeuk/f2fs.git (dev): Patch: [f2fs-dev] f2fs: remove unnecessary tracepoint enabled check Submitter: Sheng Yong <she...@gm...> Committer: Jaegeuk Kim <ja...@ke...> Patchwork: https://patchwork.kernel.org/project/f2fs/list/?series=985162 Lore link: https://lore.kernel.org/r/202...@xi... Patch: [f2fs-dev] f2fs: don't break allocation when crossing contiguous sections Submitter: Chao Yu <ch...@ke...> Committer: Jaegeuk Kim <ja...@ke...> Patchwork: https://patchwork.kernel.org/project/f2fs/list/?series=984143 Lore link: https://lore.kernel.org/r/202...@ke... Patch: [f2fs-dev] f2fs: merge the two conditions to avoid code duplication Submitter: mason.zhang <mas...@gm...> Committer: Jaegeuk Kim <ja...@ke...> Patchwork: https://patchwork.kernel.org/project/f2fs/list/?series=985175 Lore link: https://lore.kernel.org/r/202...@gm... Patch: [f2fs-dev,v3] f2fs: zone: wait for inflight dio completion, excluding pinned files read using dio Submitter: yohan.joung <yoh...@sk...> Committer: Jaegeuk Kim <ja...@ke...> Patchwork: https://patchwork.kernel.org/project/f2fs/list/?series=984548 Lore link: https://lore.kernel.org/r/202...@sk... Patch: [f2fs-dev] f2fs: ignore valid ratio when free section count is low Submitter: Daeho Jeong <da...@gm...> Committer: Jaegeuk Kim <ja...@ke...> Patchwork: https://patchwork.kernel.org/project/f2fs/list/?series=983893 Lore link: https://lore.kernel.org/r/202...@gm... Patch: [f2fs-dev,v2] f2fs: vm_unmap_ram() may be called from an invalid context Submitter: Jan Prusakowski <jpr...@go...> Committer: Jaegeuk Kim <ja...@ke...> Patchwork: https://patchwork.kernel.org/project/f2fs/list/?series=985638 Lore link: https://lore.kernel.org/r/202...@go... Total patches: 6 -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html |
From: <pat...@ke...> - 2025-07-24 20:29:59
|
Hello: This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <ja...@ke...>: On Tue, 22 Jul 2025 15:02:40 +0900 you wrote: > read for the pinfile using Direct I/O do not wait for dio write. > > Signed-off-by: yohan.joung <yoh...@sk...> > --- > fs/f2fs/file.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) Here is the summary with links: - [f2fs-dev,v3] f2fs: zone: wait for inflight dio completion, excluding pinned files read using dio https://git.kernel.org/jaegeuk/f2fs/c/3bf1bab503a5 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html |
From: <pat...@ke...> - 2025-07-24 20:29:57
|
Hello: This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <ja...@ke...>: On Mon, 21 Jul 2025 10:02:31 +0800 you wrote: > Commit 0638a3197c19 ("f2fs: avoid unused block when dio write in LFS > mode") has fixed unused block issue for dio write in lfs mode. > > However, f2fs_map_blocks() may break and return smaller extent when > last allocated block locates in the end of section, even allocator > can allocate contiguous blocks across sections. > > [...] Here is the summary with links: - [f2fs-dev] f2fs: don't break allocation when crossing contiguous sections https://git.kernel.org/jaegeuk/f2fs/c/f0a7adfedcc8 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html |
From: mason.zhang <mas...@gm...> - 2025-07-24 15:59:56
|
Otherwise, the filesystem may unaware of potential file corruption. Signed-off-by: mason.zhang <mas...@gm...> --- fs/f2fs/segment.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index ae1223ef648f..ce80ba226aed 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3936,12 +3936,15 @@ static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio) int seg_type = log_type_to_seg_type(type); bool keep_order = (f2fs_lfs_mode(fio->sbi) && seg_type == CURSEG_COLD_DATA); + int err; if (keep_order) f2fs_down_read(&fio->sbi->io_order_lock); - if (f2fs_allocate_data_block(fio->sbi, fio->page, fio->old_blkaddr, - &fio->new_blkaddr, sum, type, fio)) { + err = f2fs_allocate_data_block(fio->sbi, fio->page, fio->old_blkaddr, + &fio->new_blkaddr, sum, type, fio); + if (unlikely(err)) { + f2fs_err(fio->sbi, "Failed to allocate data block(%d)", err); if (fscrypt_inode_uses_fs_layer_crypto(folio->mapping->host)) fscrypt_finalize_bounce_page(&fio->encrypted_page); folio_end_writeback(folio); -- 2.50.0 |
From: Chao Yu <ch...@ke...> - 2025-07-24 15:55:59
|
On 7/24/2025 11:06 PM, Jaegeuk Kim wrote: > Can we disable linear lookup by default, but add an option to enable it? Sure. > > On 07/24, Chao Yu wrote: >> It provides a way to disable linear lookup fallback during mkfs. >> >> Usage: >> >> 1. Disable linear lookup: >> mkfs.f2fs -f -O casefold -C utf8:hashonly /dev/vdb >> dump.f2fs -d3 /dev/vdb |grep s_encoding_flags >> s_encoding_flags [0x 2 : 2] >> >> 2. Enable linear lookup: >> mkfs.f2fs -f -O casefold -C utf8:nohashonly /dev/vdb >> dump.f2fs -d3 /dev/vdb |grep s_encoding_flags >> s_encoding_flags [0x 0 : 0] >> >> mkfs.f2fs -f -O casefold -C utf8 /dev/vdb >> dump.f2fs -d3 /dev/vdb |grep s_encoding_flags >> s_encoding_flags [0x 0 : 0] Let me update the logic to disable linear lookup by default for case 2.2). 1) mkfs.f2fs -f -O casefold -C utf8:hashonly /dev/vdb 2.1) mkfs.f2fs -f -O casefold -C utf8:nohashonly /dev/vdb 2.2) mkfs.f2fs -f -O casefold -C utf8 /dev/vdb Thanks, >> >> Signed-off-by: Chao Yu <ch...@ke...> >> --- >> lib/libf2fs.c | 1 + >> man/mkfs.f2fs.8 | 8 +++++++- >> 2 files changed, 8 insertions(+), 1 deletion(-) >> >> diff --git a/lib/libf2fs.c b/lib/libf2fs.c >> index 2f012c8..0e3e62a 100644 >> --- a/lib/libf2fs.c >> +++ b/lib/libf2fs.c >> @@ -1424,6 +1424,7 @@ static const struct enc_flags { >> char *param; >> } encoding_flags[] = { >> { F2FS_ENC_STRICT_MODE_FL, "strict" }, >> + { F2FS_ENC_NO_COMPAT_FALLBACK_FL, "hashonly"} >> }; >> >> /* Return a positive number < 0xff indicating the encoding magic number >> diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8 >> index 8b3b0cc..b57f033 100644 >> --- a/man/mkfs.f2fs.8 >> +++ b/man/mkfs.f2fs.8 >> @@ -232,10 +232,16 @@ Use UTF-8 for casefolding. >> .I flags: >> .RS 1.2i >> .TP 1.2i >> -.B strict >> +.B [no]strict >> This flag specifies that invalid strings should be rejected by the filesystem. >> Default is disabled. >> .RE >> +.RS 1.2i >> +.TP 1.2i >> +.B [no]hashonly >> +This flag specifies that there is no linear lookup fallback during lookup. >> +By default, linear lookup fallback is enabled. >> +.RE >> .RE >> .TP >> .BI \-q >> -- >> 2.49.0 |
From: Jan P. <jpr...@go...> - 2025-07-24 15:31:32
|
When testing F2FS with xfstests using UFS backed virtual disks the kernel complains sometimes that f2fs_release_decomp_mem() calls vm_unmap_ram() from an invalid context. Example trace from f2fs/007 test: f2fs/007 5s ... [12:59:38][ 8.902525] run fstests f2fs/007 [ 11.468026] BUG: sleeping function called from invalid context at mm/vmalloc.c:2978 [ 11.471849] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 68, name: irq/22-ufshcd [ 11.475357] preempt_count: 1, expected: 0 [ 11.476970] RCU nest depth: 0, expected: 0 [ 11.478531] CPU: 0 UID: 0 PID: 68 Comm: irq/22-ufshcd Tainted: G W 6.16.0-rc5-xfstests-ufs-g40f92e79b0aa #9 PREEMPT(none) [ 11.478535] Tainted: [W]=WARN [ 11.478536] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 11.478537] Call Trace: [ 11.478543] <TASK> [ 11.478545] dump_stack_lvl+0x4e/0x70 [ 11.478554] __might_resched.cold+0xaf/0xbe [ 11.478557] vm_unmap_ram+0x21/0xb0 [ 11.478560] f2fs_release_decomp_mem+0x59/0x80 [ 11.478563] f2fs_free_dic+0x18/0x1a0 [ 11.478565] f2fs_finish_read_bio+0xd7/0x290 [ 11.478570] blk_update_request+0xec/0x3b0 [ 11.478574] ? sbitmap_queue_clear+0x3b/0x60 [ 11.478576] scsi_end_request+0x27/0x1a0 [ 11.478582] scsi_io_completion+0x40/0x300 [ 11.478583] ufshcd_mcq_poll_cqe_lock+0xa3/0xe0 [ 11.478588] ufshcd_sl_intr+0x194/0x1f0 [ 11.478592] ufshcd_threaded_intr+0x68/0xb0 [ 11.478594] ? __pfx_irq_thread_fn+0x10/0x10 [ 11.478599] irq_thread_fn+0x20/0x60 [ 11.478602] ? __pfx_irq_thread_fn+0x10/0x10 [ 11.478603] irq_thread+0xb9/0x180 [ 11.478605] ? __pfx_irq_thread_dtor+0x10/0x10 [ 11.478607] ? __pfx_irq_thread+0x10/0x10 [ 11.478609] kthread+0x10a/0x230 [ 11.478614] ? __pfx_kthread+0x10/0x10 [ 11.478615] ret_from_fork+0x7e/0xd0 [ 11.478619] ? __pfx_kthread+0x10/0x10 [ 11.478621] ret_from_fork_asm+0x1a/0x30 [ 11.478623] </TASK> This patch modifies in_task() check inside f2fs_read_end_io() to also check if interrupts are disabled. This ensures that pages are unmapped asynchronously in an interrupt handler. Fixes: bff139b49d9f ("f2fs: handle decompress only post processing in softirq") Signed-off-by: Jan Prusakowski <jpr...@go...> Reviewed-by: Chao Yu <ch...@ke...> --- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index d1a2616d41be..0acc25f996b3 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -280,7 +280,7 @@ static void f2fs_read_end_io(struct bio *bio) { struct f2fs_sb_info *sbi = F2FS_F_SB(bio_first_folio_all(bio)); struct bio_post_read_ctx *ctx; - bool intask = in_task(); + bool intask = in_task() && !irqs_disabled(); iostat_update_and_unbind_ctx(bio); ctx = bio->bi_private; -- 2.50.1.487.gc89ff58d15-goog |
From: Jaegeuk K. <ja...@ke...> - 2025-07-24 15:06:42
|
Can we disable linear lookup by default, but add an option to enable it? On 07/24, Chao Yu wrote: > It provides a way to disable linear lookup fallback during mkfs. > > Usage: > > 1. Disable linear lookup: > mkfs.f2fs -f -O casefold -C utf8:hashonly /dev/vdb > dump.f2fs -d3 /dev/vdb |grep s_encoding_flags > s_encoding_flags [0x 2 : 2] > > 2. Enable linear lookup: > mkfs.f2fs -f -O casefold -C utf8:nohashonly /dev/vdb > dump.f2fs -d3 /dev/vdb |grep s_encoding_flags > s_encoding_flags [0x 0 : 0] > > mkfs.f2fs -f -O casefold -C utf8 /dev/vdb > dump.f2fs -d3 /dev/vdb |grep s_encoding_flags > s_encoding_flags [0x 0 : 0] > > Signed-off-by: Chao Yu <ch...@ke...> > --- > lib/libf2fs.c | 1 + > man/mkfs.f2fs.8 | 8 +++++++- > 2 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/lib/libf2fs.c b/lib/libf2fs.c > index 2f012c8..0e3e62a 100644 > --- a/lib/libf2fs.c > +++ b/lib/libf2fs.c > @@ -1424,6 +1424,7 @@ static const struct enc_flags { > char *param; > } encoding_flags[] = { > { F2FS_ENC_STRICT_MODE_FL, "strict" }, > + { F2FS_ENC_NO_COMPAT_FALLBACK_FL, "hashonly"} > }; > > /* Return a positive number < 0xff indicating the encoding magic number > diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8 > index 8b3b0cc..b57f033 100644 > --- a/man/mkfs.f2fs.8 > +++ b/man/mkfs.f2fs.8 > @@ -232,10 +232,16 @@ Use UTF-8 for casefolding. > .I flags: > .RS 1.2i > .TP 1.2i > -.B strict > +.B [no]strict > This flag specifies that invalid strings should be rejected by the filesystem. > Default is disabled. > .RE > +.RS 1.2i > +.TP 1.2i > +.B [no]hashonly > +This flag specifies that there is no linear lookup fallback during lookup. > +By default, linear lookup fallback is enabled. > +.RE > .RE > .TP > .BI \-q > -- > 2.49.0 |
From: Chao Yu <ch...@ke...> - 2025-07-24 13:09:48
|
On 2025/7/16 16:27, hanqi wrote: > > > 在 2025/7/16 11:43, Jens Axboe 写道: >> On 7/15/25 9:34 PM, hanqi wrote: >>> >>> ? 2025/7/15 22:28, Jens Axboe ??: >>>> On 7/14/25 9:10 PM, Qi Han wrote: >>>>> Jens has already completed the development of uncached buffered I/O >>>>> in git [1], and in f2fs, the feature can be enabled simply by setting >>>>> the FOP_DONTCACHE flag in f2fs_file_operations. >>>> You need to ensure that for any DONTCACHE IO that the completion is >>>> routed via non-irq context, if applicable. I didn't verify that this is >>>> the case for f2fs. Generally you can deduce this as well through >>>> testing, I'd say the following cases would be interesting to test: >>>> >>>> 1) Normal DONTCACHE buffered read >>>> 2) Overwrite DONTCACHE buffered write >>>> 3) Append DONTCACHE buffered write >>>> >>>> Test those with DEBUG_ATOMIC_SLEEP set in your config, and it that >>>> doesn't complain, that's a great start. >>>> >>>> For the above test cases as well, verify that page cache doesn't grow as >>>> IO is performed. A bit is fine for things like meta data, but generally >>>> you want to see it remain basically flat in terms of page cache usage. >>>> >>>> Maybe this is all fine, like I said I didn't verify. Just mentioning it >>>> for completeness sake. >>> Hi, Jens >>> Thanks for your suggestion. As I mentioned earlier in [1], in f2fs, >>> the regular buffered write path invokes folio_end_writeback from a >>> softirq context. Therefore, it seems that f2fs may not be suitable >>> for DONTCACHE I/O writes. >>> >>> I?d like to ask a question: why is DONTCACHE I/O write restricted to >>> non-interrupt context only? Is it because dropping the page might be >>> too time-consuming to be done safely in interrupt context? This might >>> be a naive question, but I?d really appreciate your clarification. >>> Thanks in advance. >> Because (as of right now, at least) the code doing the invalidation >> needs process context. There are various reasons for this, which you'll >> see if you follow the path off folio_end_writeback() -> >> filemap_end_dropbehind_write() -> filemap_end_dropbehind() -> >> folio_unmap_invalidate(). unmap_mapping_folio() is one case, and while >> that may be doable, the inode i_lock is not IRQ safe. >> >> Most file systems have a need to punt some writeback completions to >> non-irq context, eg for file extending etc. Hence for most file systems, >> the dontcache case just becomes another case that needs to go through >> that path. >> >> It'd certainly be possible to improve upon this, for example by having >> an opportunistic dontcache unmap from IRQ/soft-irq context, and then >> punting to a workqueue if that doesn't pan out. But this doesn't exist >> as of yet, hence the need for the workqueue punt. Thanks Jens for the detailed explanation. > > Hi, Jens > Thank you for your response. I tested uncached buffer I/O reads with > a 50GB dataset on a local F2FS filesystem, and the page cache size > only increased slightly, which I believe aligns with expectations. > After clearing the page cache, the page cache size returned to its > initial state. The test results are as follows: > > stat 50G.txt > File: 50G.txt > Size: 53687091200 Blocks: 104960712 IO Blocks: 512 regular file > > [read before]: > echo 3 > /proc/sys/vm/drop_caches > 01:48:17 kbmemfree kbavail kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty > 01:50:59 6404648 8149508 2719384 23.40 512 1898092 199384760 823.75 1846756 466832 44 > > ./uncached_io_test 8192 1 1 50G.txt > Starting 1 threads > reading bs 8192, uncached 1 > 1s: 754MB/sec, MB=754 > ... > 64s: 844MB/sec, MB=262144 > > [read after]: > 01:52:33 6326664 8121240 2747968 23.65 728 1947656 199384788 823.75 1887896 502004 68 > echo 3 > /proc/sys/vm/drop_caches > 01:53:11 6351136 8096936 2772400 23.86 512 1900500 199385216 823.75 1847252 533768 104 > > Hi Chao, > Given that F2FS currently calls folio_end_writeback in the softirq > context for normal write scenarios, could we first support uncached > buffer I/O reads? For normal uncached buffer I/O writes, would it be > feasible for F2FS to introduce an asynchronous workqueue to handle the > page drop operation in the future? What are your thoughts on this? Qi, Sorry for the delay. I think it will be good to support uncached buffered I/O in read path first, and then let's take a look what we can do for write path, anyway, let's do this step by step. Can you please update the patch? - support read path only - include test data in commit message > Thank you! > > |
From: Chao Yu <ch...@ke...> - 2025-07-24 12:51:11
|
Jan, On 2025/7/24 18:30, Jan Prusakowski via Linux-f2fs-devel wrote: > When testing F2FS with xfstests using UFS backed virtual disks the > kernel complains sometimes that f2fs_release_decomp_mem() calls > vm_unmap_ram() from an invalid context. It will be better to include testcase & crash information in commit message. > > This patch modifies in_task() check inside f2fs_read_end_io() to also > check if interrupts are disabled. This ensures that pages are unmapped > asynchronously in an interrupt handler. > > Fixes: bff139b (f2fs: handle decompress only post processing in softirq) ./scripts/checkpatch.pl will output below warning message: WARNING: Please use correct Fixes: style 'Fixes: <12+ chars of sha1> ("<title line>")' - ie: 'Fixes: bff139b49d9f ("f2fs: handle decompress only post processing in softirq")' Please use this instead: Fixes: bff139b49d9f ("f2fs: handle decompress only post processing in softirq") > > Signed-off-by: Jan Prusakowski <jpr...@go...> Code part looks good to me, please feel free to add my RVB tag in next version: Reviewed-by: Chao Yu <ch...@ke...> Thanks, > --- > fs/f2fs/data.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index d1a2616d41be..0acc25f996b3 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -280,7 +280,7 @@ static void f2fs_read_end_io(struct bio *bio) > { > struct f2fs_sb_info *sbi = F2FS_F_SB(bio_first_folio_all(bio)); > struct bio_post_read_ctx *ctx; > - bool intask = in_task(); > + bool intask = in_task() && !irqs_disabled(); > > iostat_update_and_unbind_ctx(bio); > ctx = bio->bi_private; |
From: Jan P. <jpr...@go...> - 2025-07-24 10:38:33
|
When testing F2FS with xfstests using UFS backed virtual disks the kernel complains sometimes that f2fs_release_decomp_mem() calls vm_unmap_ram() from an invalid context. This patch modifies in_task() check inside f2fs_read_end_io() to also check if interrupts are disabled. This ensures that pages are unmapped asynchronously in an interrupt handler. Fixes: bff139b (f2fs: handle decompress only post processing in softirq) Signed-off-by: Jan Prusakowski <jpr...@go...> --- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index d1a2616d41be..0acc25f996b3 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -280,7 +280,7 @@ static void f2fs_read_end_io(struct bio *bio) { struct f2fs_sb_info *sbi = F2FS_F_SB(bio_first_folio_all(bio)); struct bio_post_read_ctx *ctx; - bool intask = in_task(); + bool intask = in_task() && !irqs_disabled(); iostat_update_and_unbind_ctx(bio); ctx = bio->bi_private; -- 2.50.0.727.gbf7dc18ff4-goog |
From: Lee J. <le...@ke...> - 2025-07-24 10:18:32
|
On Wed, 23 Jul 2025, Greg Kroah-Hartman wrote: > On Wed, Jul 23, 2025 at 09:26:39AM +0100, Lee Jones wrote: > > On Wed, 02 Jul 2025, Greg Kroah-Hartman wrote: > > > > > On Tue, Jun 24, 2025 at 11:00:39AM +0100, Lee Jones wrote: > > > > On Wed, 16 Apr 2025, Chao Yu wrote: > > > > > > > > > This patch adds a new sysfs entry /sys/fs/f2fs/<disk>/encoding_flags, > > > > > it is a read-only entry to show the value of sb.s_encoding_flags, the > > > > > value is hexadecimal. > > > > > > > > > > =========================== ========== > > > > > Flag_Name Flag_Value > > > > > =========================== ========== > > > > > SB_ENC_STRICT_MODE_FL 0x00000001 > > > > > SB_ENC_NO_COMPAT_FALLBACK_FL 0x00000002 > > > > > =========================== ========== > > > > > > > > > > case#1 > > > > > mkfs.f2fs -f -O casefold -C utf8:strict /dev/vda > > > > > mount /dev/vda /mnt/f2fs > > > > > cat /sys/fs/f2fs/vda/encoding_flags > > > > > 1 > > > > > > > > > > case#2 > > > > > mkfs.f2fs -f -O casefold -C utf8 /dev/vda > > > > > fsck.f2fs --nolinear-lookup=1 /dev/vda > > > > > mount /dev/vda /mnt/f2fs > > > > > cat /sys/fs/f2fs/vda/encoding_flags > > > > > 2 > > > > > > > > > > Signed-off-by: Chao Yu <ch...@ke...> > > > > > --- > > > > > Documentation/ABI/testing/sysfs-fs-f2fs | 13 +++++++++++++ > > > > > fs/f2fs/sysfs.c | 9 +++++++++ > > > > > 2 files changed, 22 insertions(+) > > > > > > > > This patch, commit 617e0491abe4 ("f2fs: sysfs: export linear_lookup in > > > > features directory") upstream, needs to find its way into all Stable > > > > branches containing upstream commit 91b587ba79e1 ("f2fs: Introduce > > > > linear search for dentries"), which is essentially linux-5.15.y and > > > > newer. > > > > > > > > stable/linux-5.4.y: > > > > MISSING: f2fs: Introduce linear search for dentries > > > > MISSING: f2fs: sysfs: export linear_lookup in features directory > > > > > > > > stable/linux-5.10.y: > > > > MISSING: f2fs: Introduce linear search for dentries > > > > MISSING: f2fs: sysfs: export linear_lookup in features directory > > > > > > > > stable/linux-5.15.y: > > > > b0938ffd39ae f2fs: Introduce linear search for dentries [5.15.179] > > > > MISSING: f2fs: sysfs: export linear_lookup in features directory > > > > > > > > stable/linux-6.1.y: > > > > de605097eb17 f2fs: Introduce linear search for dentries [6.1.129] > > > > MISSING: f2fs: sysfs: export linear_lookup in features directory > > > > > > > > stable/linux-6.6.y: > > > > 0bf2adad03e1 f2fs: Introduce linear search for dentries [6.6.76] > > > > MISSING: f2fs: sysfs: export linear_lookup in features directory > > > > > > > > stable/linux-6.12.y: > > > > 00d1943fe46d f2fs: Introduce linear search for dentries [6.12.13] > > > > MISSING: f2fs: sysfs: export linear_lookup in features directory > > > > > > > > mainline: > > > > 91b587ba79e1 f2fs: Introduce linear search for dentries > > > > 617e0491abe4 f2fs: sysfs: export linear_lookup in features directory > > > > > > Great, then can someone submit these in a format we can apply them in? > > > or do clean cherry-picks work properly? > > > > Does this work: > > > > Please backport upstream commit: > > > > 617e0491abe4 f2fs: sysfs: export linear_lookup in features directory > > > > ... to all stable branches up to and including linux-5.15.y. > > > > If there are conflicts, I can do the backport myself and submit as patches. > > There are conflicts, it doesn't apply to 6.1.y or 5.15.y :( Okay, thanks for trying. Leave it with me. -- Lee Jones [李琼斯] |
From: Chao Yu <ch...@ke...> - 2025-07-24 08:27:10
|
On 7/22/25 22:36, wangzijie wrote: > When we need to alloc nat entry and set it dirty, we can directly add it to > dirty set list(or initialize its list_head for new_ne) instead of adding it > to clean list and make a move. Introduce init_dirty flag to do it. > > Signed-off-by: wangzijie <wan...@ho...> > --- > fs/f2fs/node.c | 37 ++++++++++++++++++++++++++++++------- > 1 file changed, 30 insertions(+), 7 deletions(-) > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > index a23db6238..20bcf8559 100644 > --- a/fs/f2fs/node.c > +++ b/fs/f2fs/node.c > @@ -185,7 +185,7 @@ static void __free_nat_entry(struct nat_entry *e) > > /* must be locked by nat_tree_lock */ > static struct nat_entry *__init_nat_entry(struct f2fs_nm_info *nm_i, > - struct nat_entry *ne, struct f2fs_nat_entry *raw_ne, bool no_fail) > + struct nat_entry *ne, struct f2fs_nat_entry *raw_ne, bool no_fail, bool init_dirty) > { > if (no_fail) > f2fs_radix_tree_insert(&nm_i->nat_root, nat_get_nid(ne), ne); > @@ -195,6 +195,11 @@ static struct nat_entry *__init_nat_entry(struct f2fs_nm_info *nm_i, > if (raw_ne) > node_info_from_raw_nat(&ne->ni, raw_ne); > > + if (init_dirty) { > + nm_i->nat_cnt[TOTAL_NAT]++; > + return ne; > + } > + > spin_lock(&nm_i->nat_list_lock); > list_add_tail(&ne->list, &nm_i->nat_entries); > spin_unlock(&nm_i->nat_list_lock); > @@ -256,7 +261,7 @@ static struct nat_entry_set *__grab_nat_entry_set(struct f2fs_nm_info *nm_i, > } > > static void __set_nat_cache_dirty(struct f2fs_nm_info *nm_i, > - struct nat_entry *ne) > + struct nat_entry *ne, bool init_dirty) > { > struct nat_entry_set *head; > bool new_ne = nat_get_blkaddr(ne) == NEW_ADDR; > @@ -275,6 +280,18 @@ static void __set_nat_cache_dirty(struct f2fs_nm_info *nm_i, > > set_nat_flag(ne, IS_PREALLOC, new_ne); > > + if (init_dirty) { > + nm_i->nat_cnt[DIRTY_NAT]++; > + set_nat_flag(ne, IS_DIRTY, true); > + spin_lock(&nm_i->nat_list_lock); > + if (new_ne) > + INIT_LIST_HEAD(&ne->list); > + else > + list_add_tail(&ne->list, &head->entry_list); > + spin_unlock(&nm_i->nat_list_lock); > + return; > + } Nit issue, above blanks should be replaced w/ tab. Can we clean up like this? diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index de99b42437c6..60fc2c7b8e10 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -280,30 +280,23 @@ static void __set_nat_cache_dirty(struct f2fs_nm_info *nm_i, set_nat_flag(ne, IS_PREALLOC, new_ne); - if (init_dirty) { - nm_i->nat_cnt[DIRTY_NAT]++; - set_nat_flag(ne, IS_DIRTY, true); - spin_lock(&nm_i->nat_list_lock); - if (new_ne) - INIT_LIST_HEAD(&ne->list); - else - list_add_tail(&ne->list, &head->entry_list); - spin_unlock(&nm_i->nat_list_lock); - return; - } - if (get_nat_flag(ne, IS_DIRTY)) goto refresh_list; nm_i->nat_cnt[DIRTY_NAT]++; - nm_i->nat_cnt[RECLAIMABLE_NAT]--; + if (!init_dirty) + nm_i->nat_cnt[RECLAIMABLE_NAT]--; set_nat_flag(ne, IS_DIRTY, true); refresh_list: spin_lock(&nm_i->nat_list_lock); - if (new_ne) - list_del_init(&ne->list); - else + if (new_ne) { + if (init_dirty) + INIT_LIST_HEAD(&ne->list); + else + list_del_init(&ne->list); + } else { list_move_tail(&ne->list, &head->entry_list); + } spin_unlock(&nm_i->nat_list_lock); } Thanks, > + > if (get_nat_flag(ne, IS_DIRTY)) > goto refresh_list; > > @@ -441,7 +458,7 @@ static void cache_nat_entry(struct f2fs_sb_info *sbi, nid_t nid, > f2fs_down_write(&nm_i->nat_tree_lock); > e = __lookup_nat_cache(nm_i, nid, false); > if (!e) > - e = __init_nat_entry(nm_i, new, ne, false); > + e = __init_nat_entry(nm_i, new, ne, false, false); > else > f2fs_bug_on(sbi, nat_get_ino(e) != le32_to_cpu(ne->ino) || > nat_get_blkaddr(e) != > @@ -458,11 +475,13 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni, > struct f2fs_nm_info *nm_i = NM_I(sbi); > struct nat_entry *e; > struct nat_entry *new = __alloc_nat_entry(sbi, ni->nid, true); > + bool init_dirty = false; > > f2fs_down_write(&nm_i->nat_tree_lock); > e = __lookup_nat_cache(nm_i, ni->nid, true); > if (!e) { > - e = __init_nat_entry(nm_i, new, NULL, true); > + init_dirty = true; > + e = __init_nat_entry(nm_i, new, NULL, true, true); > copy_node_info(&e->ni, ni); > f2fs_bug_on(sbi, ni->blk_addr == NEW_ADDR); > } else if (new_blkaddr == NEW_ADDR) { > @@ -498,7 +517,7 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni, > nat_set_blkaddr(e, new_blkaddr); > if (!__is_valid_data_blkaddr(new_blkaddr)) > set_nat_flag(e, IS_CHECKPOINTED, false); > - __set_nat_cache_dirty(nm_i, e); > + __set_nat_cache_dirty(nm_i, e, init_dirty); > > /* update fsync_mark if its inode nat entry is still alive */ > if (ni->nid != ni->ino) > @@ -2924,6 +2943,7 @@ static void remove_nats_in_journal(struct f2fs_sb_info *sbi) > struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); > struct f2fs_journal *journal = curseg->journal; > int i; > + bool init_dirty; > > down_write(&curseg->journal_rwsem); > for (i = 0; i < nats_in_cursum(journal); i++) { > @@ -2934,12 +2954,15 @@ static void remove_nats_in_journal(struct f2fs_sb_info *sbi) > if (f2fs_check_nid_range(sbi, nid)) > continue; > > + init_dirty = false; > + > raw_ne = nat_in_journal(journal, i); > > ne = __lookup_nat_cache(nm_i, nid, true); > if (!ne) { > + init_dirty = true; > ne = __alloc_nat_entry(sbi, nid, true); > - __init_nat_entry(nm_i, ne, &raw_ne, true); > + __init_nat_entry(nm_i, ne, &raw_ne, true, true); > } > > /* > @@ -2954,7 +2977,7 @@ static void remove_nats_in_journal(struct f2fs_sb_info *sbi) > spin_unlock(&nm_i->nid_list_lock); > } > > - __set_nat_cache_dirty(nm_i, ne); > + __set_nat_cache_dirty(nm_i, ne, init_dirty); > } > update_nats_in_cursum(journal, -i); > up_write(&curseg->journal_rwsem); |
From: Chao Yu <ch...@ke...> - 2025-07-24 08:02:18
|
w/ "mode=lfs" mount option, generic/299 will cause system panic as below: ------------[ cut here ]------------ kernel BUG at fs/f2fs/segment.c:2835! Call Trace: <TASK> f2fs_allocate_data_block+0x6f4/0xc50 f2fs_map_blocks+0x970/0x1550 f2fs_iomap_begin+0xb2/0x1e0 iomap_iter+0x1d6/0x430 __iomap_dio_rw+0x208/0x9a0 f2fs_file_write_iter+0x6b3/0xfa0 aio_write+0x15d/0x2e0 io_submit_one+0x55e/0xab0 __x64_sys_io_submit+0xa5/0x230 do_syscall_64+0x84/0x2f0 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0010:new_curseg+0x70f/0x720 The root cause of we run out-of-space is: in f2fs_map_blocks(), f2fs may trigger foreground gc only if it allocates any physical block, it will be a little bit later when there is multiple threads writing data w/ aio/dio/bufio method in parallel, since we always use OPU in lfs mode, so f2fs_map_blocks() does block allocations aggressively. In order to fix this issue, let's give a chance to trigger foreground gc in prior to block allocation in f2fs_map_blocks(). Fixes: 36abef4e796d ("f2fs: introduce mode=lfs mount option") Cc: Daeho Jeong <dae...@go...> Signed-off-by: Chao Yu <ch...@ke...> --- fs/f2fs/data.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 4e62f7f00b70..ffcaf91c1703 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1573,8 +1573,11 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) end = pgofs + maxblocks; next_dnode: - if (map->m_may_create) + if (map->m_may_create) { + if (f2fs_lfs_mode(sbi)) + f2fs_balance_fs(sbi, true); f2fs_map_lock(sbi, flag); + } /* When reading holes, we need its node page */ set_new_dnode(&dn, inode, NULL, NULL, 0); -- 2.49.0 |
From: Chao Yu <ch...@ke...> - 2025-07-24 08:02:11
|
In lfs mode, dirty data needs OPU, we'd better calculate lower_p and upper_p w/ them during has_not_enough_free_secs(), otherwise we may encounter out-of-space issue due to we missed to reclaim enough free section w/ foreground gc. Fixes: 36abef4e796d ("f2fs: introduce mode=lfs mount option") Cc: Daeho Jeong <dae...@go...> Signed-off-by: Chao Yu <ch...@ke...> --- fs/f2fs/segment.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 2123645cf175..5e2ee5c686b1 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -668,8 +668,7 @@ static inline void __get_secs_required(struct f2fs_sb_info *sbi, unsigned int dent_blocks = total_dent_blocks % CAP_BLKS_PER_SEC(sbi); unsigned int data_blocks = 0; - if (f2fs_lfs_mode(sbi) && - unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) { + if (f2fs_lfs_mode(sbi)) { total_data_blocks = get_pages(sbi, F2FS_DIRTY_DATA); data_secs = total_data_blocks / CAP_BLKS_PER_SEC(sbi); data_blocks = total_data_blocks % CAP_BLKS_PER_SEC(sbi); -- 2.49.0 |
From: Chao Yu <ch...@ke...> - 2025-07-24 08:02:06
|
Commit 1acd73edbbfe ("f2fs: fix to account dirty data in __get_secs_required()") missed to calculate upper_p w/ data_secs, fix it. Fixes: 1acd73edbbfe ("f2fs: fix to account dirty data in __get_secs_required()") Cc: Daeho Jeong <dae...@go...> Signed-off-by: Chao Yu <ch...@ke...> --- fs/f2fs/segment.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index d2c73f641134..2123645cf175 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -678,7 +678,7 @@ static inline void __get_secs_required(struct f2fs_sb_info *sbi, if (lower_p) *lower_p = node_secs + dent_secs + data_secs; if (upper_p) - *upper_p = node_secs + dent_secs + + *upper_p = node_secs + dent_secs + data_secs + (node_blocks ? 1 : 0) + (dent_blocks ? 1 : 0) + (data_blocks ? 1 : 0); if (curseg_p) -- 2.49.0 |