History

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 ...

Linus Torvalds committed 2 years ago

Commit 79952bd2 parents fa8380a ae87b9c23 files · +798 −463Browse files

Unified · Split

23 files
  1. Documentation/ABI/testing/sysfs-fs-f2fs +56 −0
  2. fs/f2fs/checkpoint.c +9 −8
  3. fs/f2fs/compress.c +43 −20
  4. fs/f2fs/data.c +92 −72
  5. fs/f2fs/debug.c +1 −1
  6. fs/f2fs/dir.c +5 −3
  7. fs/f2fs/extent_cache.c +2 −2
  8. fs/f2fs/f2fs.h +91 −57
  9. fs/f2fs/file.c +129 −70
  10. fs/f2fs/gc.c +86 −27
  11. fs/f2fs/gc.h +29 −0
  12. fs/f2fs/inline.c +15 −16
  13. fs/f2fs/inode.c +7 −2
  14. fs/f2fs/namei.c +0 −68
  15. fs/f2fs/node.c +24 −22
  16. fs/f2fs/segment.c +56 −16
  17. fs/f2fs/segment.h +3 −2
  18. fs/f2fs/super.c +74 −45
  19. fs/f2fs/sysfs.c +57 −25
  20. fs/f2fs/verity.c +3 −2
  21. fs/f2fs/xattr.c +12 −2
  22. include/linux/f2fs_fs.h +2 −2
  23. include/trace/events/f2fs.h +2 −1
Documentation/ABI/testing/sysfs-fs-f2fs+56−0
@@ -579,6 +579,12 @@ Description: When ATGC is on, it controls age threshold to bypass GCing young · 578 unmodified lines
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 · 178 unmodified lines
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+9−8
@@ -99,7 +99,7 @@ repeat: · 98 unmodified lines
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, · 239 unmodified lines
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) · 1176 unmodified lines
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+43−20
@@ -90,11 +90,13 @@ bool f2fs_is_compressed_page(struct page *page) · 89 unmodified lines
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) · 59 unmodified lines
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) · 702 unmodified lines
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, · 59 unmodified lines
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, · 4 unmodified lines
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, · 14 unmodified lines
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,7 +995,16 @@ fail: · 3 unmodified lines
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 */
@@ -999,7 +1012,16 @@ int f2fs_is_compressed_cluster(struct inode *inode, pgoff_t index) · 1 unmodified line
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 @@ retry: · 87 unmodified lines
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 @@ retry: · 23 unmodified lines
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 @@ continue_unlock: · 393 unmodified lines
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) {
fs/f2fs/data.c+92−72
@@ -7,7 +7,6 @@ · 6 unmodified lines
77 */
88 #include <linux/fs.h>
99 #include <linux/f2fs_fs.h>
10−#include <linux/buffer_head.h>
1110 #include <linux/sched/mm.h>
1211 #include <linux/mpage.h>
1312 #include <linux/writeback.h>
@@ -355,7 +354,7 @@ static void f2fs_write_end_io(struct bio *bio) · 341 unmodified lines
355354 }
356355
357356 f2fs_bug_on(sbi, page->mapping == NODE_MAPPING(sbi) &&
358− page->index != nid_of_node(page));
357+ page_folio(page)->index != nid_of_node(page));
359358
360359 dec_page_count(sbi, type);
361360 if (f2fs_in_warm_node_list(sbi, page))
@@ -704,7 +703,7 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio) · 342 unmodified lines
704703 bio = __bio_alloc(fio, 1);
705704
706705 f2fs_set_bio_crypt_ctx(bio, fio->page->mapping->host,
707− fio->page->index, fio, GFP_NOIO);
706+ page_folio(fio->page)->index, fio, GFP_NOIO);
708707
709708 if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
710709 bio_put(bio);
@@ -803,7 +802,7 @@ static int add_ipu_page(struct f2fs_io_info *fio, struct bio **bio, · 92 unmodified lines
803802 fio->new_blkaddr));
804803 if (f2fs_crypt_mergeable_bio(*bio,
805804 fio->page->mapping->host,
806− fio->page->index, fio) &&
805+ page_folio(fio->page)->index, fio) &&
807806 bio_add_page(*bio, page, PAGE_SIZE, 0) ==
808807 PAGE_SIZE) {
809808 ret = 0;
@@ -903,7 +902,7 @@ alloc_new: · 93 unmodified lines
903902 if (!bio) {
904903 bio = __bio_alloc(fio, BIO_MAX_VECS);
905904 f2fs_set_bio_crypt_ctx(bio, fio->page->mapping->host,
906− fio->page->index, fio, GFP_NOIO);
905+ page_folio(fio->page)->index, fio, GFP_NOIO);
907906
908907 add_bio_entry(fio->sbi, bio, page, fio->temp);
909908 } else {
@@ -996,13 +995,13 @@ next: · 86 unmodified lines
996995 (!io_is_mergeable(sbi, io->bio, io, fio, io->last_block_in_bio,
997996 fio->new_blkaddr) ||
998997 !f2fs_crypt_mergeable_bio(io->bio, fio->page->mapping->host,
999− bio_page->index, fio)))
998+ page_folio(bio_page)->index, fio)))
1000999 __submit_merged_bio(io);
10011000 alloc_new:
10021001 if (io->bio == NULL) {
10031002 io->bio = __bio_alloc(fio, BIO_MAX_VECS);
10041003 f2fs_set_bio_crypt_ctx(io->bio, fio->page->mapping->host,
1005− bio_page->index, fio, GFP_NOIO);
1004+ page_folio(bio_page)->index, fio, GFP_NOIO);
10061005 io->fio = *fio;
10071006 }
10081007
@@ -1087,7 +1086,7 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr, · 78 unmodified lines
10871086 }
10881087
10891088 /* This can handle encryption stuffs */
1090−static int f2fs_submit_page_read(struct inode *inode, struct page *page,
1089+static int f2fs_submit_page_read(struct inode *inode, struct folio *folio,
10911090 block_t blkaddr, blk_opf_t op_flags,
10921091 bool for_write)
10931092 {
@@ -1095,14 +1094,14 @@ static int f2fs_submit_page_read(struct inode *inode, struct page *page, · 1 unmodified line
10951094 struct bio *bio;
10961095
10971096 bio = f2fs_grab_read_bio(inode, blkaddr, 1, op_flags,
1098− page->index, for_write);
1097+ folio->index, for_write);
10991098 if (IS_ERR(bio))
11001099 return PTR_ERR(bio);
11011100
11021101 /* wait for GCed page writeback via META_MAPPING */
11031102 f2fs_wait_on_block_writeback(inode, blkaddr);
11041103
1105− if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
1104+ if (!bio_add_folio(bio, folio, PAGE_SIZE, 0)) {
11061105 iostat_update_and_unbind_ctx(bio);
11071106 if (bio->bi_private)
11081107 mempool_free(bio->bi_private, bio_post_read_ctx_pool);
@@ -1270,7 +1269,7 @@ got_it: · 161 unmodified lines
12701269 return page;
12711270 }
12721271
1273− err = f2fs_submit_page_read(inode, page, dn.data_blkaddr,
1272+ err = f2fs_submit_page_read(inode, page_folio(page), dn.data_blkaddr,
12741273 op_flags, for_write);
12751274 if (err)
12761275 goto put_err;
@@ -1713,6 +1712,14 @@ skip: · 436 unmodified lines
17131712 dn.ofs_in_node = end_offset;
17141713 }
17151714
1715+ if (flag == F2FS_GET_BLOCK_DIO && f2fs_lfs_mode(sbi) &&
1716+ map->m_may_create) {
1717+ /* the next block to be allocated may not be contiguous. */
1718+ if (GET_SEGOFF_FROM_SEG0(sbi, blkaddr) % BLKS_PER_SEC(sbi) ==
1719+ CAP_BLKS_PER_SEC(sbi) - 1)
1720+ goto sync_out;
1721+ }
1722+
17161723 if (pgofs >= end)
17171724 goto sync_out;
17181725 else if (dn.ofs_in_node < end_offset)
@@ -1939,7 +1946,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, · 220 unmodified lines
19391946
19401947 inode_lock_shared(inode);
19411948
1942− maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
1949+ maxbytes = F2FS_BLK_TO_BYTES(max_file_blocks(inode));
19431950 if (start > maxbytes) {
19441951 ret = -EFBIG;
19451952 goto out;
@@ -2064,7 +2071,7 @@ out: · 118 unmodified lines
20642071 static inline loff_t f2fs_readpage_limit(struct inode *inode)
20652072 {
20662073 if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode))
2067− return inode->i_sb->s_maxbytes;
2074+ return F2FS_BLK_TO_BYTES(max_file_blocks(inode));
20682075
20692076 return i_size_read(inode);
20702077 }
@@ -2208,19 +2215,22 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, · 137 unmodified lines
22082215 /* get rid of pages beyond EOF */
22092216 for (i = 0; i < cc->cluster_size; i++) {
22102217 struct page *page = cc->rpages[i];
2218+ struct folio *folio;
22112219
22122220 if (!page)
22132221 continue;
2214− if ((sector_t)page->index >= last_block_in_file) {
2215− zero_user_segment(page, 0, PAGE_SIZE);
2216− if (!PageUptodate(page))
2217− SetPageUptodate(page);
2218− } else if (!PageUptodate(page)) {
2222+
2223+ folio = page_folio(page);
2224+ if ((sector_t)folio->index >= last_block_in_file) {
2225+ folio_zero_segment(folio, 0, folio_size(folio));
2226+ if (!folio_test_uptodate(folio))
2227+ folio_mark_uptodate(folio);
2228+ } else if (!folio_test_uptodate(folio)) {
22192229 continue;
22202230 }
2221− unlock_page(page);
2231+ folio_unlock(folio);
22222232 if (for_write)
2223− put_page(page);
2233+ folio_put(folio);
22242234 cc->rpages[i] = NULL;
22252235 cc->nr_rpages--;
22262236 }
@@ -2280,7 +2290,7 @@ skip_reading_dnode: · 53 unmodified lines
22802290 }
22812291
22822292 for (i = 0; i < cc->nr_cpages; i++) {
2283− struct page *page = dic->cpages[i];
2293+ struct folio *folio = page_folio(dic->cpages[i]);
22842294 block_t blkaddr;
22852295 struct bio_post_read_ctx *ctx;
22862296
@@ -2290,7 +2300,8 @@ skip_reading_dnode: · 3 unmodified lines
22902300
22912301 f2fs_wait_on_block_writeback(inode, blkaddr);
22922302
2293− if (f2fs_load_compressed_page(sbi, page, blkaddr)) {
2303+ if (f2fs_load_compressed_page(sbi, folio_page(folio, 0),
2304+ blkaddr)) {
22942305 if (atomic_dec_and_test(&dic->remaining_pages)) {
22952306 f2fs_decompress_cluster(dic, true);
22962307 break;
@@ -2300,7 +2311,7 @@ skip_reading_dnode: · 3 unmodified lines
23002311
23012312 if (bio && (!page_is_mergeable(sbi, bio,
23022313 *last_block_in_bio, blkaddr) ||
2303− !f2fs_crypt_mergeable_bio(bio, inode, page->index, NULL))) {
2314+ !f2fs_crypt_mergeable_bio(bio, inode, folio->index, NULL))) {
23042315 submit_and_realloc:
23052316 f2fs_submit_read_bio(sbi, bio, DATA);
23062317 bio = NULL;
@@ -2309,7 +2320,7 @@ submit_and_realloc: · 2 unmodified lines
23092320 if (!bio) {
23102321 bio = f2fs_grab_read_bio(inode, blkaddr, nr_pages,
23112322 f2fs_ra_op_flags(rac),
2312− page->index, for_write);
2323+ folio->index, for_write);
23132324 if (IS_ERR(bio)) {
23142325 ret = PTR_ERR(bio);
23152326 f2fs_decompress_end_io(dic, ret, true);
@@ -2319,7 +2330,7 @@ submit_and_realloc: · 3 unmodified lines
23192330 }
23202331 }
23212332
2322− if (bio_add_page(bio, page, blocksize, 0) < blocksize)
2333+ if (!bio_add_folio(bio, folio, blocksize, 0))
23232334 goto submit_and_realloc;
23242335
23252336 ctx = get_post_read_ctx(bio);
@@ -2430,7 +2441,7 @@ static int f2fs_mpage_readpages(struct inode *inode, · 104 unmodified lines
24302441 if (ret)
24312442 goto set_error_page;
24322443
2433− f2fs_compress_ctx_add_page(&cc, &folio->page);
2444+ f2fs_compress_ctx_add_page(&cc, folio);
24342445
24352446 goto next_page;
24362447 read_single_page:
@@ -2645,21 +2656,24 @@ static inline bool need_inplace_update(struct f2fs_io_info *fio) · 208 unmodified lines
26452656
26462657 int f2fs_do_write_data_page(struct f2fs_io_info *fio)
26472658 {
2648− struct page *page = fio->page;
2649− struct inode *inode = page->mapping->host;
2659+ struct folio *folio = page_folio(fio->page);
2660+ struct inode *inode = folio->mapping->host;
26502661 struct dnode_of_data dn;
26512662 struct node_info ni;
26522663 bool ipu_force = false;
2664+ bool atomic_commit;
26532665 int err = 0;
26542666
26552667 /* Use COW inode to make dnode_of_data for atomic write */
2656− if (f2fs_is_atomic_file(inode))
2668+ atomic_commit = f2fs_is_atomic_file(inode) &&
2669+ page_private_atomic(folio_page(folio, 0));
2670+ if (atomic_commit)
26572671 set_new_dnode(&dn, F2FS_I(inode)->cow_inode, NULL, NULL, 0);
26582672 else
26592673 set_new_dnode(&dn, inode, NULL, NULL, 0);
26602674
26612675 if (need_inplace_update(fio) &&
2662− f2fs_lookup_read_extent_cache_block(inode, page->index,
2676+ f2fs_lookup_read_extent_cache_block(inode, folio->index,
26632677 &fio->old_blkaddr)) {
26642678 if (!f2fs_is_valid_blkaddr(fio->sbi, fio->old_blkaddr,
26652679 DATA_GENERIC_ENHANCE))
@@ -2674,7 +2688,7 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio) · 8 unmodified lines
26742688 if (fio->need_lock == LOCK_REQ && !f2fs_trylock_op(fio->sbi))
26752689 return -EAGAIN;
26762690
2677− err = f2fs_get_dnode_of_data(&dn, page->index, LOOKUP_NODE);
2691+ err = f2fs_get_dnode_of_data(&dn, folio->index, LOOKUP_NODE);
26782692 if (err)
26792693 goto out;
26802694
@@ -2682,8 +2696,8 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio) · 1 unmodified line
26822696
26832697 /* This page is already truncated */
26842698 if (fio->old_blkaddr == NULL_ADDR) {
2685− ClearPageUptodate(page);
2686− clear_page_private_gcing(page);
2699+ folio_clear_uptodate(folio);
2700+ clear_page_private_gcing(folio_page(folio, 0));
26872701 goto out_writepage;
26882702 }
26892703 got_it:
@@ -2709,7 +2723,7 @@ got_it: · 19 unmodified lines
27092723 if (err)
27102724 goto out_writepage;
27112725
2712− set_page_writeback(page);
2726+ folio_start_writeback(folio);
27132727 f2fs_put_dnode(&dn);
27142728 if (fio->need_lock == LOCK_REQ)
27152729 f2fs_unlock_op(fio->sbi);
@@ -2717,11 +2731,11 @@ got_it: · 1 unmodified line
27172731 if (err) {
27182732 if (fscrypt_inode_uses_fs_layer_crypto(inode))
27192733 fscrypt_finalize_bounce_page(&fio->encrypted_page);
2720− end_page_writeback(page);
2734+ folio_end_writeback(folio);
27212735 } else {
27222736 set_inode_flag(inode, FI_UPDATE_WRITE);
27232737 }
2724− trace_f2fs_do_write_data_page(page_folio(page), IPU);
2738+ trace_f2fs_do_write_data_page(folio, IPU);
27252739 return err;
27262740 }
27272741
@@ -2743,15 +2757,17 @@ got_it: · 15 unmodified lines
27432757 if (err)
27442758 goto out_writepage;
27452759
2746− set_page_writeback(page);
2760+ folio_start_writeback(folio);
27472761
27482762 if (fio->compr_blocks && fio->old_blkaddr == COMPRESS_ADDR)
27492763 f2fs_i_compr_blocks_update(inode, fio->compr_blocks - 1, false);
27502764
27512765 /* LFS mode write path */
27522766 f2fs_outplace_write_data(&dn, fio);
2753− trace_f2fs_do_write_data_page(page_folio(page), OPU);
2767+ trace_f2fs_do_write_data_page(folio, OPU);
27542768 set_inode_flag(inode, FI_APPEND_WRITE);
2769+ if (atomic_commit)
2770+ clear_page_private_atomic(folio_page(folio, 0));
27552771 out_writepage:
27562772 f2fs_put_dnode(&dn);
27572773 out:
@@ -2760,7 +2776,7 @@ out: · 2 unmodified lines
27602776 return err;
27612777 }
27622778
2763−int f2fs_write_single_data_page(struct page *page, int *submitted,
2779+int f2fs_write_single_data_page(struct folio *folio, int *submitted,
27642780 struct bio **bio,
27652781 sector_t *last_block,
27662782 struct writeback_control *wbc,
@@ -2768,12 +2784,13 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, · 1 unmodified line
27682784 int compr_blocks,
27692785 bool allow_balance)
27702786 {
2771− struct inode *inode = page->mapping->host;
2787+ struct inode *inode = folio->mapping->host;
2788+ struct page *page = folio_page(folio, 0);
27722789 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
27732790 loff_t i_size = i_size_read(inode);
27742791 const pgoff_t end_index = ((unsigned long long)i_size)
27752792 >> PAGE_SHIFT;
2776− loff_t psize = (loff_t)(page->index + 1) << PAGE_SHIFT;
2793+ loff_t psize = (loff_t)(folio->index + 1) << PAGE_SHIFT;
27772794 unsigned offset = 0;
27782795 bool need_balance_fs = false;
27792796 bool quota_inode = IS_NOQUOTA(inode);
@@ -2797,11 +2814,11 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, · 17 unmodified lines
27972814 .last_block = last_block,
27982815 };
27992816
2800− trace_f2fs_writepage(page_folio(page), DATA);
2817+ trace_f2fs_writepage(folio, DATA);
28012818
28022819 /* we should bypass data pages to proceed the kworker jobs */
28032820 if (unlikely(f2fs_cp_error(sbi))) {
2804− mapping_set_error(page->mapping, -EIO);
2821+ mapping_set_error(folio->mapping, -EIO);
28052822 /*
28062823 * don't drop any dirty dentry pages for keeping lastest
28072824 * directory structure.
@@ -2819,7 +2836,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, · 11 unmodified lines
28192836 if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
28202837 goto redirty_out;
28212838
2822− if (page->index < end_index ||
2839+ if (folio->index < end_index ||
28232840 f2fs_verity_in_progress(inode) ||
28242841 compr_blocks)
28252842 goto write;
@@ -2829,10 +2846,10 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, · 3 unmodified lines
28292846 * this page does not have to be written to disk.
28302847 */
28312848 offset = i_size & (PAGE_SIZE - 1);
2832− if ((page->index >= end_index + 1) || !offset)
2849+ if ((folio->index >= end_index + 1) || !offset)
28332850 goto out;
28342851
2835− zero_user_segment(page, offset, PAGE_SIZE);
2852+ folio_zero_segment(folio, offset, folio_size(folio));
28362853 write:
28372854 /* Dentry/quota blocks are controlled by checkpoint */
28382855 if (S_ISDIR(inode->i_mode) || quota_inode) {
@@ -2862,7 +2879,7 @@ write: · 23 unmodified lines
28622879
28632880 err = -EAGAIN;
28642881 if (f2fs_has_inline_data(inode)) {
2865− err = f2fs_write_inline_data(inode, page);
2882+ err = f2fs_write_inline_data(inode, folio);
28662883 if (!err)
28672884 goto out;
28682885 }
@@ -2892,7 +2909,7 @@ done: · 23 unmodified lines
28922909 out:
28932910 inode_dec_dirty_pages(inode);
28942911 if (err) {
2895− ClearPageUptodate(page);
2912+ folio_clear_uptodate(folio);
28962913 clear_page_private_gcing(page);
28972914 }
28982915
@@ -2902,7 +2919,7 @@ out: · 3 unmodified lines
29022919 f2fs_remove_dirty_inode(inode);
29032920 submitted = NULL;
29042921 }
2905− unlock_page(page);
2922+ folio_unlock(folio);
29062923 if (!S_ISDIR(inode->i_mode) && !IS_NOQUOTA(inode) &&
29072924 !F2FS_I(inode)->wb_task && allow_balance)
29082925 f2fs_balance_fs(sbi, need_balance_fs);
@@ -2920,7 +2937,7 @@ out: · 11 unmodified lines
29202937 return 0;
29212938
29222939 redirty_out:
2923− redirty_page_for_writepage(wbc, page);
2940+ folio_redirty_for_writepage(wbc, folio);
29242941 /*
29252942 * pageout() in MM translates EAGAIN, so calls handle_write_error()
29262943 * -> mapping_set_error() -> set_bit(AS_EIO, ...).
@@ -2929,29 +2946,30 @@ redirty_out: · 2 unmodified lines
29292946 */
29302947 if (!err || wbc->for_reclaim)
29312948 return AOP_WRITEPAGE_ACTIVATE;
2932− unlock_page(page);
2949+ folio_unlock(folio);
29332950 return err;
29342951 }
29352952
29362953 static int f2fs_write_data_page(struct page *page,
29372954 struct writeback_control *wbc)
29382955 {
2956+ struct folio *folio = page_folio(page);
29392957 #ifdef CONFIG_F2FS_FS_COMPRESSION
2940− struct inode *inode = page->mapping->host;
2958+ struct inode *inode = folio->mapping->host;
29412959
29422960 if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
29432961 goto out;
29442962
29452963 if (f2fs_compressed_file(inode)) {
2946− if (f2fs_is_compressed_cluster(inode, page->index)) {
2947− redirty_page_for_writepage(wbc, page);
2964+ if (f2fs_is_compressed_cluster(inode, folio->index)) {
2965+ folio_redirty_for_writepage(wbc, folio);
29482966 return AOP_WRITEPAGE_ACTIVATE;
29492967 }
29502968 }
29512969 out:
29522970 #endif
29532971
2954− return f2fs_write_single_data_page(page, NULL, NULL, NULL,
2972+ return f2fs_write_single_data_page(folio, NULL, NULL, NULL,
29552973 wbc, FS_DATA_IO, 0, true);
29562974 }
29572975
@@ -3157,11 +3175,11 @@ continue_unlock: · 199 unmodified lines
31573175 #ifdef CONFIG_F2FS_FS_COMPRESSION
31583176 if (f2fs_compressed_file(inode)) {
31593177 folio_get(folio);
3160− f2fs_compress_ctx_add_page(&cc, &folio->page);
3178+ f2fs_compress_ctx_add_page(&cc, folio);
31613179 continue;
31623180 }
31633181 #endif
3164− ret = f2fs_write_single_data_page(&folio->page,
3182+ ret = f2fs_write_single_data_page(folio,
31653183 &submitted, &bio, &last_block,
31663184 wbc, io_type, 0, true);
31673185 if (ret == AOP_WRITEPAGE_ACTIVATE)
@@ -3369,11 +3387,11 @@ void f2fs_write_failed(struct inode *inode, loff_t to) · 201 unmodified lines
33693387 }
33703388
33713389 static int prepare_write_begin(struct f2fs_sb_info *sbi,
3372− struct page *page, loff_t pos, unsigned len,
3390+ struct folio *folio, loff_t pos, unsigned int len,
33733391 block_t *blk_addr, bool *node_changed)
33743392 {
3375− struct inode *inode = page->mapping->host;
3376− pgoff_t index = page->index;
3393+ struct inode *inode = folio->mapping->host;
3394+ pgoff_t index = folio->index;
33773395 struct dnode_of_data dn;
33783396 struct page *ipage;
33793397 bool locked = false;
@@ -3410,13 +3428,13 @@ restart: · 30 unmodified lines
34103428
34113429 if (f2fs_has_inline_data(inode)) {
34123430 if (pos + len <= MAX_INLINE_DATA(inode)) {
3413− f2fs_do_read_inline_data(page_folio(page), ipage);
3431+ f2fs_do_read_inline_data(folio, ipage);
34143432 set_inode_flag(inode, FI_DATA_EXIST);
34153433 if (inode->i_nlink)
34163434 set_page_private_inline(ipage);
34173435 goto out;
34183436 }
3419− err = f2fs_convert_inline_page(&dn, page);
3437+ err = f2fs_convert_inline_page(&dn, folio_page(folio, 0));
34203438 if (err || dn.data_blkaddr != NULL_ADDR)
34213439 goto out;
34223440 }
@@ -3509,12 +3527,12 @@ unlock_out: · 86 unmodified lines
35093527 }
35103528
35113529 static int prepare_atomic_write_begin(struct f2fs_sb_info *sbi,
3512− struct page *page, loff_t pos, unsigned int len,
3530+ struct folio *folio, loff_t pos, unsigned int len,
35133531 block_t *blk_addr, bool *node_changed, bool *use_cow)
35143532 {
3515− struct inode *inode = page->mapping->host;
3533+ struct inode *inode = folio->mapping->host;
35163534 struct inode *cow_inode = F2FS_I(inode)->cow_inode;
3517− pgoff_t index = page->index;
3535+ pgoff_t index = folio->index;
35183536 int err = 0;
35193537 block_t ori_blk_addr = NULL_ADDR;
35203538
@@ -3620,10 +3638,10 @@ repeat: · 99 unmodified lines
36203638 *foliop = folio;
36213639
36223640 if (f2fs_is_atomic_file(inode))
3623− err = prepare_atomic_write_begin(sbi, &folio->page, pos, len,
3641+ err = prepare_atomic_write_begin(sbi, folio, pos, len,
36243642 &blkaddr, &need_balance, &use_cow);
36253643 else
3626− err = prepare_write_begin(sbi, &folio->page, pos, len,
3644+ err = prepare_write_begin(sbi, folio, pos, len,
36273645 &blkaddr, &need_balance);
36283646 if (err)
36293647 goto put_folio;
@@ -3648,7 +3666,7 @@ repeat: · 18 unmodified lines
36483666
36493667 if (!(pos & (PAGE_SIZE - 1)) && (pos + len) >= i_size_read(inode) &&
36503668 !f2fs_verity_in_progress(inode)) {
3651− folio_zero_segment(folio, len, PAGE_SIZE);
3669+ folio_zero_segment(folio, len, folio_size(folio));
36523670 return 0;
36533671 }
36543672
@@ -3662,8 +3680,8 @@ repeat: · 7 unmodified lines
36623680 goto put_folio;
36633681 }
36643682 err = f2fs_submit_page_read(use_cow ?
3665− F2FS_I(inode)->cow_inode : inode, &folio->page,
3666− blkaddr, 0, true);
3683+ F2FS_I(inode)->cow_inode : inode,
3684+ folio, blkaddr, 0, true);
36673685 if (err)
36683686 goto put_folio;
36693687
@@ -3727,6 +3745,9 @@ static int f2fs_write_end(struct file *file, · 57 unmodified lines
37273745
37283746 folio_mark_dirty(folio);
37293747
3748+ if (f2fs_is_atomic_file(inode))
3749+ set_page_private_atomic(folio_page(folio, 0));
3750+
37303751 if (pos + copied > i_size_read(inode) &&
37313752 !f2fs_verity_in_progress(inode)) {
37323753 f2fs_i_size_write(inode, pos + copied);
@@ -4117,9 +4138,8 @@ const struct address_space_operations f2fs_dblock_aops = { · 384 unmodified lines
41174138 .swap_deactivate = f2fs_swap_deactivate,
41184139 };
41194140
4120−void f2fs_clear_page_cache_dirty_tag(struct page *page)
4141+void f2fs_clear_page_cache_dirty_tag(struct folio *folio)
41214142 {
4122− struct folio *folio = page_folio(page);
41234143 struct address_space *mapping = folio->mapping;
41244144 unsigned long flags;
41254145
fs/f2fs/debug.c+1−1
@@ -275,7 +275,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi) · 274 unmodified lines
275275 /* build nm */
276276 si->base_mem += sizeof(struct f2fs_nm_info);
277277 si->base_mem += __bitmap_size(sbi, NAT_BITMAP);
278− si->base_mem += (NM_I(sbi)->nat_bits_blocks << F2FS_BLKSIZE_BITS);
278+ si->base_mem += F2FS_BLK_TO_BYTES(NM_I(sbi)->nat_bits_blocks);
279279 si->base_mem += NM_I(sbi)->nat_blocks *
280280 f2fs_bitmap_size(NAT_ENTRY_PER_BLOCK);
281281 si->base_mem += NM_I(sbi)->nat_blocks / 8;
fs/f2fs/dir.c+5−3
@@ -166,7 +166,8 @@ static unsigned long dir_block_index(unsigned int level, · 165 unmodified lines
166166 unsigned long bidx = 0;
167167
168168 for (i = 0; i < level; i++)
169− bidx += dir_buckets(i, dir_level) * bucket_blocks(i);
169+ bidx += mul_u32_u32(dir_buckets(i, dir_level),
170+ bucket_blocks(i));
170171 bidx += idx * bucket_blocks(level);
171172 return bidx;
172173 }
@@ -841,6 +842,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, · 668 unmodified lines
841842 struct f2fs_dentry_block *dentry_blk;
842843 unsigned int bit_pos;
843844 int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len));
845+ pgoff_t index = page_folio(page)->index;
844846 int i;
845847
846848 f2fs_update_time(F2FS_I_SB(dir), REQ_TIME);
@@ -866,8 +868,8 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, · 19 unmodified lines
866868 set_page_dirty(page);
867869
868870 if (bit_pos == NR_DENTRY_IN_BLOCK &&
869− !f2fs_truncate_hole(dir, page->index, page->index + 1)) {
870− f2fs_clear_page_cache_dirty_tag(page);
871+ !f2fs_truncate_hole(dir, index, index + 1)) {
872+ f2fs_clear_page_cache_dirty_tag(page_folio(page));
871873 clear_page_dirty_for_io(page);
872874 ClearPageUptodate(page);
873875 clear_page_private_all(page);
fs/f2fs/extent_cache.c+2−2
@@ -366,7 +366,7 @@ static unsigned int __free_extent_tree(struct f2fs_sb_info *sbi, · 365 unmodified lines
366366 static void __drop_largest_extent(struct extent_tree *et,
367367 pgoff_t fofs, unsigned int len)
368368 {
369− if (fofs < et->largest.fofs + et->largest.len &&
369+ if (fofs < (pgoff_t)et->largest.fofs + et->largest.len &&
370370 fofs + len > et->largest.fofs) {
371371 et->largest.len = 0;
372372 et->largest_updated = true;
@@ -456,7 +456,7 @@ static bool __lookup_extent_tree(struct inode *inode, pgoff_t pgofs, · 83 unmodified lines
456456
457457 if (type == EX_READ &&
458458 et->largest.fofs <= pgofs &&
459− et->largest.fofs + et->largest.len > pgofs) {
459+ (pgoff_t)et->largest.fofs + et->largest.len > pgofs) {
460460 *ei = et->largest;
461461 ret = true;
462462 stat_inc_largest_node_hit(sbi);
fs/f2fs/f2fs.h+91−57
@@ -11,7 +11,6 @@ · 10 unmodified lines
1111 #include <linux/uio.h>
1212 #include <linux/types.h>
1313 #include <linux/page-flags.h>
14−#include <linux/buffer_head.h>
1514 #include <linux/slab.h>
1615 #include <linux/crc32.h>
1716 #include <linux/magic.h>
@@ -134,6 +133,12 @@ typedef u32 nid_t; · 116 unmodified lines
134133
135134 #define COMPRESS_EXT_NUM 16
136135
136+enum blkzone_allocation_policy {
137+ BLKZONE_ALLOC_PRIOR_SEQ, /* Prioritize writing to sequential zones */
138+ BLKZONE_ALLOC_ONLY_SEQ, /* Only allow writing to sequential zones */
139+ BLKZONE_ALLOC_PRIOR_CONV, /* Prioritize writing to conventional zones */
140+};
141+
137142 /*
138143 * An implementation of an rwsem that is explicitly unfair to readers. This
139144 * prevents priority inversion when a low-priority reader acquires the read lock
@@ -285,6 +290,7 @@ enum { · 145 unmodified lines
285290 APPEND_INO, /* for append ino list */
286291 UPDATE_INO, /* for update ino list */
287292 TRANS_DIR_INO, /* for transactions dir ino list */
293+ XATTR_DIR_INO, /* for xattr updated dir ino list */
288294 FLUSH_INO, /* for multiple device flushing */
289295 MAX_INO_ENTRY, /* max. list */
290296 };
@@ -784,7 +790,6 @@ enum { · 493 unmodified lines
784790 FI_NEED_IPU, /* used for ipu per file */
785791 FI_ATOMIC_FILE, /* indicate atomic file */
786792 FI_DATA_EXIST, /* indicate data exists */
787− FI_INLINE_DOTS, /* indicate inline dot dentries */
788793 FI_SKIP_WRITES, /* should skip data page writeback */
789794 FI_OPU_WRITE, /* used for opu per file */
790795 FI_DIRTY_FILE, /* indicate regular/symlink has dirty pages */
@@ -802,6 +807,7 @@ enum { · 11 unmodified lines
802807 FI_ALIGNED_WRITE, /* enable aligned write */
803808 FI_COW_FILE, /* indicate COW file */
804809 FI_ATOMIC_COMMITTED, /* indicate atomic commit completed except disk sync */
810+ FI_ATOMIC_DIRTIED, /* indicate atomic file is dirtied */
805811 FI_ATOMIC_REPLACE, /* indicate atomic replace */
806812 FI_OPENED_FILE, /* indicate file has been opened */
807813 FI_MAX, /* max flag, never be used */
@@ -1155,6 +1161,7 @@ enum cp_reason_type { · 347 unmodified lines
11551161 CP_FASTBOOT_MODE,
11561162 CP_SPEC_LOG_NUM,
11571163 CP_RECOVER_DIR,
1164+ CP_XATTR_DIR,
11581165 };
11591166
11601167 enum iostat_type {
@@ -1293,6 +1300,7 @@ struct f2fs_gc_control { · 132 unmodified lines
12931300 bool no_bg_gc; /* check the space and stop bg_gc */
12941301 bool should_migrate_blocks; /* should migrate blocks */
12951302 bool err_gc_skipped; /* return EAGAIN if GC skipped */
1303+ bool one_time; /* require one time GC in one migration unit */
12961304 unsigned int nr_free_secs; /* # of free sections to do GC */
12971305 };
12981306
@@ -1418,7 +1426,8 @@ static inline void f2fs_clear_bit(unsigned int nr, char *addr); · 119 unmodified lines
14181426 * bit 1 PAGE_PRIVATE_ONGOING_MIGRATION
14191427 * bit 2 PAGE_PRIVATE_INLINE_INODE
14201428 * bit 3 PAGE_PRIVATE_REF_RESOURCE
1421− * bit 4- f2fs private data
1429+ * bit 4 PAGE_PRIVATE_ATOMIC_WRITE
1430+ * bit 5- f2fs private data
14221431 *
14231432 * Layout B: lowest bit should be 0
14241433 * page.private is a wrapped pointer.
@@ -1428,6 +1437,7 @@ enum { · 3 unmodified lines
14281437 PAGE_PRIVATE_ONGOING_MIGRATION, /* data page which is on-going migrating */
14291438 PAGE_PRIVATE_INLINE_INODE, /* inode page contains inline data */
14301439 PAGE_PRIVATE_REF_RESOURCE, /* dirty page has referenced resources */
1440+ PAGE_PRIVATE_ATOMIC_WRITE, /* data page from atomic write path */
14311441 PAGE_PRIVATE_MAX
14321442 };
14331443
@@ -1559,6 +1569,8 @@ struct f2fs_sb_info { · 125 unmodified lines
15591569 #ifdef CONFIG_BLK_DEV_ZONED
15601570 unsigned int blocks_per_blkz; /* F2FS blocks per zone */
15611571 unsigned int max_open_zones; /* max open zone resources of the zoned device */
1572+ /* For adjust the priority writing position of data in zone UFS */
1573+ unsigned int blkzone_alloc_policy;
15621574 #endif
15631575
15641576 /* for node-related operations */
@@ -1685,6 +1697,8 @@ struct f2fs_sb_info { · 120 unmodified lines
16851697 unsigned int max_victim_search;
16861698 /* migration granularity of garbage collection, unit: segment */
16871699 unsigned int migration_granularity;
1700+ /* migration window granularity of garbage collection, unit: segment */
1701+ unsigned int migration_window_granularity;
16881702
16891703 /*
16901704 * for stat information.
@@ -1994,6 +2008,16 @@ static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi) · 303 unmodified lines
19942008 return (struct f2fs_super_block *)(sbi->raw_super);
19952009 }
19962010
2011+static inline struct f2fs_super_block *F2FS_SUPER_BLOCK(struct folio *folio,
2012+ pgoff_t index)
2013+{
2014+ pgoff_t idx_in_folio = index % (1 << folio_order(folio));
2015+
2016+ return (struct f2fs_super_block *)
2017+ (page_address(folio_page(folio, idx_in_folio)) +
2018+ F2FS_SUPER_OFFSET);
2019+}
2020+
19972021 static inline struct f2fs_checkpoint *F2FS_CKPT(struct f2fs_sb_info *sbi)
19982022 {
19992023 return (struct f2fs_checkpoint *)(sbi->ckpt);
@@ -2396,14 +2420,17 @@ static inline void clear_page_private_##name(struct page *page) \ · 396 unmodified lines
23962420 PAGE_PRIVATE_GET_FUNC(nonpointer, NOT_POINTER);
23972421 PAGE_PRIVATE_GET_FUNC(inline, INLINE_INODE);
23982422 PAGE_PRIVATE_GET_FUNC(gcing, ONGOING_MIGRATION);
2423+PAGE_PRIVATE_GET_FUNC(atomic, ATOMIC_WRITE);
23992424
24002425 PAGE_PRIVATE_SET_FUNC(reference, REF_RESOURCE);
24012426 PAGE_PRIVATE_SET_FUNC(inline, INLINE_INODE);
24022427 PAGE_PRIVATE_SET_FUNC(gcing, ONGOING_MIGRATION);
2428+PAGE_PRIVATE_SET_FUNC(atomic, ATOMIC_WRITE);
24032429
24042430 PAGE_PRIVATE_CLEAR_FUNC(reference, REF_RESOURCE);
24052431 PAGE_PRIVATE_CLEAR_FUNC(inline, INLINE_INODE);
24062432 PAGE_PRIVATE_CLEAR_FUNC(gcing, ONGOING_MIGRATION);
2433+PAGE_PRIVATE_CLEAR_FUNC(atomic, ATOMIC_WRITE);
24072434
24082435 static inline unsigned long get_page_private_data(struct page *page)
24092436 {
@@ -2435,6 +2462,7 @@ static inline void clear_page_private_all(struct page *page) · 25 unmodified lines
24352462 clear_page_private_reference(page);
24362463 clear_page_private_gcing(page);
24372464 clear_page_private_inline(page);
2465+ clear_page_private_atomic(page);
24382466
24392467 f2fs_bug_on(F2FS_P_SB(page), page_private(page));
24402468 }
@@ -2854,13 +2882,26 @@ static inline bool is_inflight_io(struct f2fs_sb_info *sbi, int type) · 413 unmodified lines
28542882 return false;
28552883 }
28562884
2885+static inline bool is_inflight_read_io(struct f2fs_sb_info *sbi)
2886+{
2887+ return get_pages(sbi, F2FS_RD_DATA) || get_pages(sbi, F2FS_DIO_READ);
2888+}
2889+
28572890 static inline bool is_idle(struct f2fs_sb_info *sbi, int type)
28582891 {
2892+ bool zoned_gc = (type == GC_TIME &&
2893+ F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_BLKZONED));
2894+
28592895 if (sbi->gc_mode == GC_URGENT_HIGH)
28602896 return true;
28612897
2862− if (is_inflight_io(sbi, type))
2863− return false;
2898+ if (zoned_gc) {
2899+ if (is_inflight_read_io(sbi))
2900+ return false;
2901+ } else {
2902+ if (is_inflight_io(sbi, type))
2903+ return false;
2904+ }
28642905
28652906 if (sbi->gc_mode == GC_URGENT_MID)
28662907 return true;
@@ -2869,6 +2910,9 @@ static inline bool is_idle(struct f2fs_sb_info *sbi, int type) · 2 unmodified lines
28692910 (type == DISCARD_TIME || type == GC_TIME))
28702911 return true;
28712912
2913+ if (zoned_gc)
2914+ return true;
2915+
28722916 return f2fs_time_over(sbi, type);
28732917 }
28742918
@@ -2900,26 +2944,27 @@ static inline __le32 *blkaddr_in_node(struct f2fs_node *node) · 25 unmodified lines
29002944 }
29012945
29022946 static inline int f2fs_has_extra_attr(struct inode *inode);
2903−static inline block_t data_blkaddr(struct inode *inode,
2904− struct page *node_page, unsigned int offset)
2947+static inline unsigned int get_dnode_base(struct inode *inode,
2948+ struct page *node_page)
29052949 {
2906− struct f2fs_node *raw_node;
2907− __le32 *addr_array;
2908− int base = 0;
2909− bool is_inode = IS_INODE(node_page);
2950+ if (!IS_INODE(node_page))
2951+ return 0;
29102952
2911− raw_node = F2FS_NODE(node_page);
2953+ return inode ? get_extra_isize(inode) :
2954+ offset_in_addr(&F2FS_NODE(node_page)->i);
2955+}
29122956
2913− if (is_inode) {
2914− if (!inode)
2915− /* from GC path only */
2916− base = offset_in_addr(&raw_node->i);
2917− else if (f2fs_has_extra_attr(inode))
2918− base = get_extra_isize(inode);
2919− }
2957+static inline __le32 *get_dnode_addr(struct inode *inode,
2958+ struct page *node_page)
2959+{
2960+ return blkaddr_in_node(F2FS_NODE(node_page)) +
2961+ get_dnode_base(inode, node_page);
2962+}
29202963
2921− addr_array = blkaddr_in_node(raw_node);
2922− return le32_to_cpu(addr_array[base + offset]);
2964+static inline block_t data_blkaddr(struct inode *inode,
2965+ struct page *node_page, unsigned int offset)
2966+{
2967+ return le32_to_cpu(*(get_dnode_addr(inode, node_page) + offset));
29232968 }
29242969
29252970 static inline block_t f2fs_data_blkaddr(struct dnode_of_data *dn)
@@ -3038,10 +3083,8 @@ static inline void __mark_inode_dirty_flag(struct inode *inode, · 112 unmodified lines
30383083 return;
30393084 fallthrough;
30403085 case FI_DATA_EXIST:
3041− case FI_INLINE_DOTS:
30423086 case FI_PIN_FILE:
30433087 case FI_COMPRESS_RELEASED:
3044− case FI_ATOMIC_COMMITTED:
30453088 f2fs_mark_inode_dirty_sync(inode, true);
30463089 }
30473090 }
@@ -3163,8 +3206,6 @@ static inline void get_inline_info(struct inode *inode, struct f2fs_inode *ri) · 115 unmodified lines
31633206 set_bit(FI_INLINE_DENTRY, fi->flags);
31643207 if (ri->i_inline & F2FS_DATA_EXIST)
31653208 set_bit(FI_DATA_EXIST, fi->flags);
3166− if (ri->i_inline & F2FS_INLINE_DOTS)
3167− set_bit(FI_INLINE_DOTS, fi->flags);
31683209 if (ri->i_inline & F2FS_EXTRA_ATTR)
31693210 set_bit(FI_EXTRA_ATTR, fi->flags);
31703211 if (ri->i_inline & F2FS_PIN_FILE)
@@ -3185,8 +3226,6 @@ static inline void set_raw_inline(struct inode *inode, struct f2fs_inode *ri) · 14 unmodified lines
31853226 ri->i_inline |= F2FS_INLINE_DENTRY;
31863227 if (is_inode_flag_set(inode, FI_DATA_EXIST))
31873228 ri->i_inline |= F2FS_DATA_EXIST;
3188− if (is_inode_flag_set(inode, FI_INLINE_DOTS))
3189− ri->i_inline |= F2FS_INLINE_DOTS;
31903229 if (is_inode_flag_set(inode, FI_EXTRA_ATTR))
31913230 ri->i_inline |= F2FS_EXTRA_ATTR;
31923231 if (is_inode_flag_set(inode, FI_PIN_FILE))
@@ -3267,11 +3306,6 @@ static inline int f2fs_exist_data(struct inode *inode) · 74 unmodified lines
32673306 return is_inode_flag_set(inode, FI_DATA_EXIST);
32683307 }
32693308
3270−static inline int f2fs_has_inline_dots(struct inode *inode)
3271−{
3272− return is_inode_flag_set(inode, FI_INLINE_DOTS);
3273−}
3274−
32753309 static inline int f2fs_is_mmap_file(struct inode *inode)
32763310 {
32773311 return is_inode_flag_set(inode, FI_MMAP_FILE);
@@ -3292,8 +3326,6 @@ static inline bool f2fs_is_cow_file(struct inode *inode) · 14 unmodified lines
32923326 return is_inode_flag_set(inode, FI_COW_FILE);
32933327 }
32943328
3295−static inline __le32 *get_dnode_addr(struct inode *inode,
3296− struct page *node_page);
32973329 static inline void *inline_data_addr(struct inode *inode, struct page *page)
32983330 {
32993331 __le32 *addr = get_dnode_addr(inode, page);
@@ -3432,17 +3464,6 @@ static inline int get_inline_xattr_addrs(struct inode *inode) · 132 unmodified lines
34323464 return F2FS_I(inode)->i_inline_xattr_size;
34333465 }
34343466
3435−static inline __le32 *get_dnode_addr(struct inode *inode,
3436− struct page *node_page)
3437−{
3438− int base = 0;
3439−
3440− if (IS_INODE(node_page) && f2fs_has_extra_attr(inode))
3441− base = get_extra_isize(inode);
3442−
3443− return blkaddr_in_node(F2FS_NODE(node_page)) + base;
3444−}
3445−
34463467 #define f2fs_get_inode_mode(i) \
34473468 ((is_inode_flag_set(i, FI_ACL_MODE)) ? \
34483469 (F2FS_I(i)->i_acl_mode) : ((i)->i_mode))
@@ -3495,7 +3516,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, · 46 unmodified lines
34953516 int f2fs_truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end);
34963517 void f2fs_truncate_data_blocks_range(struct dnode_of_data *dn, int count);
34973518 int f2fs_do_shutdown(struct f2fs_sb_info *sbi, unsigned int flag,
3498− bool readonly);
3519+ bool readonly, bool need_lock);
34993520 int f2fs_precache_extents(struct inode *inode);
35003521 int f2fs_fileattr_get(struct dentry *dentry, struct fileattr *fa);
35013522 int f2fs_fileattr_set(struct mnt_idmap *idmap,
@@ -3719,7 +3740,7 @@ bool f2fs_exist_trim_candidates(struct f2fs_sb_info *sbi, · 217 unmodified lines
37193740 struct page *f2fs_get_sum_page(struct f2fs_sb_info *sbi, unsigned int segno);
37203741 void f2fs_update_meta_page(struct f2fs_sb_info *sbi, void *src,
37213742 block_t blk_addr);
3722−void f2fs_do_write_meta_page(struct f2fs_sb_info *sbi, struct page *page,
3743+void f2fs_do_write_meta_page(struct f2fs_sb_info *sbi, struct folio *folio,
37233744 enum iostat_type io_type);
37243745 void f2fs_do_write_node_page(unsigned int nid, struct f2fs_io_info *fio);
37253746 void f2fs_outplace_write_data(struct dnode_of_data *dn,
@@ -3759,8 +3780,7 @@ void f2fs_destroy_segment_manager_caches(void); · 33 unmodified lines
37593780 int f2fs_rw_hint_to_seg_type(struct f2fs_sb_info *sbi, enum rw_hint hint);
37603781 enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi,
37613782 enum page_type type, enum temp_type temp);
3762−unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi,
3763− unsigned int segno);
3783+unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi);
37643784 unsigned int f2fs_usable_blks_in_seg(struct f2fs_sb_info *sbi,
37653785 unsigned int segno);
37663786
@@ -3868,7 +3888,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, · 101 unmodified lines
38683888 int f2fs_encrypt_one_page(struct f2fs_io_info *fio);
38693889 bool f2fs_should_update_inplace(struct inode *inode, struct f2fs_io_info *fio);
38703890 bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio);
3871−int f2fs_write_single_data_page(struct page *page, int *submitted,
3891+int f2fs_write_single_data_page(struct folio *folio, int *submitted,
38723892 struct bio **bio, sector_t *last_block,
38733893 struct writeback_control *wbc,
38743894 enum iostat_type io_type,
@@ -3877,7 +3897,7 @@ void f2fs_write_failed(struct inode *inode, loff_t to); · 2 unmodified lines
38773897 void f2fs_invalidate_folio(struct folio *folio, size_t offset, size_t length);
38783898 bool f2fs_release_folio(struct folio *folio, gfp_t wait);
38793899 bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len);
3880−void f2fs_clear_page_cache_dirty_tag(struct page *page);
3900+void f2fs_clear_page_cache_dirty_tag(struct folio *folio);
38813901 int f2fs_init_post_read_processing(void);
38823902 void f2fs_destroy_post_read_processing(void);
38833903 int f2fs_init_post_read_wq(struct f2fs_sb_info *sbi);
@@ -3901,7 +3921,7 @@ void f2fs_destroy_garbage_collection_cache(void); · 17 unmodified lines
39013921 /* victim selection function for cleaning and SSR */
39023922 int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result,
39033923 int gc_type, int type, char alloc_mode,
3904− unsigned long long age);
3924+ unsigned long long age, bool one_time);
39053925
39063926 /*
39073927 * recovery.c
@@ -3987,7 +4007,7 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi) · 79 unmodified lines
39874007
39884008 #define stat_inc_cp_call_count(sbi, foreground) \
39894009 atomic_inc(&sbi->cp_call_count[(foreground)])
3990−#define stat_inc_cp_count(si) (F2FS_STAT(sbi)->cp_count++)
4010+#define stat_inc_cp_count(sbi) (F2FS_STAT(sbi)->cp_count++)
39914011 #define stat_io_skip_bggc_count(sbi) ((sbi)->io_skip_bggc++)
39924012 #define stat_other_skip_bggc_count(sbi) ((sbi)->other_skip_bggc++)
39934013 #define stat_inc_dirty_inode(sbi, type) ((sbi)->ndirty_inode[type]++)
@@ -4172,7 +4192,7 @@ int f2fs_read_inline_data(struct inode *inode, struct folio *folio); · 178 unmodified lines
41724192 int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page);
41734193 int f2fs_convert_inline_inode(struct inode *inode);
41744194 int f2fs_try_convert_inline_dir(struct inode *dir, struct dentry *dentry);
4175−int f2fs_write_inline_data(struct inode *inode, struct page *page);
4195+int f2fs_write_inline_data(struct inode *inode, struct folio *folio);
41764196 int f2fs_recover_inline_data(struct inode *inode, struct page *npage);
41774197 struct f2fs_dir_entry *f2fs_find_in_inline_dir(struct inode *dir,
41784198 const struct f2fs_filename *fname,
@@ -4289,6 +4309,11 @@ static inline bool f2fs_meta_inode_gc_required(struct inode *inode) · 110 unmodified lines
42894309 * compress.c
42904310 */
42914311 #ifdef CONFIG_F2FS_FS_COMPRESSION
4312+enum cluster_check_type {
4313+ CLUSTER_IS_COMPR, /* check only if compressed cluster */
4314+ CLUSTER_COMPR_BLKS, /* return # of compressed blocks in a cluster */
4315+ CLUSTER_RAW_BLKS /* return # of raw blocks in a cluster */
4316+};
42924317 bool f2fs_is_compressed_page(struct page *page);
42934318 struct page *f2fs_compress_control_page(struct page *page);
42944319 int f2fs_prepare_compress_overwrite(struct inode *inode,
@@ -4309,12 +4334,13 @@ bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index); · 14 unmodified lines
43094334 bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages,
43104335 int index, int nr_pages, bool uptodate);
43114336 bool f2fs_sanity_check_cluster(struct dnode_of_data *dn);
4312−void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct page *page);
4337+void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct folio *folio);
43134338 int f2fs_write_multi_pages(struct compress_ctx *cc,
43144339 int *submitted,
43154340 struct writeback_control *wbc,
43164341 enum iostat_type io_type);
43174342 int f2fs_is_compressed_cluster(struct inode *inode, pgoff_t index);
4343+bool f2fs_is_sparse_cluster(struct inode *inode, pgoff_t index);
43184344 void f2fs_update_read_extent_tree_range_compressed(struct inode *inode,
43194345 pgoff_t fofs, block_t blkaddr,
43204346 unsigned int llen, unsigned int c_len);
@@ -4401,6 +4427,12 @@ static inline bool f2fs_load_compressed_page(struct f2fs_sb_info *sbi, · 80 unmodified lines
44014427 static inline void f2fs_invalidate_compress_pages(struct f2fs_sb_info *sbi,
44024428 nid_t ino) { }
44034429 #define inc_compr_inode_stat(inode) do { } while (0)
4430+static inline int f2fs_is_compressed_cluster(
4431+ struct inode *inode,
4432+ pgoff_t index) { return 0; }
4433+static inline bool f2fs_is_sparse_cluster(
4434+ struct inode *inode,
4435+ pgoff_t index) { return true; }
44044436 static inline void f2fs_update_read_extent_tree_range_compressed(
44054437 struct inode *inode,
44064438 pgoff_t fofs, block_t blkaddr,
@@ -4653,9 +4685,11 @@ static inline void f2fs_io_schedule_timeout(long timeout) · 246 unmodified lines
46534685 io_schedule_timeout(timeout);
46544686 }
46554687
4656−static inline void f2fs_handle_page_eio(struct f2fs_sb_info *sbi, pgoff_t ofs,
4657− enum page_type type)
4688+static inline void f2fs_handle_page_eio(struct f2fs_sb_info *sbi,
4689+ struct folio *folio, enum page_type type)
46584690 {
4691+ pgoff_t ofs = folio->index;
4692+
46594693 if (unlikely(f2fs_cp_error(sbi)))
46604694 return;
46614695
fs/f2fs/file.c+129−70
@@ -8,7 +8,6 @@ · 7 unmodified lines
88 #include <linux/fs.h>
99 #include <linux/f2fs_fs.h>
1010 #include <linux/stat.h>
11−#include <linux/buffer_head.h>
1211 #include <linux/writeback.h>
1312 #include <linux/blkdev.h>
1413 #include <linux/falloc.h>
@@ -54,7 +53,7 @@ static vm_fault_t f2fs_filemap_fault(struct vm_fault *vmf) · 39 unmodified lines
5453
5554 static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)
5655 {
57− struct page *page = vmf->page;
56+ struct folio *folio = page_folio(vmf->page);
5857 struct inode *inode = file_inode(vmf->vma->vm_file);
5958 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
6059 struct dnode_of_data dn;
@@ -86,7 +85,7 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) · 25 unmodified lines
8685
8786 #ifdef CONFIG_F2FS_FS_COMPRESSION
8887 if (f2fs_compressed_file(inode)) {
89− int ret = f2fs_is_compressed_cluster(inode, page->index);
88+ int ret = f2fs_is_compressed_cluster(inode, folio->index);
9089
9190 if (ret < 0) {
9291 err = ret;
@@ -106,11 +105,11 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) · 13 unmodified lines
106105
107106 file_update_time(vmf->vma->vm_file);
108107 filemap_invalidate_lock_shared(inode->i_mapping);
109− lock_page(page);
110− if (unlikely(page->mapping != inode->i_mapping ||
111− page_offset(page) > i_size_read(inode) ||
112− !PageUptodate(page))) {
113− unlock_page(page);
108+ folio_lock(folio);
109+ if (unlikely(folio->mapping != inode->i_mapping ||
110+ folio_pos(folio) > i_size_read(inode) ||
111+ !folio_test_uptodate(folio))) {
112+ folio_unlock(folio);
114113 err = -EFAULT;
115114 goto out_sem;
116115 }
@@ -118,9 +117,9 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) · 1 unmodified line
118117 set_new_dnode(&dn, inode, NULL, NULL, 0);
119118 if (need_alloc) {
120119 /* block allocation */
121− err = f2fs_get_block_locked(&dn, page->index);
120+ err = f2fs_get_block_locked(&dn, folio->index);
122121 } else {
123− err = f2fs_get_dnode_of_data(&dn, page->index, LOOKUP_NODE);
122+ err = f2fs_get_dnode_of_data(&dn, folio->index, LOOKUP_NODE);
124123 f2fs_put_dnode(&dn);
125124 if (f2fs_is_pinned_file(inode) &&
126125 !__is_valid_data_blkaddr(dn.data_blkaddr))
@@ -128,11 +127,11 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) · 1 unmodified line
128127 }
129128
130129 if (err) {
131− unlock_page(page);
130+ folio_unlock(folio);
132131 goto out_sem;
133132 }
134133
135− f2fs_wait_on_page_writeback(page, DATA, false, true);
134+ f2fs_wait_on_page_writeback(folio_page(folio, 0), DATA, false, true);
136135
137136 /* wait for GCed page writeback via META_MAPPING */
138137 f2fs_wait_on_block_writeback(inode, dn.data_blkaddr);
@@ -140,18 +139,18 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) · 1 unmodified line
140139 /*
141140 * check to see if the page is mapped already (no holes)
142141 */
143− if (PageMappedToDisk(page))
142+ if (folio_test_mappedtodisk(folio))
144143 goto out_sem;
145144
146145 /* page is wholly or partially inside EOF */
147− if (((loff_t)(page->index + 1) << PAGE_SHIFT) >
146+ if (((loff_t)(folio->index + 1) << PAGE_SHIFT) >
148147 i_size_read(inode)) {
149148 loff_t offset;
150149
151150 offset = i_size_read(inode) & ~PAGE_MASK;
152− zero_user_segment(page, offset, PAGE_SIZE);
151+ folio_zero_segment(folio, offset, folio_size(folio));
153152 }
154− set_page_dirty(page);
153+ folio_mark_dirty(folio);
155154
156155 f2fs_update_iostat(sbi, inode, APP_MAPPED_IO, F2FS_BLKSIZE);
157156 f2fs_update_time(sbi, REQ_TIME);
@@ -163,7 +162,7 @@ out_sem: · 5 unmodified lines
163162 out:
164163 ret = vmf_fs_error(err);
165164
166− trace_f2fs_vm_page_mkwrite(inode, page->index, vmf->vma->vm_flags, ret);
165+ trace_f2fs_vm_page_mkwrite(inode, folio->index, vmf->vma->vm_flags, ret);
167166 return ret;
168167 }
169168
@@ -218,6 +217,9 @@ static inline enum cp_reason_type need_do_checkpoint(struct inode *inode) · 48 unmodified lines
218217 f2fs_exist_written_data(sbi, F2FS_I(inode)->i_pino,
219218 TRANS_DIR_INO))
220219 cp_reason = CP_RECOVER_DIR;
220+ else if (f2fs_exist_written_data(sbi, F2FS_I(inode)->i_pino,
221+ XATTR_DIR_INO))
222+ cp_reason = CP_XATTR_DIR;
221223
222224 return cp_reason;
223225 }
@@ -373,8 +375,7 @@ sync_nodes: · 149 unmodified lines
373375 f2fs_remove_ino_entry(sbi, ino, APPEND_INO);
374376 clear_inode_flag(inode, FI_APPEND_WRITE);
375377 flush_out:
376− if ((!atomic && F2FS_OPTION(sbi).fsync_mode != FSYNC_MODE_NOBARRIER) ||
377− (atomic && !test_opt(sbi, NOBARRIER) && f2fs_sb_has_blkzoned(sbi)))
378+ if (!atomic && F2FS_OPTION(sbi).fsync_mode != FSYNC_MODE_NOBARRIER)
378379 ret = f2fs_issue_flush(sbi, inode->i_ino);
379380 if (!ret) {
380381 f2fs_remove_ino_entry(sbi, ino, UPDATE_INO);
@@ -431,7 +432,7 @@ static bool __found_offset(struct address_space *mapping, · 50 unmodified lines
431432 static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
432433 {
433434 struct inode *inode = file->f_mapping->host;
434− loff_t maxbytes = inode->i_sb->s_maxbytes;
435+ loff_t maxbytes = F2FS_BLK_TO_BYTES(max_file_blocks(inode));
435436 struct dnode_of_data dn;
436437 pgoff_t pgofs, end_offset;
437438 loff_t data_ofs = offset;
@@ -513,10 +514,7 @@ fail: · 75 unmodified lines
513514 static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
514515 {
515516 struct inode *inode = file->f_mapping->host;
516− loff_t maxbytes = inode->i_sb->s_maxbytes;
517−
518− if (f2fs_compressed_file(inode))
519− maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
517+ loff_t maxbytes = F2FS_BLK_TO_BYTES(max_file_blocks(inode));
520518
521519 switch (whence) {
522520 case SEEK_SET:
@@ -1052,6 +1050,13 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, · 529 unmodified lines
10521050 return err;
10531051 }
10541052
1053+ /*
1054+ * wait for inflight dio, blocks should be removed after
1055+ * IO completion.
1056+ */
1057+ if (attr->ia_size < old_size)
1058+ inode_dio_wait(inode);
1059+
10551060 f2fs_down_write(&fi->i_gc_rwsem[WRITE]);
10561061 filemap_invalidate_lock(inode->i_mapping);
10571062
@@ -1888,6 +1893,12 @@ static long f2fs_fallocate(struct file *file, int mode, · 830 unmodified lines
18881893 if (ret)
18891894 goto out;
18901895
1896+ /*
1897+ * wait for inflight dio, blocks should be removed after IO
1898+ * completion.
1899+ */
1900+ inode_dio_wait(inode);
1901+
18911902 if (mode & FALLOC_FL_PUNCH_HOLE) {
18921903 if (offset >= inode->i_size)
18931904 goto out;
@@ -2116,10 +2127,12 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate) · 222 unmodified lines
21162127 struct mnt_idmap *idmap = file_mnt_idmap(filp);
21172128 struct f2fs_inode_info *fi = F2FS_I(inode);
21182129 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
2119− struct inode *pinode;
21202130 loff_t isize;
21212131 int ret;
21222132
2133+ if (!(filp->f_mode & FMODE_WRITE))
2134+ return -EBADF;
2135+
21232136 if (!inode_owner_or_capable(idmap, inode))
21242137 return -EACCES;
21252138
@@ -2149,6 +2162,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate) · 23 unmodified lines
21492162 goto out;
21502163
21512164 f2fs_down_write(&fi->i_gc_rwsem[WRITE]);
2165+ f2fs_down_write(&fi->i_gc_rwsem[READ]);
21522166
21532167 /*
21542168 * Should wait end_io to count F2FS_WB_CP_DATA correctly by
@@ -2158,27 +2172,18 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate) · 3 unmodified lines
21582172 f2fs_warn(sbi, "Unexpected flush for atomic writes: ino=%lu, npages=%u",
21592173 inode->i_ino, get_dirty_pages(inode));
21602174 ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX);
2161− if (ret) {
2162− f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
2163− goto out;
2164− }
2175+ if (ret)
2176+ goto out_unlock;
21652177
21662178 /* Check if the inode already has a COW inode */
21672179 if (fi->cow_inode == NULL) {
21682180 /* Create a COW inode for atomic write */
2169− pinode = f2fs_iget(inode->i_sb, fi->i_pino);
2170− if (IS_ERR(pinode)) {
2171− f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
2172− ret = PTR_ERR(pinode);
2173− goto out;
2174− }
2181+ struct dentry *dentry = file_dentry(filp);
2182+ struct inode *dir = d_inode(dentry->d_parent);
21752183
2176− ret = f2fs_get_tmpfile(idmap, pinode, &fi->cow_inode);
2177− iput(pinode);
2178− if (ret) {
2179− f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
2180− goto out;
2181− }
2184+ ret = f2fs_get_tmpfile(idmap, dir, &fi->cow_inode);
2185+ if (ret)
2186+ goto out_unlock;
21822187
21832188 set_inode_flag(fi->cow_inode, FI_COW_FILE);
21842189 clear_inode_flag(fi->cow_inode, FI_INLINE_DATA);
@@ -2187,11 +2192,13 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate) · 2 unmodified lines
21872192 F2FS_I(fi->cow_inode)->atomic_inode = inode;
21882193 } else {
21892194 /* Reuse the already created COW inode */
2195+ f2fs_bug_on(sbi, get_dirty_pages(fi->cow_inode));
2196+
2197+ invalidate_mapping_pages(fi->cow_inode->i_mapping, 0, -1);
2198+
21902199 ret = f2fs_do_truncate_blocks(fi->cow_inode, 0, true);
2191− if (ret) {
2192− f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
2193− goto out;
2194− }
2200+ if (ret)
2201+ goto out_unlock;
21952202 }
21962203
21972204 f2fs_write_inode(inode, NULL);
@@ -2210,7 +2217,11 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate) · 12 unmodified lines
22102217 }
22112218 f2fs_i_size_write(fi->cow_inode, isize);
22122219
2220+out_unlock:
2221+ f2fs_up_write(&fi->i_gc_rwsem[READ]);
22132222 f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
2223+ if (ret)
2224+ goto out;
22142225
22152226 f2fs_update_time(sbi, REQ_TIME);
22162227 fi->atomic_write_task = current;
@@ -2228,6 +2239,9 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp) · 11 unmodified lines
22282239 struct mnt_idmap *idmap = file_mnt_idmap(filp);
22292240 int ret;
22302241
2242+ if (!(filp->f_mode & FMODE_WRITE))
2243+ return -EBADF;
2244+
22312245 if (!inode_owner_or_capable(idmap, inode))
22322246 return -EACCES;
22332247
@@ -2260,6 +2274,9 @@ static int f2fs_ioc_abort_atomic_write(struct file *filp) · 26 unmodified lines
22602274 struct mnt_idmap *idmap = file_mnt_idmap(filp);
22612275 int ret;
22622276
2277+ if (!(filp->f_mode & FMODE_WRITE))
2278+ return -EBADF;
2279+
22632280 if (!inode_owner_or_capable(idmap, inode))
22642281 return -EACCES;
22652282
@@ -2279,7 +2296,7 @@ static int f2fs_ioc_abort_atomic_write(struct file *filp) · 13 unmodified lines
22792296 }
22802297
22812298 int f2fs_do_shutdown(struct f2fs_sb_info *sbi, unsigned int flag,
2282− bool readonly)
2299+ bool readonly, bool need_lock)
22832300 {
22842301 struct super_block *sb = sbi->sb;
22852302 int ret = 0;
@@ -2326,12 +2343,19 @@ int f2fs_do_shutdown(struct f2fs_sb_info *sbi, unsigned int flag, · 40 unmodified lines
23262343 if (readonly)
23272344 goto out;
23282345
2346+ /* grab sb->s_umount to avoid racing w/ remount() */
2347+ if (need_lock)
2348+ down_read(&sbi->sb->s_umount);
2349+
23292350 f2fs_stop_gc_thread(sbi);
23302351 f2fs_stop_discard_thread(sbi);
23312352
23322353 f2fs_drop_discard_cmd(sbi);
23332354 clear_opt(sbi, DISCARD);
23342355
2356+ if (need_lock)
2357+ up_read(&sbi->sb->s_umount);
2358+
23352359 f2fs_update_time(sbi, REQ_TIME);
23362360 out:
23372361
@@ -2368,7 +2392,7 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg) · 30 unmodified lines
23682392 }
23692393 }
23702394
2371− ret = f2fs_do_shutdown(sbi, in, readonly);
2395+ ret = f2fs_do_shutdown(sbi, in, readonly, true);
23722396
23732397 if (need_drop)
23742398 mnt_drop_write_file(filp);
@@ -2686,7 +2710,8 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, · 311 unmodified lines
26862710 (range->start + range->len) >> PAGE_SHIFT,
26872711 DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE));
26882712
2689− if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
2713+ if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) ||
2714+ f2fs_is_atomic_file(inode)) {
26902715 err = -EINVAL;
26912716 goto unlock_out;
26922717 }
@@ -2710,7 +2735,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, · 17 unmodified lines
27102735 * block addresses are continuous.
27112736 */
27122737 if (f2fs_lookup_read_extent_cache(inode, pg_start, &ei)) {
2713− if (ei.fofs + ei.len >= pg_end)
2738+ if ((pgoff_t)ei.fofs + ei.len >= pg_end)
27142739 goto out;
27152740 }
27162741
@@ -2793,6 +2818,8 @@ do_map: · 76 unmodified lines
27932818 goto clear_out;
27942819 }
27952820
2821+ f2fs_wait_on_page_writeback(page, DATA, true, true);
2822+
27962823 set_page_dirty(page);
27972824 set_page_private_gcing(page);
27982825 f2fs_put_page(page, 1);
@@ -2917,6 +2944,11 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, · 118 unmodified lines
29172944 goto out_unlock;
29182945 }
29192946
2947+ if (f2fs_is_atomic_file(src) || f2fs_is_atomic_file(dst)) {
2948+ ret = -EINVAL;
2949+ goto out_unlock;
2950+ }
2951+
29202952 ret = -EINVAL;
29212953 if (pos_in + len > src->i_size || pos_in + len < pos_in)
29222954 goto out_unlock;
@@ -2968,9 +3000,9 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, · 45 unmodified lines
29683000 }
29693001
29703002 f2fs_lock_op(sbi);
2971− ret = __exchange_data_block(src, dst, pos_in >> F2FS_BLKSIZE_BITS,
2972− pos_out >> F2FS_BLKSIZE_BITS,
2973− len >> F2FS_BLKSIZE_BITS, false);
3003+ ret = __exchange_data_block(src, dst, F2FS_BYTES_TO_BLK(pos_in),
3004+ F2FS_BYTES_TO_BLK(pos_out),
3005+ F2FS_BYTES_TO_BLK(len), false);
29743006
29753007 if (!ret) {
29763008 if (dst_max_i_size)
@@ -3300,6 +3332,11 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg) · 323 unmodified lines
33003332
33013333 inode_lock(inode);
33023334
3335+ if (f2fs_is_atomic_file(inode)) {
3336+ ret = -EINVAL;
3337+ goto out;
3338+ }
3339+
33033340 if (!pin) {
33043341 clear_inode_flag(inode, FI_PIN_FILE);
33053342 f2fs_i_gc_failures_write(inode, 0);
@@ -4193,6 +4230,8 @@ static int redirty_blocks(struct inode *inode, pgoff_t page_idx, int len) · 887 unmodified lines
41934230 /* It will never fail, when page has pinned above */
41944231 f2fs_bug_on(F2FS_I_SB(inode), !page);
41954232
4233+ f2fs_wait_on_page_writeback(page, DATA, true, true);
4234+
41964235 set_page_dirty(page);
41974236 set_page_private_gcing(page);
41984237 f2fs_put_page(page, 1);
@@ -4207,9 +4246,8 @@ static int f2fs_ioc_decompress_file(struct file *filp) · 8 unmodified lines
42074246 struct inode *inode = file_inode(filp);
42084247 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
42094248 struct f2fs_inode_info *fi = F2FS_I(inode);
4210− pgoff_t page_idx = 0, last_idx;
4211− int cluster_size = fi->i_cluster_size;
4212− int count, ret;
4249+ pgoff_t page_idx = 0, last_idx, cluster_idx;
4250+ int ret;
42134251
42144252 if (!f2fs_sb_has_compression(sbi) ||
42154253 F2FS_OPTION(sbi).compress_mode != COMPR_MODE_USER)
@@ -4244,10 +4282,15 @@ static int f2fs_ioc_decompress_file(struct file *filp) · 28 unmodified lines
42444282 goto out;
42454283
42464284 last_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
4285+ last_idx >>= fi->i_log_cluster_size;
42474286
4248− count = last_idx - page_idx;
4249− while (count && count >= cluster_size) {
4250− ret = redirty_blocks(inode, page_idx, cluster_size);
4287+ for (cluster_idx = 0; cluster_idx < last_idx; cluster_idx++) {
4288+ page_idx = cluster_idx << fi->i_log_cluster_size;
4289+
4290+ if (!f2fs_is_compressed_cluster(inode, page_idx))
4291+ continue;
4292+
4293+ ret = redirty_blocks(inode, page_idx, fi->i_cluster_size);
42514294 if (ret < 0)
42524295 break;
42534296
@@ -4257,9 +4300,6 @@ static int f2fs_ioc_decompress_file(struct file *filp) · 3 unmodified lines
42574300 break;
42584301 }
42594302
4260− count -= cluster_size;
4261− page_idx += cluster_size;
4262−
42634303 cond_resched();
42644304 if (fatal_signal_pending(current)) {
42654305 ret = -EINTR;
@@ -4286,9 +4326,9 @@ static int f2fs_ioc_compress_file(struct file *filp) · 20 unmodified lines
42864326 {
42874327 struct inode *inode = file_inode(filp);
42884328 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
4289− pgoff_t page_idx = 0, last_idx;
4290− int cluster_size = F2FS_I(inode)->i_cluster_size;
4291− int count, ret;
4329+ struct f2fs_inode_info *fi = F2FS_I(inode);
4330+ pgoff_t page_idx = 0, last_idx, cluster_idx;
4331+ int ret;
42924332
42934333 if (!f2fs_sb_has_compression(sbi) ||
42944334 F2FS_OPTION(sbi).compress_mode != COMPR_MODE_USER)
@@ -4322,10 +4362,15 @@ static int f2fs_ioc_compress_file(struct file *filp) · 27 unmodified lines
43224362 set_inode_flag(inode, FI_ENABLE_COMPRESS);
43234363
43244364 last_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
4365+ last_idx >>= fi->i_log_cluster_size;
4366+
4367+ for (cluster_idx = 0; cluster_idx < last_idx; cluster_idx++) {
4368+ page_idx = cluster_idx << fi->i_log_cluster_size;
4369+
4370+ if (f2fs_is_sparse_cluster(inode, page_idx))
4371+ continue;
43254372
4326− count = last_idx - page_idx;
4327− while (count && count >= cluster_size) {
4328− ret = redirty_blocks(inode, page_idx, cluster_size);
4373+ ret = redirty_blocks(inode, page_idx, fi->i_cluster_size);
43294374 if (ret < 0)
43304375 break;
43314376
@@ -4335,9 +4380,6 @@ static int f2fs_ioc_compress_file(struct file *filp) · 3 unmodified lines
43354380 break;
43364381 }
43374382
4338− count -= cluster_size;
4339− page_idx += cluster_size;
4340−
43414383 cond_resched();
43424384 if (fatal_signal_pending(current)) {
43434385 ret = -EINTR;
@@ -4538,6 +4580,13 @@ static ssize_t f2fs_dio_read_iter(struct kiocb *iocb, struct iov_iter *to) · 194 unmodified lines
45384580 f2fs_down_read(&fi->i_gc_rwsem[READ]);
45394581 }
45404582
4583+ /* dio is not compatible w/ atomic file */
4584+ if (f2fs_is_atomic_file(inode)) {
4585+ f2fs_up_read(&fi->i_gc_rwsem[READ]);
4586+ ret = -EOPNOTSUPP;
4587+ goto out;
4588+ }
4589+
45414590 /*
45424591 * We have to use __iomap_dio_rw() and iomap_dio_complete() instead of
45434592 * the higher-level function iomap_dio_rw() in order to ensure that the
@@ -4597,6 +4646,10 @@ static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) · 53 unmodified lines
45974646 f2fs_trace_rw_file_path(iocb->ki_filp, iocb->ki_pos,
45984647 iov_iter_count(to), READ);
45994648
4649+ /* In LFS mode, if there is inflight dio, wait for its completion */
4650+ if (f2fs_lfs_mode(F2FS_I_SB(inode)))
4651+ inode_dio_wait(inode);
4652+
46004653 if (f2fs_should_use_dio(inode, iocb, to)) {
46014654 ret = f2fs_dio_read_iter(iocb, to);
46024655 } else {
@@ -4949,6 +5002,12 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · 346 unmodified lines
49495002 /* Determine whether we will do a direct write or a buffered write. */
49505003 dio = f2fs_should_use_dio(inode, iocb, from);
49515004
5005+ /* dio is not compatible w/ atomic write */
5006+ if (dio && f2fs_is_atomic_file(inode)) {
5007+ ret = -EOPNOTSUPP;
5008+ goto out_unlock;
5009+ }
5010+
49525011 /* Possibly preallocate the blocks for the write. */
49535012 target_size = iocb->ki_pos + iov_iter_count(from);
49545013 preallocated = f2fs_preallocate_blocks(iocb, from, dio);
fs/f2fs/gc.c+86−27
@@ -81,6 +81,8 @@ static int gc_thread_func(void *data) · 80 unmodified lines
8181 continue;
8282 }
8383
84+ gc_control.one_time = false;
85+
8486 /*
8587 * [GC triggering condition]
8688 * 0. GC is not conducted currently.
@@ -116,15 +118,30 @@ static int gc_thread_func(void *data) · 29 unmodified lines
116118 goto next;
117119 }
118120
119− if (has_enough_invalid_blocks(sbi))
121+ if (f2fs_sb_has_blkzoned(sbi)) {
122+ if (has_enough_free_blocks(sbi,
123+ gc_th->no_zoned_gc_percent)) {
124+ wait_ms = gc_th->no_gc_sleep_time;
125+ f2fs_up_write(&sbi->gc_lock);
126+ goto next;
127+ }
128+ if (wait_ms == gc_th->no_gc_sleep_time)
129+ wait_ms = gc_th->max_sleep_time;
130+ }
131+
132+ if (need_to_boost_gc(sbi)) {
120133 decrease_sleep_time(gc_th, &wait_ms);
121− else
134+ if (f2fs_sb_has_blkzoned(sbi))
135+ gc_control.one_time = true;
136+ } else {
122137 increase_sleep_time(gc_th, &wait_ms);
138+ }
123139 do_gc:
124140 stat_inc_gc_call_count(sbi, foreground ?
125141 FOREGROUND : BACKGROUND);
126142
127− sync_mode = F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC;
143+ sync_mode = (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC) ||
144+ gc_control.one_time;
128145
129146 /* foreground GC was been triggered via f2fs_balance_fs() */
130147 if (foreground)
@@ -179,9 +196,21 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi) · 48 unmodified lines
179196 return -ENOMEM;
180197
181198 gc_th->urgent_sleep_time = DEF_GC_THREAD_URGENT_SLEEP_TIME;
182− gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME;
183− gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME;
184− gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME;
199+ gc_th->valid_thresh_ratio = DEF_GC_THREAD_VALID_THRESH_RATIO;
200+
201+ if (f2fs_sb_has_blkzoned(sbi)) {
202+ gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED;
203+ gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME_ZONED;
204+ gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME_ZONED;
205+ gc_th->no_zoned_gc_percent = LIMIT_NO_ZONED_GC;
206+ gc_th->boost_zoned_gc_percent = LIMIT_BOOST_ZONED_GC;
207+ } else {
208+ gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME;
209+ gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME;
210+ gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME;
211+ gc_th->no_zoned_gc_percent = 0;
212+ gc_th->boost_zoned_gc_percent = 0;
213+ }
185214
186215 gc_th->gc_wake = false;
187216
@@ -339,7 +368,7 @@ static unsigned int get_cb_cost(struct f2fs_sb_info *sbi, unsigned int segno) · 151 unmodified lines
339368 unsigned char age = 0;
340369 unsigned char u;
341370 unsigned int i;
342− unsigned int usable_segs_per_sec = f2fs_usable_segs_in_sec(sbi, segno);
371+ unsigned int usable_segs_per_sec = f2fs_usable_segs_in_sec(sbi);
343372
344373 for (i = 0; i < usable_segs_per_sec; i++)
345374 mtime += get_seg_entry(sbi, start + i)->mtime;
@@ -368,6 +397,11 @@ static inline unsigned int get_gc_cost(struct f2fs_sb_info *sbi, · 22 unmodified lines
368397 if (p->alloc_mode == SSR)
369398 return get_seg_entry(sbi, segno)->ckpt_valid_blocks;
370399
400+ if (p->one_time_gc && (get_valid_blocks(sbi, segno, true) >=
401+ CAP_BLKS_PER_SEC(sbi) * sbi->gc_thread->valid_thresh_ratio /
402+ 100))
403+ return UINT_MAX;
404+
371405 /* alloc_mode == LFS */
372406 if (p->gc_mode == GC_GREEDY)
373407 return get_valid_blocks(sbi, segno, true);
@@ -742,7 +776,7 @@ static int f2fs_gc_pinned_control(struct inode *inode, int gc_type, · 368 unmodified lines
742776 */
743777 int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result,
744778 int gc_type, int type, char alloc_mode,
745− unsigned long long age)
779+ unsigned long long age, bool one_time)
746780 {
747781 struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
748782 struct sit_info *sm = SIT_I(sbi);
@@ -759,6 +793,7 @@ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result, · 10 unmodified lines
759793 p.alloc_mode = alloc_mode;
760794 p.age = age;
761795 p.age_threshold = sbi->am.age_threshold;
796+ p.one_time_gc = one_time;
762797
763798 retry:
764799 select_policy(sbi, gc_type, type, &p);
@@ -1670,13 +1705,14 @@ next_step: · 905 unmodified lines
16701705 }
16711706
16721707 static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim,
1673− int gc_type)
1708+ int gc_type, bool one_time)
16741709 {
16751710 struct sit_info *sit_i = SIT_I(sbi);
16761711 int ret;
16771712
16781713 down_write(&sit_i->sentry_lock);
1679− ret = f2fs_get_victim(sbi, victim, gc_type, NO_CHECK_TYPE, LFS, 0);
1714+ ret = f2fs_get_victim(sbi, victim, gc_type, NO_CHECK_TYPE,
1715+ LFS, 0, one_time);
16801716 up_write(&sit_i->sentry_lock);
16811717 return ret;
16821718 }
@@ -1684,30 +1720,49 @@ static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim, · 1 unmodified line
16841720 static int do_garbage_collect(struct f2fs_sb_info *sbi,
16851721 unsigned int start_segno,
16861722 struct gc_inode_list *gc_list, int gc_type,
1687− bool force_migrate)
1723+ bool force_migrate, bool one_time)
16881724 {
16891725 struct page *sum_page;
16901726 struct f2fs_summary_block *sum;
16911727 struct blk_plug plug;
16921728 unsigned int segno = start_segno;
16931729 unsigned int end_segno = start_segno + SEGS_PER_SEC(sbi);
1730+ unsigned int sec_end_segno;
16941731 int seg_freed = 0, migrated = 0;
16951732 unsigned char type = IS_DATASEG(get_seg_entry(sbi, segno)->type) ?
16961733 SUM_TYPE_DATA : SUM_TYPE_NODE;
16971734 unsigned char data_type = (type == SUM_TYPE_DATA) ? DATA : NODE;
16981735 int submitted = 0;
16991736
1700− if (__is_large_section(sbi))
1701− end_segno = rounddown(end_segno, SEGS_PER_SEC(sbi));
1737+ if (__is_large_section(sbi)) {
1738+ sec_end_segno = rounddown(end_segno, SEGS_PER_SEC(sbi));
17021739
1703− /*
1704− * zone-capacity can be less than zone-size in zoned devices,
1705− * resulting in less than expected usable segments in the zone,
1706− * calculate the end segno in the zone which can be garbage collected
1707− */
1708− if (f2fs_sb_has_blkzoned(sbi))
1709− end_segno -= SEGS_PER_SEC(sbi) -
1710− f2fs_usable_segs_in_sec(sbi, segno);
1740+ /*
1741+ * zone-capacity can be less than zone-size in zoned devices,
1742+ * resulting in less than expected usable segments in the zone,
1743+ * calculate the end segno in the zone which can be garbage
1744+ * collected
1745+ */
1746+ if (f2fs_sb_has_blkzoned(sbi))
1747+ sec_end_segno -= SEGS_PER_SEC(sbi) -
1748+ f2fs_usable_segs_in_sec(sbi);
1749+
1750+ if (gc_type == BG_GC || one_time) {
1751+ unsigned int window_granularity =
1752+ sbi->migration_window_granularity;
1753+
1754+ if (f2fs_sb_has_blkzoned(sbi) &&
1755+ !has_enough_free_blocks(sbi,
1756+ sbi->gc_thread->boost_zoned_gc_percent))
1757+ window_granularity *=
1758+ BOOST_GC_MULTIPLE;
1759+
1760+ end_segno = start_segno + window_granularity;
1761+ }
1762+
1763+ if (end_segno > sec_end_segno)
1764+ end_segno = sec_end_segno;
1765+ }
17111766
17121767 sanity_check_seg_type(sbi, get_seg_entry(sbi, segno)->type);
17131768
@@ -1786,7 +1841,8 @@ freed: · 72 unmodified lines
17861841
17871842 if (__is_large_section(sbi))
17881843 sbi->next_victim_seg[gc_type] =
1789− (segno + 1 < end_segno) ? segno + 1 : NULL_SEGNO;
1844+ (segno + 1 < sec_end_segno) ?
1845+ segno + 1 : NULL_SEGNO;
17901846 skip:
17911847 f2fs_put_page(sum_page, 0);
17921848 }
@@ -1863,7 +1919,7 @@ gc_more: · 70 unmodified lines
18631919 goto stop;
18641920 }
18651921 retry:
1866− ret = __get_victim(sbi, &segno, gc_type);
1922+ ret = __get_victim(sbi, &segno, gc_type, gc_control->one_time);
18671923 if (ret) {
18681924 /* allow to search victim from sections has pinned data */
18691925 if (ret == -ENODATA && gc_type == FG_GC &&
@@ -1875,17 +1931,21 @@ retry: · 5 unmodified lines
18751931 }
18761932
18771933 seg_freed = do_garbage_collect(sbi, segno, &gc_list, gc_type,
1878− gc_control->should_migrate_blocks);
1934+ gc_control->should_migrate_blocks,
1935+ gc_control->one_time);
18791936 if (seg_freed < 0)
18801937 goto stop;
18811938
18821939 total_freed += seg_freed;
18831940
1884− if (seg_freed == f2fs_usable_segs_in_sec(sbi, segno)) {
1941+ if (seg_freed == f2fs_usable_segs_in_sec(sbi)) {
18851942 sec_freed++;
18861943 total_sec_freed++;
18871944 }
18881945
1946+ if (gc_control->one_time)
1947+ goto stop;
1948+
18891949 if (gc_type == FG_GC) {
18901950 sbi->cur_victim_sec = NULL_SEGNO;
18911951
@@ -2010,8 +2070,7 @@ int f2fs_gc_range(struct f2fs_sb_info *sbi, · 118 unmodified lines
20102070 .iroot = RADIX_TREE_INIT(gc_list.iroot, GFP_NOFS),
20112071 };
20122072
2013− do_garbage_collect(sbi, segno, &gc_list, FG_GC,
2014− dry_run_sections == 0);
2073+ do_garbage_collect(sbi, segno, &gc_list, FG_GC, true, false);
20152074 put_gc_inode(&gc_list);
20162075
20172076 if (!dry_run && get_valid_blocks(sbi, segno, true))
fs/f2fs/gc.h+29−0
@@ -15,16 +15,27 @@ · 14 unmodified lines
1515 #define DEF_GC_THREAD_MAX_SLEEP_TIME 60000
1616 #define DEF_GC_THREAD_NOGC_SLEEP_TIME 300000 /* wait 5 min */
1717
18+/* GC sleep parameters for zoned deivces */
19+#define DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED 10
20+#define DEF_GC_THREAD_MAX_SLEEP_TIME_ZONED 20
21+#define DEF_GC_THREAD_NOGC_SLEEP_TIME_ZONED 60000
22+
1823 /* choose candidates from sections which has age of more than 7 days */
1924 #define DEF_GC_THREAD_AGE_THRESHOLD (60 * 60 * 24 * 7)
2025 #define DEF_GC_THREAD_CANDIDATE_RATIO 20 /* select 20% oldest sections as candidates */
2126 #define DEF_GC_THREAD_MAX_CANDIDATE_COUNT 10 /* select at most 10 sections as candidates */
2227 #define DEF_GC_THREAD_AGE_WEIGHT 60 /* age weight */
28+#define DEF_GC_THREAD_VALID_THRESH_RATIO 95 /* do not GC over 95% valid block ratio for one time GC */
2329 #define DEFAULT_ACCURACY_CLASS 10000 /* accuracy class */
2430
2531 #define LIMIT_INVALID_BLOCK 40 /* percentage over total user space */
2632 #define LIMIT_FREE_BLOCK 40 /* percentage over invalid + free space */
2733
34+#define LIMIT_NO_ZONED_GC 60 /* percentage over total user space of no gc for zoned devices */
35+#define LIMIT_BOOST_ZONED_GC 25 /* percentage over total user space of boosted gc for zoned devices */
36+#define DEF_MIGRATION_WINDOW_GRANULARITY_ZONED 3
37+#define BOOST_GC_MULTIPLE 5
38+
2839 #define DEF_GC_FAILED_PINNED_FILES 2048
2940 #define MAX_GC_FAILED_PINNED_FILES USHRT_MAX
3041
@@ -51,6 +62,11 @@ struct f2fs_gc_kthread { · 20 unmodified lines
5162 * caller of f2fs_balance_fs()
5263 * will wait on this wait queue.
5364 */
65+
66+ /* for gc control for zoned devices */
67+ unsigned int no_zoned_gc_percent;
68+ unsigned int boost_zoned_gc_percent;
69+ unsigned int valid_thresh_ratio;
5470 };
5571
5672 struct gc_inode_list {
@@ -152,6 +168,12 @@ static inline void decrease_sleep_time(struct f2fs_gc_kthread *gc_th, · 95 unmodified lines
152168 *wait -= min_time;
153169 }
154170
171+static inline bool has_enough_free_blocks(struct f2fs_sb_info *sbi,
172+ unsigned int limit_perc)
173+{
174+ return free_sections(sbi) > ((sbi->total_sections * limit_perc) / 100);
175+}
176+
155177 static inline bool has_enough_invalid_blocks(struct f2fs_sb_info *sbi)
156178 {
157179 block_t user_block_count = sbi->user_block_count;
@@ -167,3 +189,10 @@ static inline bool has_enough_invalid_blocks(struct f2fs_sb_info *sbi) · 9 unmodified lines
167189 free_user_blocks(sbi) <
168190 limit_free_user_blocks(invalid_user_blocks));
169191 }
192+
193+static inline bool need_to_boost_gc(struct f2fs_sb_info *sbi)
194+{
195+ if (f2fs_sb_has_blkzoned(sbi))
196+ return !has_enough_free_blocks(sbi, LIMIT_BOOST_ZONED_GC);
197+ return has_enough_invalid_blocks(sbi);
198+}
fs/f2fs/inline.c+15−16
@@ -260,35 +260,34 @@ out: · 259 unmodified lines
260260 return err;
261261 }
262262
263−int f2fs_write_inline_data(struct inode *inode, struct page *page)
263+int f2fs_write_inline_data(struct inode *inode, struct folio *folio)
264264 {
265− struct dnode_of_data dn;
266− int err;
265+ struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
266+ struct page *ipage;
267267
268− set_new_dnode(&dn, inode, NULL, NULL, 0);
269− err = f2fs_get_dnode_of_data(&dn, 0, LOOKUP_NODE);
270− if (err)
271− return err;
268+ ipage = f2fs_get_node_page(sbi, inode->i_ino);
269+ if (IS_ERR(ipage))
270+ return PTR_ERR(ipage);
272271
273272 if (!f2fs_has_inline_data(inode)) {
274− f2fs_put_dnode(&dn);
273+ f2fs_put_page(ipage, 1);
275274 return -EAGAIN;
276275 }
277276
278− f2fs_bug_on(F2FS_I_SB(inode), page->index);
277+ f2fs_bug_on(F2FS_I_SB(inode), folio->index);
279278
280− f2fs_wait_on_page_writeback(dn.inode_page, NODE, true, true);
281− memcpy_from_page(inline_data_addr(inode, dn.inode_page),
282− page, 0, MAX_INLINE_DATA(inode));
283− set_page_dirty(dn.inode_page);
279+ f2fs_wait_on_page_writeback(ipage, NODE, true, true);
280+ memcpy_from_folio(inline_data_addr(inode, ipage),
281+ folio, 0, MAX_INLINE_DATA(inode));
282+ set_page_dirty(ipage);
284283
285− f2fs_clear_page_cache_dirty_tag(page);
284+ f2fs_clear_page_cache_dirty_tag(folio);
286285
287286 set_inode_flag(inode, FI_APPEND_WRITE);
288287 set_inode_flag(inode, FI_DATA_EXIST);
289288
290− clear_page_private_inline(dn.inode_page);
291− f2fs_put_dnode(&dn);
289+ clear_page_private_inline(ipage);
290+ f2fs_put_page(ipage, 1);
292291 return 0;
293292 }
294293
fs/f2fs/inode.c+7−2
@@ -7,7 +7,6 @@ · 6 unmodified lines
77 */
88 #include <linux/fs.h>
99 #include <linux/f2fs_fs.h>
10−#include <linux/buffer_head.h>
1110 #include <linux/writeback.h>
1211 #include <linux/sched/mm.h>
1312 #include <linux/lz4.h>
@@ -35,6 +34,11 @@ void f2fs_mark_inode_dirty_sync(struct inode *inode, bool sync) · 21 unmodified lines
3534 if (f2fs_inode_dirtied(inode, sync))
3635 return;
3736
37+ if (f2fs_is_atomic_file(inode)) {
38+ set_inode_flag(inode, FI_ATOMIC_DIRTIED);
39+ return;
40+ }
41+
3842 mark_inode_dirty_sync(inode);
3943 }
4044
@@ -175,7 +179,8 @@ bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page) · 134 unmodified lines
175179
176180 if (provided != calculated)
177181 f2fs_warn(sbi, "checksum invalid, nid = %lu, ino_of_node = %x, %x vs. %x",
178− page->index, ino_of_node(page), provided, calculated);
182+ page_folio(page)->index, ino_of_node(page),
183+ provided, calculated);
179184
180185 return provided == calculated;
181186 }
fs/f2fs/namei.c+0−68
@@ -457,62 +457,6 @@ struct dentry *f2fs_get_parent(struct dentry *child) · 456 unmodified lines
457457 return d_obtain_alias(f2fs_iget(child->d_sb, ino));
458458 }
459459
460−static int __recover_dot_dentries(struct inode *dir, nid_t pino)
461−{
462− struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
463− struct qstr dot = QSTR_INIT(".", 1);
464− struct f2fs_dir_entry *de;
465− struct page *page;
466− int err = 0;
467−
468− if (f2fs_readonly(sbi->sb)) {
469− f2fs_info(sbi, "skip recovering inline_dots inode (ino:%lu, pino:%u) in readonly mountpoint",
470− dir->i_ino, pino);
471− return 0;
472− }
473−
474− if (!S_ISDIR(dir->i_mode)) {
475− f2fs_err(sbi, "inconsistent inode status, skip recovering inline_dots inode (ino:%lu, i_mode:%u, pino:%u)",
476− dir->i_ino, dir->i_mode, pino);
477− set_sbi_flag(sbi, SBI_NEED_FSCK);
478− return -ENOTDIR;
479− }
480−
481− err = f2fs_dquot_initialize(dir);
482− if (err)
483− return err;
484−
485− f2fs_balance_fs(sbi, true);
486−
487− f2fs_lock_op(sbi);
488−
489− de = f2fs_find_entry(dir, &dot, &page);
490− if (de) {
491− f2fs_put_page(page, 0);
492− } else if (IS_ERR(page)) {
493− err = PTR_ERR(page);
494− goto out;
495− } else {
496− err = f2fs_do_add_link(dir, &dot, NULL, dir->i_ino, S_IFDIR);
497− if (err)
498− goto out;
499− }
500−
501− de = f2fs_find_entry(dir, &dotdot_name, &page);
502− if (de)
503− f2fs_put_page(page, 0);
504− else if (IS_ERR(page))
505− err = PTR_ERR(page);
506− else
507− err = f2fs_do_add_link(dir, &dotdot_name, NULL, pino, S_IFDIR);
508−out:
509− if (!err)
510− clear_inode_flag(dir, FI_INLINE_DOTS);
511−
512− f2fs_unlock_op(sbi);
513− return err;
514−}
515−
516460 static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
517461 unsigned int flags)
518462 {
@@ -522,7 +466,6 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry, · 3 unmodified lines
522466 struct dentry *new;
523467 nid_t ino = -1;
524468 int err = 0;
525− unsigned int root_ino = F2FS_ROOT_INO(F2FS_I_SB(dir));
526469 struct f2fs_filename fname;
527470
528471 trace_f2fs_lookup_start(dir, dentry, flags);
@@ -558,17 +501,6 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry, · 29 unmodified lines
558501 goto out;
559502 }
560503
561− if ((dir->i_ino == root_ino) && f2fs_has_inline_dots(dir)) {
562− err = __recover_dot_dentries(dir, root_ino);
563− if (err)
564− goto out_iput;
565− }
566−
567− if (f2fs_has_inline_dots(inode)) {
568− err = __recover_dot_dentries(inode, dir->i_ino);
569− if (err)
570− goto out_iput;
571− }
572504 if (IS_ENCRYPTED(dir) &&
573505 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
574506 !fscrypt_has_permitted_context(dir, inode)) {
fs/f2fs/node.c+24−22
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020 #include "iostat.h"
2121 #include <trace/events/f2fs.h>
2222
23−#define on_f2fs_build_free_nids(nmi) mutex_is_locked(&(nm_i)->build_lock)
23+#define on_f2fs_build_free_nids(nm_i) mutex_is_locked(&(nm_i)->build_lock)
2424
2525 static struct kmem_cache *nat_entry_slab;
2626 static struct kmem_cache *free_nid_slab;
@@ -123,7 +123,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type) · 96 unmodified lines
123123 static void clear_node_page_dirty(struct page *page)
124124 {
125125 if (PageDirty(page)) {
126− f2fs_clear_page_cache_dirty_tag(page);
126+ f2fs_clear_page_cache_dirty_tag(page_folio(page));
127127 clear_page_dirty_for_io(page);
128128 dec_page_count(F2FS_P_SB(page), F2FS_DIRTY_NODES);
129129 }
@@ -919,7 +919,7 @@ static int truncate_node(struct dnode_of_data *dn) · 789 unmodified lines
919919 clear_node_page_dirty(dn->node_page);
920920 set_sbi_flag(sbi, SBI_IS_DIRTY);
921921
922− index = dn->node_page->index;
922+ index = page_folio(dn->node_page)->index;
923923 f2fs_put_page(dn->node_page, 1);
924924
925925 invalidate_mapping_pages(NODE_MAPPING(sbi),
@@ -1369,6 +1369,7 @@ fail: · 443 unmodified lines
13691369 */
13701370 static int read_node_page(struct page *page, blk_opf_t op_flags)
13711371 {
1372+ struct folio *folio = page_folio(page);
13721373 struct f2fs_sb_info *sbi = F2FS_P_SB(page);
13731374 struct node_info ni;
13741375 struct f2fs_io_info fio = {
@@ -1381,21 +1382,21 @@ static int read_node_page(struct page *page, blk_opf_t op_flags) · 6 unmodified lines
13811382 };
13821383 int err;
13831384
1384− if (PageUptodate(page)) {
1385+ if (folio_test_uptodate(folio)) {
13851386 if (!f2fs_inode_chksum_verify(sbi, page)) {
1386− ClearPageUptodate(page);
1387+ folio_clear_uptodate(folio);
13871388 return -EFSBADCRC;
13881389 }
13891390 return LOCKED_PAGE;
13901391 }
13911392
1392− err = f2fs_get_node_info(sbi, page->index, &ni, false);
1393+ err = f2fs_get_node_info(sbi, folio->index, &ni, false);
13931394 if (err)
13941395 return err;
13951396
13961397 /* NEW_ADDR can be seen, after cp_error drops some dirty node pages */
13971398 if (unlikely(ni.blk_addr == NULL_ADDR || ni.blk_addr == NEW_ADDR)) {
1398− ClearPageUptodate(page);
1399+ folio_clear_uptodate(folio);
13991400 return -ENOENT;
14001401 }
14011402
@@ -1492,7 +1493,7 @@ out_err: · 90 unmodified lines
14921493 out_put_err:
14931494 /* ENOENT comes from read_node_page which is not an error. */
14941495 if (err != -ENOENT)
1495− f2fs_handle_page_eio(sbi, page->index, NODE);
1496+ f2fs_handle_page_eio(sbi, page_folio(page), NODE);
14961497 f2fs_put_page(page, 1);
14971498 return ERR_PTR(err);
14981499 }
@@ -1535,7 +1536,7 @@ static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino) · 36 unmodified lines
15351536 if (!clear_page_dirty_for_io(page))
15361537 goto page_out;
15371538
1538− ret = f2fs_write_inline_data(inode, page);
1539+ ret = f2fs_write_inline_data(inode, page_folio(page));
15391540 inode_dec_dirty_pages(inode);
15401541 f2fs_remove_dirty_inode(inode);
15411542 if (ret)
@@ -1608,6 +1609,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, · 66 unmodified lines
16081609 enum iostat_type io_type, unsigned int *seq_id)
16091610 {
16101611 struct f2fs_sb_info *sbi = F2FS_P_SB(page);
1612+ struct folio *folio = page_folio(page);
16111613 nid_t nid;
16121614 struct node_info ni;
16131615 struct f2fs_io_info fio = {
@@ -1624,15 +1626,15 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, · 10 unmodified lines
16241626 };
16251627 unsigned int seq;
16261628
1627− trace_f2fs_writepage(page_folio(page), NODE);
1629+ trace_f2fs_writepage(folio, NODE);
16281630
16291631 if (unlikely(f2fs_cp_error(sbi))) {
16301632 /* keep node pages in remount-ro mode */
16311633 if (F2FS_OPTION(sbi).errors == MOUNT_ERRORS_READONLY)
16321634 goto redirty_out;
1633− ClearPageUptodate(page);
1635+ folio_clear_uptodate(folio);
16341636 dec_page_count(sbi, F2FS_DIRTY_NODES);
1635− unlock_page(page);
1637+ folio_unlock(folio);
16361638 return 0;
16371639 }
16381640
@@ -1646,7 +1648,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, · 7 unmodified lines
16461648
16471649 /* get old block addr of this node page */
16481650 nid = nid_of_node(page);
1649− f2fs_bug_on(sbi, page->index != nid);
1651+ f2fs_bug_on(sbi, folio->index != nid);
16501652
16511653 if (f2fs_get_node_info(sbi, nid, &ni, !do_balance))
16521654 goto redirty_out;
@@ -1660,10 +1662,10 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, · 7 unmodified lines
16601662
16611663 /* This page is already truncated */
16621664 if (unlikely(ni.blk_addr == NULL_ADDR)) {
1663− ClearPageUptodate(page);
1665+ folio_clear_uptodate(folio);
16641666 dec_page_count(sbi, F2FS_DIRTY_NODES);
16651667 f2fs_up_read(&sbi->node_write);
1666− unlock_page(page);
1668+ folio_unlock(folio);
16671669 return 0;
16681670 }
16691671
@@ -1674,7 +1676,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, · 4 unmodified lines
16741676 goto redirty_out;
16751677 }
16761678
1677− if (atomic && !test_opt(sbi, NOBARRIER) && !f2fs_sb_has_blkzoned(sbi))
1679+ if (atomic && !test_opt(sbi, NOBARRIER))
16781680 fio.op_flags |= REQ_PREFLUSH | REQ_FUA;
16791681
16801682 /* should add to global list before clearing PAGECACHE status */
@@ -1684,7 +1686,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, · 3 unmodified lines
16841686 *seq_id = seq;
16851687 }
16861688
1687− set_page_writeback(page);
1689+ folio_start_writeback(folio);
16881690
16891691 fio.old_blkaddr = ni.blk_addr;
16901692 f2fs_do_write_node_page(nid, &fio);
@@ -1697,7 +1699,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, · 6 unmodified lines
16971699 submitted = NULL;
16981700 }
16991701
1700− unlock_page(page);
1702+ folio_unlock(folio);
17011703
17021704 if (unlikely(f2fs_cp_error(sbi))) {
17031705 f2fs_submit_merged_write(sbi, NODE);
@@ -1711,7 +1713,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, · 7 unmodified lines
17111713 return 0;
17121714
17131715 redirty_out:
1714− redirty_page_for_writepage(wbc, page);
1716+ folio_redirty_for_writepage(wbc, folio);
17151717 return AOP_WRITEPAGE_ACTIVATE;
17161718 }
17171719
@@ -1867,7 +1869,7 @@ continue_unlock: · 149 unmodified lines
18671869 }
18681870 if (!ret && atomic && !marked) {
18691871 f2fs_debug(sbi, "Retry to write fsync mark: ino=%u, idx=%lx",
1870− ino, last_page->index);
1872+ ino, page_folio(last_page)->index);
18711873 lock_page(last_page);
18721874 f2fs_wait_on_page_writeback(last_page, NODE, true, true);
18731875 set_page_dirty(last_page);
@@ -3166,7 +3168,7 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi) · 1292 unmodified lines
31663168
31673169 nm_i->nat_bits_blocks = F2FS_BLK_ALIGN((nat_bits_bytes << 1) + 8);
31683170 nm_i->nat_bits = f2fs_kvzalloc(sbi,
3169− nm_i->nat_bits_blocks << F2FS_BLKSIZE_BITS, GFP_KERNEL);
3171+ F2FS_BLK_TO_BYTES(nm_i->nat_bits_blocks), GFP_KERNEL);
31703172 if (!nm_i->nat_bits)
31713173 return -ENOMEM;
31723174
@@ -3185,7 +3187,7 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi) · 12 unmodified lines
31853187 if (IS_ERR(page))
31863188 return PTR_ERR(page);
31873189
3188− memcpy(nm_i->nat_bits + (i << F2FS_BLKSIZE_BITS),
3190+ memcpy(nm_i->nat_bits + F2FS_BLK_TO_BYTES(i),
31893191 page_address(page), F2FS_BLKSIZE);
31903192 f2fs_put_page(page, 1);
31913193 }
fs/f2fs/segment.c+56−16
@@ -199,6 +199,10 @@ void f2fs_abort_atomic_write(struct inode *inode, bool clean) · 198 unmodified lines
199199 clear_inode_flag(inode, FI_ATOMIC_COMMITTED);
200200 clear_inode_flag(inode, FI_ATOMIC_REPLACE);
201201 clear_inode_flag(inode, FI_ATOMIC_FILE);
202+ if (is_inode_flag_set(inode, FI_ATOMIC_DIRTIED)) {
203+ clear_inode_flag(inode, FI_ATOMIC_DIRTIED);
204+ f2fs_mark_inode_dirty_sync(inode, true);
205+ }
202206 stat_dec_atomic_inode(inode);
203207
204208 F2FS_I(inode)->atomic_write_task = NULL;
@@ -366,6 +370,10 @@ out: · 161 unmodified lines
366370 } else {
367371 sbi->committed_atomic_block += fi->atomic_write_cnt;
368372 set_inode_flag(inode, FI_ATOMIC_COMMITTED);
373+ if (is_inode_flag_set(inode, FI_ATOMIC_DIRTIED)) {
374+ clear_inode_flag(inode, FI_ATOMIC_DIRTIED);
375+ f2fs_mark_inode_dirty_sync(inode, true);
376+ }
369377 }
370378
371379 __complete_revoke_list(inode, &revoke_list, ret ? true : false);
@@ -1282,6 +1290,13 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi, · 910 unmodified lines
12821290 wait_list, issued);
12831291 return 0;
12841292 }
1293+
1294+ /*
1295+ * Issue discard for conventional zones only if the device
1296+ * supports discard.
1297+ */
1298+ if (!bdev_max_discard_sectors(bdev))
1299+ return -EOPNOTSUPP;
12851300 }
12861301 #endif
12871302
@@ -2686,22 +2701,47 @@ static int get_new_segment(struct f2fs_sb_info *sbi, · 1398 unmodified lines
26862701 goto got_it;
26872702 }
26882703
2704+#ifdef CONFIG_BLK_DEV_ZONED
26892705 /*
26902706 * If we format f2fs on zoned storage, let's try to get pinned sections
26912707 * from beginning of the storage, which should be a conventional one.
26922708 */
26932709 if (f2fs_sb_has_blkzoned(sbi)) {
2694− segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
2710+ /* Prioritize writing to conventional zones */
2711+ if (sbi->blkzone_alloc_policy == BLKZONE_ALLOC_PRIOR_CONV || pinning)
2712+ segno = 0;
2713+ else
2714+ segno = max(first_zoned_segno(sbi), *newseg);
26952715 hint = GET_SEC_FROM_SEG(sbi, segno);
26962716 }
2717+#endif
26972718
26982719 find_other_zone:
26992720 secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
2721+
2722+#ifdef CONFIG_BLK_DEV_ZONED
2723+ if (secno >= MAIN_SECS(sbi) && f2fs_sb_has_blkzoned(sbi)) {
2724+ /* Write only to sequential zones */
2725+ if (sbi->blkzone_alloc_policy == BLKZONE_ALLOC_ONLY_SEQ) {
2726+ hint = GET_SEC_FROM_SEG(sbi, first_zoned_segno(sbi));
2727+ secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
2728+ } else
2729+ secno = find_first_zero_bit(free_i->free_secmap,
2730+ MAIN_SECS(sbi));
2731+ if (secno >= MAIN_SECS(sbi)) {
2732+ ret = -ENOSPC;
2733+ f2fs_bug_on(sbi, 1);
2734+ goto out_unlock;
2735+ }
2736+ }
2737+#endif
2738+
27002739 if (secno >= MAIN_SECS(sbi)) {
27012740 secno = find_first_zero_bit(free_i->free_secmap,
27022741 MAIN_SECS(sbi));
27032742 if (secno >= MAIN_SECS(sbi)) {
27042743 ret = -ENOSPC;
2744+ f2fs_bug_on(sbi, 1);
27052745 goto out_unlock;
27062746 }
27072747 }
@@ -2743,10 +2783,8 @@ got_it: · 35 unmodified lines
27432783 out_unlock:
27442784 spin_unlock(&free_i->segmap_lock);
27452785
2746− if (ret == -ENOSPC) {
2786+ if (ret == -ENOSPC)
27472787 f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_NO_SEGMENT);
2748− f2fs_bug_on(sbi, 1);
2749− }
27502788 return ret;
27512789 }
27522790
@@ -3052,7 +3090,8 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type, · 299 unmodified lines
30523090 sanity_check_seg_type(sbi, seg_type);
30533091
30543092 /* f2fs_need_SSR() already forces to do this */
3055− if (!f2fs_get_victim(sbi, &segno, BG_GC, seg_type, alloc_mode, age)) {
3093+ if (!f2fs_get_victim(sbi, &segno, BG_GC, seg_type,
3094+ alloc_mode, age, false)) {
30563095 curseg->next_segno = segno;
30573096 return 1;
30583097 }
@@ -3079,7 +3118,8 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type, · 20 unmodified lines
30793118 for (; cnt-- > 0; reversed ? i-- : i++) {
30803119 if (i == seg_type)
30813120 continue;
3082− if (!f2fs_get_victim(sbi, &segno, BG_GC, i, alloc_mode, age)) {
3121+ if (!f2fs_get_victim(sbi, &segno, BG_GC, i,
3122+ alloc_mode, age, false)) {
30833123 curseg->next_segno = segno;
30843124 return 1;
30853125 }
@@ -3522,7 +3562,8 @@ static int __get_segment_type_6(struct f2fs_io_info *fio) · 436 unmodified lines
35223562 if (file_is_cold(inode) || f2fs_need_compress_data(inode))
35233563 return CURSEG_COLD_DATA;
35243564
3525− type = __get_age_segment_type(inode, fio->page->index);
3565+ type = __get_age_segment_type(inode,
3566+ page_folio(fio->page)->index);
35263567 if (type != NO_CHECK_TYPE)
35273568 return type;
35283569
@@ -3781,7 +3822,7 @@ out: · 252 unmodified lines
37813822 f2fs_up_read(&fio->sbi->io_order_lock);
37823823 }
37833824
3784−void f2fs_do_write_meta_page(struct f2fs_sb_info *sbi, struct page *page,
3825+void f2fs_do_write_meta_page(struct f2fs_sb_info *sbi, struct folio *folio,
37853826 enum iostat_type io_type)
37863827 {
37873828 struct f2fs_io_info fio = {
@@ -3790,20 +3831,20 @@ void f2fs_do_write_meta_page(struct f2fs_sb_info *sbi, struct page *page, · 2 unmodified lines
37903831 .temp = HOT,
37913832 .op = REQ_OP_WRITE,
37923833 .op_flags = REQ_SYNC | REQ_META | REQ_PRIO,
3793− .old_blkaddr = page->index,
3794− .new_blkaddr = page->index,
3795− .page = page,
3834+ .old_blkaddr = folio->index,
3835+ .new_blkaddr = folio->index,
3836+ .page = folio_page(folio, 0),
37963837 .encrypted_page = NULL,
37973838 .in_list = 0,
37983839 };
37993840
3800− if (unlikely(page->index >= MAIN_BLKADDR(sbi)))
3841+ if (unlikely(folio->index >= MAIN_BLKADDR(sbi)))
38013842 fio.op_flags &= ~REQ_META;
38023843
3803− set_page_writeback(page);
3844+ folio_start_writeback(folio);
38043845 f2fs_submit_page_write(&fio);
38053846
3806− stat_inc_meta_count(sbi, page->index);
3847+ stat_inc_meta_count(sbi, folio->index);
38073848 f2fs_update_iostat(sbi, NULL, io_type, F2FS_BLKSIZE);
38083849 }
38093850
@@ -5381,8 +5422,7 @@ unsigned int f2fs_usable_blks_in_seg(struct f2fs_sb_info *sbi, · 1571 unmodified lines
53815422 return BLKS_PER_SEG(sbi);
53825423 }
53835424
5384−unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi,
5385− unsigned int segno)
5425+unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi)
53865426 {
53875427 if (f2fs_sb_has_blkzoned(sbi))
53885428 return CAP_SEGS_PER_SEC(sbi);
fs/f2fs/segment.h+3−2
@@ -188,6 +188,7 @@ struct victim_sel_policy { · 187 unmodified lines
188188 unsigned int min_segno; /* segment # having min. cost */
189189 unsigned long long age; /* mtime of GCed section*/
190190 unsigned long long age_threshold;/* age threshold */
191+ bool one_time_gc; /* one time GC */
191192 };
192193
193194 struct seg_entry {
@@ -430,7 +431,7 @@ static inline void __set_free(struct f2fs_sb_info *sbi, unsigned int segno) · 236 unmodified lines
430431 unsigned int secno = GET_SEC_FROM_SEG(sbi, segno);
431432 unsigned int start_segno = GET_SEG_FROM_SEC(sbi, secno);
432433 unsigned int next;
433− unsigned int usable_segs = f2fs_usable_segs_in_sec(sbi, segno);
434+ unsigned int usable_segs = f2fs_usable_segs_in_sec(sbi);
434435
435436 spin_lock(&free_i->segmap_lock);
436437 clear_bit(segno, free_i->free_segmap);
@@ -464,7 +465,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi, · 27 unmodified lines
464465 unsigned int secno = GET_SEC_FROM_SEG(sbi, segno);
465466 unsigned int start_segno = GET_SEG_FROM_SEC(sbi, secno);
466467 unsigned int next;
467− unsigned int usable_segs = f2fs_usable_segs_in_sec(sbi, segno);
468+ unsigned int usable_segs = f2fs_usable_segs_in_sec(sbi);
468469
469470 spin_lock(&free_i->segmap_lock);
470471 if (test_and_clear_bit(segno, free_i->free_segmap)) {
fs/f2fs/super.c+74−45
@@ -11,7 +11,6 @@ · 10 unmodified lines
1111 #include <linux/fs_context.h>
1212 #include <linux/sched/mm.h>
1313 #include <linux/statfs.h>
14−#include <linux/buffer_head.h>
1514 #include <linux/kthread.h>
1615 #include <linux/parser.h>
1716 #include <linux/mount.h>
@@ -707,6 +706,11 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) · 689 unmodified lines
707706 if (!strcmp(name, "on")) {
708707 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON;
709708 } else if (!strcmp(name, "off")) {
709+ if (f2fs_sb_has_blkzoned(sbi)) {
710+ f2fs_warn(sbi, "zoned devices need bggc");
711+ kfree(name);
712+ return -EINVAL;
713+ }
710714 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_OFF;
711715 } else if (!strcmp(name, "sync")) {
712716 F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_SYNC;
@@ -2561,7 +2565,7 @@ restore_opts: · 1848 unmodified lines
25612565
25622566 static void f2fs_shutdown(struct super_block *sb)
25632567 {
2564− f2fs_do_shutdown(F2FS_SB(sb), F2FS_GOING_DOWN_NOSYNC, false);
2568+ f2fs_do_shutdown(F2FS_SB(sb), F2FS_GOING_DOWN_NOSYNC, false, false);
25652569 }
25662570
25672571 #ifdef CONFIG_QUOTA
@@ -3318,29 +3322,47 @@ loff_t max_file_blocks(struct inode *inode) · 750 unmodified lines
33183322 * fit within U32_MAX + 1 data units.
33193323 */
33203324
3321− result = min(result, (((loff_t)U32_MAX + 1) * 4096) >> F2FS_BLKSIZE_BITS);
3325+ result = min(result, F2FS_BYTES_TO_BLK(((loff_t)U32_MAX + 1) * 4096));
33223326
33233327 return result;
33243328 }
33253329
3326−static int __f2fs_commit_super(struct buffer_head *bh,
3327− struct f2fs_super_block *super)
3330+static int __f2fs_commit_super(struct f2fs_sb_info *sbi, struct folio *folio,
3331+ pgoff_t index, bool update)
33283332 {
3329− lock_buffer(bh);
3330− if (super)
3331− memcpy(bh->b_data + F2FS_SUPER_OFFSET, super, sizeof(*super));
3332− set_buffer_dirty(bh);
3333− unlock_buffer(bh);
3334−
3333+ struct bio *bio;
33353334 /* it's rare case, we can do fua all the time */
3336− return __sync_dirty_buffer(bh, REQ_SYNC | REQ_PREFLUSH | REQ_FUA);
3335+ blk_opf_t opf = REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH | REQ_FUA;
3336+ int ret;
3337+
3338+ folio_lock(folio);
3339+ folio_wait_writeback(folio);
3340+ if (update)
3341+ memcpy(F2FS_SUPER_BLOCK(folio, index), F2FS_RAW_SUPER(sbi),
3342+ sizeof(struct f2fs_super_block));
3343+ folio_mark_dirty(folio);
3344+ folio_clear_dirty_for_io(folio);
3345+ folio_start_writeback(folio);
3346+ folio_unlock(folio);
3347+
3348+ bio = bio_alloc(sbi->sb->s_bdev, 1, opf, GFP_NOFS);
3349+
3350+ /* it doesn't need to set crypto context for superblock update */
3351+ bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(folio_index(folio));
3352+
3353+ if (!bio_add_folio(bio, folio, folio_size(folio), 0))
3354+ f2fs_bug_on(sbi, 1);
3355+
3356+ ret = submit_bio_wait(bio);
3357+ folio_end_writeback(folio);
3358+
3359+ return ret;
33373360 }
33383361
33393362 static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi,
3340− struct buffer_head *bh)
3363+ struct folio *folio, pgoff_t index)
33413364 {
3342− struct f2fs_super_block *raw_super = (struct f2fs_super_block *)
3343− (bh->b_data + F2FS_SUPER_OFFSET);
3365+ struct f2fs_super_block *raw_super = F2FS_SUPER_BLOCK(folio, index);
33443366 struct super_block *sb = sbi->sb;
33453367 u32 segment0_blkaddr = le32_to_cpu(raw_super->segment0_blkaddr);
33463368 u32 cp_blkaddr = le32_to_cpu(raw_super->cp_blkaddr);
@@ -3356,9 +3378,9 @@ static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi, · 9 unmodified lines
33563378 u32 segment_count = le32_to_cpu(raw_super->segment_count);
33573379 u32 log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
33583380 u64 main_end_blkaddr = main_blkaddr +
3359− (segment_count_main << log_blocks_per_seg);
3381+ ((u64)segment_count_main << log_blocks_per_seg);
33603382 u64 seg_end_blkaddr = segment0_blkaddr +
3361− (segment_count << log_blocks_per_seg);
3383+ ((u64)segment_count << log_blocks_per_seg);
33623384
33633385 if (segment0_blkaddr != cp_blkaddr) {
33643386 f2fs_info(sbi, "Mismatch start address, segment0(%u) cp_blkaddr(%u)",
@@ -3415,7 +3437,7 @@ static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi, · 50 unmodified lines
34153437 set_sbi_flag(sbi, SBI_NEED_SB_WRITE);
34163438 res = "internally";
34173439 } else {
3418− err = __f2fs_commit_super(bh, NULL);
3440+ err = __f2fs_commit_super(sbi, folio, index, false);
34193441 res = err ? "failed" : "done";
34203442 }
34213443 f2fs_info(sbi, "Fix alignment : %s, start(%u) end(%llu) block(%u)",
@@ -3428,12 +3450,11 @@ static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi, · 6 unmodified lines
34283450 }
34293451
34303452 static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
3431− struct buffer_head *bh)
3453+ struct folio *folio, pgoff_t index)
34323454 {
34333455 block_t segment_count, segs_per_sec, secs_per_zone, segment_count_main;
34343456 block_t total_sections, blocks_per_seg;
3435− struct f2fs_super_block *raw_super = (struct f2fs_super_block *)
3436− (bh->b_data + F2FS_SUPER_OFFSET);
3457+ struct f2fs_super_block *raw_super = F2FS_SUPER_BLOCK(folio, index);
34373458 size_t crc_offset = 0;
34383459 __u32 crc = 0;
34393460
@@ -3591,7 +3612,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · 151 unmodified lines
35913612 }
35923613
35933614 /* check CP/SIT/NAT/SSA/MAIN_AREA area boundary */
3594− if (sanity_check_area_boundary(sbi, bh))
3615+ if (sanity_check_area_boundary(sbi, folio, index))
35953616 return -EFSCORRUPTED;
35963617
35973618 return 0;
@@ -3786,6 +3807,8 @@ static void init_sb_info(struct f2fs_sb_info *sbi) · 188 unmodified lines
37863807 sbi->next_victim_seg[FG_GC] = NULL_SEGNO;
37873808 sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH;
37883809 sbi->migration_granularity = SEGS_PER_SEC(sbi);
3810+ sbi->migration_window_granularity = f2fs_sb_has_blkzoned(sbi) ?
3811+ DEF_MIGRATION_WINDOW_GRANULARITY_ZONED : SEGS_PER_SEC(sbi);
37893812 sbi->seq_file_ra_mul = MIN_RA_MUL;
37903813 sbi->max_fragment_chunk = DEF_FRAGMENT_SIZE;
37913814 sbi->max_fragment_hole = DEF_FRAGMENT_SIZE;
@@ -3938,7 +3961,7 @@ static int read_raw_super_block(struct f2fs_sb_info *sbi, · 146 unmodified lines
39383961 {
39393962 struct super_block *sb = sbi->sb;
39403963 int block;
3941− struct buffer_head *bh;
3964+ struct folio *folio;
39423965 struct f2fs_super_block *super;
39433966 int err = 0;
39443967
@@ -3947,32 +3970,32 @@ static int read_raw_super_block(struct f2fs_sb_info *sbi, · 2 unmodified lines
39473970 return -ENOMEM;
39483971
39493972 for (block = 0; block < 2; block++) {
3950− bh = sb_bread(sb, block);
3951− if (!bh) {
3973+ folio = read_mapping_folio(sb->s_bdev->bd_mapping, block, NULL);
3974+ if (IS_ERR(folio)) {
39523975 f2fs_err(sbi, "Unable to read %dth superblock",
39533976 block + 1);
3954− err = -EIO;
3977+ err = PTR_ERR(folio);
39553978 *recovery = 1;
39563979 continue;
39573980 }
39583981
39593982 /* sanity checking of raw super */
3960− err = sanity_check_raw_super(sbi, bh);
3983+ err = sanity_check_raw_super(sbi, folio, block);
39613984 if (err) {
39623985 f2fs_err(sbi, "Can't find valid F2FS filesystem in %dth superblock",
39633986 block + 1);
3964− brelse(bh);
3987+ folio_put(folio);
39653988 *recovery = 1;
39663989 continue;
39673990 }
39683991
39693992 if (!*raw_super) {
3970− memcpy(super, bh->b_data + F2FS_SUPER_OFFSET,
3993+ memcpy(super, F2FS_SUPER_BLOCK(folio, block),
39713994 sizeof(*super));
39723995 *valid_super_block = block;
39733996 *raw_super = super;
39743997 }
3975− brelse(bh);
3998+ folio_put(folio);
39763999 }
39774000
39784001 /* No valid superblock */
@@ -3986,7 +4009,8 @@ static int read_raw_super_block(struct f2fs_sb_info *sbi, · 7 unmodified lines
39864009
39874010 int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
39884011 {
3989− struct buffer_head *bh;
4012+ struct folio *folio;
4013+ pgoff_t index;
39904014 __u32 crc = 0;
39914015 int err;
39924016
@@ -4004,22 +4028,24 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover) · 11 unmodified lines
40044028 }
40054029
40064030 /* write back-up superblock first */
4007− bh = sb_bread(sbi->sb, sbi->valid_super_block ? 0 : 1);
4008− if (!bh)
4009− return -EIO;
4010− err = __f2fs_commit_super(bh, F2FS_RAW_SUPER(sbi));
4011− brelse(bh);
4031+ index = sbi->valid_super_block ? 0 : 1;
4032+ folio = read_mapping_folio(sbi->sb->s_bdev->bd_mapping, index, NULL);
4033+ if (IS_ERR(folio))
4034+ return PTR_ERR(folio);
4035+ err = __f2fs_commit_super(sbi, folio, index, true);
4036+ folio_put(folio);
40124037
40134038 /* if we are in recovery path, skip writing valid superblock */
40144039 if (recover || err)
40154040 return err;
40164041
40174042 /* write current valid superblock */
4018− bh = sb_bread(sbi->sb, sbi->valid_super_block);
4019− if (!bh)
4020− return -EIO;
4021− err = __f2fs_commit_super(bh, F2FS_RAW_SUPER(sbi));
4022− brelse(bh);
4043+ index = sbi->valid_super_block;
4044+ folio = read_mapping_folio(sbi->sb->s_bdev->bd_mapping, index, NULL);
4045+ if (IS_ERR(folio))
4046+ return PTR_ERR(folio);
4047+ err = __f2fs_commit_super(sbi, folio, index, true);
4048+ folio_put(folio);
40234049 return err;
40244050 }
40254051
@@ -4173,12 +4199,14 @@ void f2fs_handle_critical_error(struct f2fs_sb_info *sbi, unsigned char reason, · 147 unmodified lines
41734199 }
41744200
41754201 f2fs_warn(sbi, "Remounting filesystem read-only");
4202+
41764203 /*
4177− * Make sure updated value of ->s_mount_flags will be visible before
4178− * ->s_flags update
4204+ * We have already set CP_ERROR_FLAG flag to stop all updates
4205+ * to filesystem, so it doesn't need to set SB_RDONLY flag here
4206+ * because the flag should be set covered w/ sb->s_umount semaphore
4207+ * via remount procedure, otherwise, it will confuse code like
4208+ * freeze_super() which will lead to deadlocks and other problems.
41794209 */
4180− smp_wmb();
4181− sb->s_flags |= SB_RDONLY;
41824210 }
41834211
41844212 static void f2fs_record_error_work(struct work_struct *work)
@@ -4219,6 +4247,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi) · 34 unmodified lines
42194247 sbi->aligned_blksize = true;
42204248 #ifdef CONFIG_BLK_DEV_ZONED
42214249 sbi->max_open_zones = UINT_MAX;
4250+ sbi->blkzone_alloc_policy = BLKZONE_ALLOC_PRIOR_SEQ;
42224251 #endif
42234252
42244253 for (i = 0; i < max_devices; i++) {
fs/f2fs/sysfs.c+57−25
@@ -170,6 +170,12 @@ static ssize_t undiscard_blks_show(struct f2fs_attr *a, · 169 unmodified lines
170170 SM_I(sbi)->dcc_info->undiscard_blks);
171171 }
172172
173+static ssize_t atgc_enabled_show(struct f2fs_attr *a,
174+ struct f2fs_sb_info *sbi, char *buf)
175+{
176+ return sysfs_emit(buf, "%d\n", sbi->am.atgc_enabled ? 1 : 0);
177+}
178+
173179 static ssize_t gc_mode_show(struct f2fs_attr *a,
174180 struct f2fs_sb_info *sbi, char *buf)
175181 {
@@ -182,50 +188,50 @@ static ssize_t features_show(struct f2fs_attr *a, · 6 unmodified lines
182188 int len = 0;
183189
184190 if (f2fs_sb_has_encrypt(sbi))
185− len += scnprintf(buf, PAGE_SIZE - len, "%s",
191+ len += sysfs_emit_at(buf, len, "%s",
186192 "encryption");
187193 if (f2fs_sb_has_blkzoned(sbi))
188− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
194+ len += sysfs_emit_at(buf, len, "%s%s",
189195 len ? ", " : "", "blkzoned");
190196 if (f2fs_sb_has_extra_attr(sbi))
191− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
197+ len += sysfs_emit_at(buf, len, "%s%s",
192198 len ? ", " : "", "extra_attr");
193199 if (f2fs_sb_has_project_quota(sbi))
194− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
200+ len += sysfs_emit_at(buf, len, "%s%s",
195201 len ? ", " : "", "projquota");
196202 if (f2fs_sb_has_inode_chksum(sbi))
197− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
203+ len += sysfs_emit_at(buf, len, "%s%s",
198204 len ? ", " : "", "inode_checksum");
199205 if (f2fs_sb_has_flexible_inline_xattr(sbi))
200− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
206+ len += sysfs_emit_at(buf, len, "%s%s",
201207 len ? ", " : "", "flexible_inline_xattr");
202208 if (f2fs_sb_has_quota_ino(sbi))
203− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
209+ len += sysfs_emit_at(buf, len, "%s%s",
204210 len ? ", " : "", "quota_ino");
205211 if (f2fs_sb_has_inode_crtime(sbi))
206− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
212+ len += sysfs_emit_at(buf, len, "%s%s",
207213 len ? ", " : "", "inode_crtime");
208214 if (f2fs_sb_has_lost_found(sbi))
209− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
215+ len += sysfs_emit_at(buf, len, "%s%s",
210216 len ? ", " : "", "lost_found");
211217 if (f2fs_sb_has_verity(sbi))
212− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
218+ len += sysfs_emit_at(buf, len, "%s%s",
213219 len ? ", " : "", "verity");
214220 if (f2fs_sb_has_sb_chksum(sbi))
215− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
221+ len += sysfs_emit_at(buf, len, "%s%s",
216222 len ? ", " : "", "sb_checksum");
217223 if (f2fs_sb_has_casefold(sbi))
218− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
224+ len += sysfs_emit_at(buf, len, "%s%s",
219225 len ? ", " : "", "casefold");
220226 if (f2fs_sb_has_readonly(sbi))
221− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
227+ len += sysfs_emit_at(buf, len, "%s%s",
222228 len ? ", " : "", "readonly");
223229 if (f2fs_sb_has_compression(sbi))
224− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
230+ len += sysfs_emit_at(buf, len, "%s%s",
225231 len ? ", " : "", "compression");
226− len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
232+ len += sysfs_emit_at(buf, len, "%s%s",
227233 len ? ", " : "", "pin_file");
228− len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
234+ len += sysfs_emit_at(buf, len, "\n");
229235 return len;
230236 }
231237
@@ -323,17 +329,14 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a, · 91 unmodified lines
323329 int hot_count = sbi->raw_super->hot_ext_count;
324330 int len = 0, i;
325331
326− len += scnprintf(buf + len, PAGE_SIZE - len,
327− "cold file extension:\n");
332+ len += sysfs_emit_at(buf, len, "cold file extension:\n");
328333 for (i = 0; i < cold_count; i++)
329− len += scnprintf(buf + len, PAGE_SIZE - len, "%s\n",
330− extlist[i]);
334+ len += sysfs_emit_at(buf, len, "%s\n", extlist[i]);
331335
332− len += scnprintf(buf + len, PAGE_SIZE - len,
333− "hot file extension:\n");
336+ len += sysfs_emit_at(buf, len, "hot file extension:\n");
334337 for (i = cold_count; i < cold_count + hot_count; i++)
335− len += scnprintf(buf + len, PAGE_SIZE - len, "%s\n",
336− extlist[i]);
338+ len += sysfs_emit_at(buf, len, "%s\n", extlist[i]);
339+
337340 return len;
338341 }
339342
@@ -561,6 +564,11 @@ out: · 221 unmodified lines
561564 return -EINVAL;
562565 }
563566
567+ if (!strcmp(a->attr.name, "migration_window_granularity")) {
568+ if (t == 0 || t > SEGS_PER_SEC(sbi))
569+ return -EINVAL;
570+ }
571+
564572 if (!strcmp(a->attr.name, "gc_urgent")) {
565573 if (t == 0) {
566574 sbi->gc_mode = GC_NORMAL;
@@ -627,6 +635,15 @@ out: · 60 unmodified lines
627635 }
628636 #endif
629637
638+#ifdef CONFIG_BLK_DEV_ZONED
639+ if (!strcmp(a->attr.name, "blkzone_alloc_policy")) {
640+ if (t < BLKZONE_ALLOC_PRIOR_SEQ || t > BLKZONE_ALLOC_PRIOR_CONV)
641+ return -EINVAL;
642+ sbi->blkzone_alloc_policy = t;
643+ return count;
644+ }
645+#endif
646+
630647 #ifdef CONFIG_F2FS_FS_COMPRESSION
631648 if (!strcmp(a->attr.name, "compr_written_block") ||
632649 !strcmp(a->attr.name, "compr_saved_block")) {
@@ -775,7 +792,8 @@ out: · 142 unmodified lines
775792 if (!strcmp(a->attr.name, "ipu_policy")) {
776793 if (t >= BIT(F2FS_IPU_MAX))
777794 return -EINVAL;
778− if (t && f2fs_lfs_mode(sbi))
795+ /* allow F2FS_IPU_NOCACHE only for IPU in the pinned file */
796+ if (f2fs_lfs_mode(sbi) && (t & ~BIT(F2FS_IPU_NOCACHE)))
779797 return -EINVAL;
780798 SM_I(sbi)->ipu_policy = (unsigned int)t;
781799 return count;
@@ -960,6 +978,9 @@ GC_THREAD_RW_ATTR(gc_urgent_sleep_time, urgent_sleep_time); · 178 unmodified lines
960978 GC_THREAD_RW_ATTR(gc_min_sleep_time, min_sleep_time);
961979 GC_THREAD_RW_ATTR(gc_max_sleep_time, max_sleep_time);
962980 GC_THREAD_RW_ATTR(gc_no_gc_sleep_time, no_gc_sleep_time);
981+GC_THREAD_RW_ATTR(gc_no_zoned_gc_percent, no_zoned_gc_percent);
982+GC_THREAD_RW_ATTR(gc_boost_zoned_gc_percent, boost_zoned_gc_percent);
983+GC_THREAD_RW_ATTR(gc_valid_thresh_ratio, valid_thresh_ratio);
963984
964985 /* SM_INFO ATTR */
965986 SM_INFO_RW_ATTR(reclaim_segments, rec_prefree_segments);
@@ -969,6 +990,7 @@ SM_INFO_GENERAL_RW_ATTR(min_fsync_blocks); · 3 unmodified lines
969990 SM_INFO_GENERAL_RW_ATTR(min_seq_blocks);
970991 SM_INFO_GENERAL_RW_ATTR(min_hot_blocks);
971992 SM_INFO_GENERAL_RW_ATTR(min_ssr_sections);
993+SM_INFO_GENERAL_RW_ATTR(reserved_segments);
972994
973995 /* DCC_INFO ATTR */
974996 DCC_INFO_RW_ATTR(max_small_discards, max_discards);
@@ -1001,6 +1023,7 @@ F2FS_SBI_RW_ATTR(gc_pin_file_thresh, gc_pin_file_threshold); · 26 unmodified lines
10011023 F2FS_SBI_RW_ATTR(gc_reclaimed_segments, gc_reclaimed_segs);
10021024 F2FS_SBI_GENERAL_RW_ATTR(max_victim_search);
10031025 F2FS_SBI_GENERAL_RW_ATTR(migration_granularity);
1026+F2FS_SBI_GENERAL_RW_ATTR(migration_window_granularity);
10041027 F2FS_SBI_GENERAL_RW_ATTR(dir_level);
10051028 #ifdef CONFIG_F2FS_IOSTAT
10061029 F2FS_SBI_GENERAL_RW_ATTR(iostat_enable);
@@ -1033,6 +1056,7 @@ F2FS_SBI_GENERAL_RW_ATTR(warm_data_age_threshold); · 26 unmodified lines
10331056 F2FS_SBI_GENERAL_RW_ATTR(last_age_weight);
10341057 #ifdef CONFIG_BLK_DEV_ZONED
10351058 F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
1059+F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
10361060 #endif
10371061
10381062 /* STAT_INFO ATTR */
@@ -1072,6 +1096,7 @@ F2FS_GENERAL_RO_ATTR(encoding); · 33 unmodified lines
10721096 F2FS_GENERAL_RO_ATTR(mounted_time_sec);
10731097 F2FS_GENERAL_RO_ATTR(main_blkaddr);
10741098 F2FS_GENERAL_RO_ATTR(pending_discard);
1099+F2FS_GENERAL_RO_ATTR(atgc_enabled);
10751100 F2FS_GENERAL_RO_ATTR(gc_mode);
10761101 #ifdef CONFIG_F2FS_STAT_FS
10771102 F2FS_GENERAL_RO_ATTR(moved_blocks_background);
@@ -1116,6 +1141,9 @@ static struct attribute *f2fs_attrs[] = { · 38 unmodified lines
11161141 ATTR_LIST(gc_min_sleep_time),
11171142 ATTR_LIST(gc_max_sleep_time),
11181143 ATTR_LIST(gc_no_gc_sleep_time),
1144+ ATTR_LIST(gc_no_zoned_gc_percent),
1145+ ATTR_LIST(gc_boost_zoned_gc_percent),
1146+ ATTR_LIST(gc_valid_thresh_ratio),
11191147 ATTR_LIST(gc_idle),
11201148 ATTR_LIST(gc_urgent),
11211149 ATTR_LIST(reclaim_segments),
@@ -1138,8 +1166,10 @@ static struct attribute *f2fs_attrs[] = { · 16 unmodified lines
11381166 ATTR_LIST(min_seq_blocks),
11391167 ATTR_LIST(min_hot_blocks),
11401168 ATTR_LIST(min_ssr_sections),
1169+ ATTR_LIST(reserved_segments),
11411170 ATTR_LIST(max_victim_search),
11421171 ATTR_LIST(migration_granularity),
1172+ ATTR_LIST(migration_window_granularity),
11431173 ATTR_LIST(dir_level),
11441174 ATTR_LIST(ram_thresh),
11451175 ATTR_LIST(ra_nid_pages),
@@ -1187,6 +1217,7 @@ static struct attribute *f2fs_attrs[] = { · 41 unmodified lines
11871217 #endif
11881218 #ifdef CONFIG_BLK_DEV_ZONED
11891219 ATTR_LIST(unusable_blocks_per_sec),
1220+ ATTR_LIST(blkzone_alloc_policy),
11901221 #endif
11911222 #ifdef CONFIG_F2FS_FS_COMPRESSION
11921223 ATTR_LIST(compr_written_block),
@@ -1200,6 +1231,7 @@ static struct attribute *f2fs_attrs[] = { · 7 unmodified lines
12001231 ATTR_LIST(atgc_candidate_count),
12011232 ATTR_LIST(atgc_age_weight),
12021233 ATTR_LIST(atgc_age_threshold),
1234+ ATTR_LIST(atgc_enabled),
12031235 ATTR_LIST(seq_file_ra_mul),
12041236 ATTR_LIST(gc_segment_mode),
12051237 ATTR_LIST(gc_reclaimed_segments),
fs/f2fs/verity.c+3−2
@@ -74,7 +74,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count, · 73 unmodified lines
7474 struct address_space *mapping = inode->i_mapping;
7575 const struct address_space_operations *aops = mapping->a_ops;
7676
77− if (pos + count > inode->i_sb->s_maxbytes)
77+ if (pos + count > F2FS_BLK_TO_BYTES(max_file_blocks(inode)))
7878 return -EFBIG;
7979
8080 while (count) {
@@ -237,7 +237,8 @@ static int f2fs_get_verity_descriptor(struct inode *inode, void *buf, · 156 unmodified lines
237237 pos = le64_to_cpu(dloc.pos);
238238
239239 /* Get the descriptor */
240− if (pos + size < pos || pos + size > inode->i_sb->s_maxbytes ||
240+ if (pos + size < pos ||
241+ pos + size > F2FS_BLK_TO_BYTES(max_file_blocks(inode)) ||
241242 pos < f2fs_verity_metadata_pos(inode) || size > INT_MAX) {
242243 f2fs_warn(F2FS_I_SB(inode), "invalid verity xattr");
243244 f2fs_handle_error(F2FS_I_SB(inode),
fs/f2fs/xattr.c+12−2
@@ -629,6 +629,7 @@ static int __f2fs_setxattr(struct inode *inode, int index, · 628 unmodified lines
629629 const char *name, const void *value, size_t size,
630630 struct page *ipage, int flags)
631631 {
632+ struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
632633 struct f2fs_xattr_entry *here, *last;
633634 void *base_addr, *last_base_addr;
634635 int found, newsize;
@@ -772,9 +773,18 @@ retry: · 137 unmodified lines
772773 if (index == F2FS_XATTR_INDEX_ENCRYPTION &&
773774 !strcmp(name, F2FS_XATTR_NAME_ENCRYPTION_CONTEXT))
774775 f2fs_set_encrypted_inode(inode);
775− if (S_ISDIR(inode->i_mode))
776− set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_CP);
777776
777+ if (!S_ISDIR(inode->i_mode))
778+ goto same;
779+ /*
780+ * In restrict mode, fsync() always try to trigger checkpoint for all
781+ * metadata consistency, in other mode, it triggers checkpoint when
782+ * parent's xattr metadata was updated.
783+ */
784+ if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT)
785+ set_sbi_flag(sbi, SBI_NEED_CP);
786+ else
787+ f2fs_add_ino_entry(sbi, inode->i_ino, XATTR_DIR_INO);
778788 same:
779789 if (is_inode_flag_set(inode, FI_ACL_MODE)) {
780790 inode->i_mode = F2FS_I(inode)->i_acl_mode;
include/linux/f2fs_fs.h+2−2
@@ -19,7 +19,6 @@ · 18 unmodified lines
1919 #define F2FS_BLKSIZE_BITS PAGE_SHIFT /* bits for F2FS_BLKSIZE */
2020 #define F2FS_MAX_EXTENSION 64 /* # of extension entries */
2121 #define F2FS_EXTENSION_LEN 8 /* max size of extension */
22−#define F2FS_BLK_ALIGN(x) (((x) + F2FS_BLKSIZE - 1) >> F2FS_BLKSIZE_BITS)
2322
2423 #define NULL_ADDR ((block_t)0) /* used as block_t addresses */
2524 #define NEW_ADDR ((block_t)-1) /* used as block_t addresses */
@@ -28,6 +27,7 @@ · 2 unmodified lines
2827 #define F2FS_BYTES_TO_BLK(bytes) ((bytes) >> F2FS_BLKSIZE_BITS)
2928 #define F2FS_BLK_TO_BYTES(blk) ((blk) << F2FS_BLKSIZE_BITS)
3029 #define F2FS_BLK_END_BYTES(blk) (F2FS_BLK_TO_BYTES(blk + 1) - 1)
30+#define F2FS_BLK_ALIGN(x) (F2FS_BYTES_TO_BLK((x) + F2FS_BLKSIZE - 1))
3131
3232 /* 0, 1(node nid), 2(meta nid) are reserved node id */
3333 #define F2FS_RESERVED_NODE_NUM 3
@@ -278,7 +278,7 @@ struct node_footer { · 244 unmodified lines
278278 #define F2FS_INLINE_DATA 0x02 /* file inline data flag */
279279 #define F2FS_INLINE_DENTRY 0x04 /* file inline dentry flag */
280280 #define F2FS_DATA_EXIST 0x08 /* file inline data exist flag */
281−#define F2FS_INLINE_DOTS 0x10 /* file having implicit dot dentries */
281+#define F2FS_INLINE_DOTS 0x10 /* file having implicit dot dentries (obsolete) */
282282 #define F2FS_EXTRA_ATTR 0x20 /* file having extra attribute */
283283 #define F2FS_PIN_FILE 0x40 /* file should not be gced */
284284 #define F2FS_COMPRESS_RELEASED 0x80 /* file released compressed blocks */
include/trace/events/f2fs.h+2−1
@@ -139,7 +139,8 @@ TRACE_DEFINE_ENUM(EX_BLOCK_AGE); · 138 unmodified lines
139139 { CP_NODE_NEED_CP, "node needs cp" }, \
140140 { CP_FASTBOOT_MODE, "fastboot mode" }, \
141141 { CP_SPEC_LOG_NUM, "log type is 2" }, \
142− { CP_RECOVER_DIR, "dir needs recovery" })
142+ { CP_RECOVER_DIR, "dir needs recovery" }, \
143+ { CP_XATTR_DIR, "dir's xattr updated" })
143144
144145 #define show_shutdown_mode(type) \
145146 __print_symbolic(type, \