Skip to content

Commit 70d201a

Browse files
committed
Merge tag 'f2fs-for-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs update from Jaegeuk Kim: "In this series, we've some progress to support Zoned block device regarding to the power-cut recovery flow and enabling checkpoint=disable feature which is essential for Android OTA. Other than that, some patches touched sysfs entries and tracepoints which are minor, while several bug fixes on error handlers and compression flows are good to improve the overall stability. Enhancements: - enable checkpoint=disable for zoned block device - sysfs entries such as discard status, discard_io_aware, dir_level - tracepoints such as f2fs_vm_page_mkwrite(), f2fs_rename(), f2fs_new_inode() - use shared inode lock during f2fs_fiemap() and f2fs_seek_block() Bug fixes: - address some power-cut recovery issues on zoned block device - handle errors and logics on do_garbage_collect(), f2fs_reserve_new_block(), f2fs_move_file_range(), f2fs_recover_xattr_data() - don't set FI_PREALLOCATED_ALL for partial write - fix to update iostat correctly in f2fs_filemap_fault() - fix to wait on block writeback for post_read case - fix to tag gcing flag on page during block migration - restrict max filesize for 16K f2fs - fix to avoid dirent corruption - explicitly null-terminate the xattr list There are also several clean-up patches to remove dead codes and better readability" * tag 'f2fs-for-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (33 commits) f2fs: show more discard status by sysfs f2fs: Add error handling for negative returns from do_garbage_collect f2fs: Constrain the modification range of dir_level in the sysfs f2fs: Use wait_event_freezable_timeout() for freezable kthread f2fs: fix to check return value of f2fs_recover_xattr_data f2fs: don't set FI_PREALLOCATED_ALL for partial write f2fs: fix to update iostat correctly in f2fs_filemap_fault() f2fs: fix to check compress file in f2fs_move_file_range() f2fs: fix to wait on block writeback for post_read case f2fs: fix to tag gcing flag on page during block migration f2fs: add tracepoint for f2fs_vm_page_mkwrite() f2fs: introduce f2fs_invalidate_internal_cache() for cleanup f2fs: update blkaddr in __set_data_blkaddr() for cleanup f2fs: introduce get_dnode_addr() to clean up codes f2fs: delete obsolete FI_DROP_CACHE f2fs: delete obsolete FI_FIRST_BLOCK_WRITTEN f2fs: Restrict max filesize for 16K f2fs f2fs: let's finish or reset zones all the time f2fs: check write pointers when checkpoint=disable f2fs: fix write pointers on zoned device after roll forward ...
2 parents 6a31658 + c3c2d45 commit 70d201a

File tree

16 files changed

+395
-269
lines changed

16 files changed

+395
-269
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,21 @@ Description: Show status of f2fs checkpoint in real time.
498498
CP_RESIZEFS_FLAG 0x00004000
499499
=============================== ==============================
500500

501+
What: /sys/fs/f2fs/<disk>/stat/issued_discard
502+
Date: December 2023
503+
Contact: "Zhiguo Niu" <[email protected]>
504+
Description: Shows the number of issued discard.
505+
506+
What: /sys/fs/f2fs/<disk>/stat/queued_discard
507+
Date: December 2023
508+
Contact: "Zhiguo Niu" <[email protected]>
509+
Description: Shows the number of queued discard.
510+
511+
What: /sys/fs/f2fs/<disk>/stat/undiscard_blks
512+
Date: December 2023
513+
Contact: "Zhiguo Niu" <[email protected]>
514+
Description: Shows the total number of undiscard blocks.
515+
501516
What: /sys/fs/f2fs/<disk>/ckpt_thread_ioprio
502517
Date: January 2021
503518
Contact: "Daeho Jeong" <[email protected]>
@@ -740,3 +755,9 @@ Description: When compress cache is on, it controls cached page
740755
If cached page percent exceed threshold, then deny caching compress page.
741756
The value should be in range of (0, 100], by default it was initialized
742757
as 20(%).
758+
759+
What: /sys/fs/f2fs/<disk>/discard_io_aware
760+
Date: November 2023
761+
Contact: "Chao Yu" <[email protected]>
762+
Description: It controls to enable/disable IO aware feature for background discard.
763+
By default, the value is 1 which indicates IO aware is on.

fs/f2fs/compress.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,10 @@ static void set_cluster_dirty(struct compress_ctx *cc)
10361036
int i;
10371037

10381038
for (i = 0; i < cc->cluster_size; i++)
1039-
if (cc->rpages[i])
1039+
if (cc->rpages[i]) {
10401040
set_page_dirty(cc->rpages[i]);
1041+
set_page_private_gcing(cc->rpages[i]);
1042+
}
10411043
}
10421044

10431045
static int prepare_compress_overwrite(struct compress_ctx *cc,
@@ -1369,8 +1371,6 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
13691371
add_compr_block_stat(inode, cc->valid_nr_cpages);
13701372

13711373
set_inode_flag(cc->inode, FI_APPEND_WRITE);
1372-
if (cc->cluster_idx == 0)
1373-
set_inode_flag(inode, FI_FIRST_BLOCK_WRITTEN);
13741374

13751375
f2fs_put_dnode(&dn);
13761376
if (quota_inode)

fs/f2fs/data.c

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,18 +1179,12 @@ static int f2fs_submit_page_read(struct inode *inode, struct page *page,
11791179
return 0;
11801180
}
11811181

1182-
static void __set_data_blkaddr(struct dnode_of_data *dn)
1182+
static void __set_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr)
11831183
{
1184-
struct f2fs_node *rn = F2FS_NODE(dn->node_page);
1185-
__le32 *addr_array;
1186-
int base = 0;
1184+
__le32 *addr = get_dnode_addr(dn->inode, dn->node_page);
11871185

1188-
if (IS_INODE(dn->node_page) && f2fs_has_extra_attr(dn->inode))
1189-
base = get_extra_isize(dn->inode);
1190-
1191-
/* Get physical address of data block */
1192-
addr_array = blkaddr_in_node(rn);
1193-
addr_array[base + dn->ofs_in_node] = cpu_to_le32(dn->data_blkaddr);
1186+
dn->data_blkaddr = blkaddr;
1187+
addr[dn->ofs_in_node] = cpu_to_le32(dn->data_blkaddr);
11941188
}
11951189

11961190
/*
@@ -1199,18 +1193,17 @@ static void __set_data_blkaddr(struct dnode_of_data *dn)
11991193
* ->node_page
12001194
* update block addresses in the node page
12011195
*/
1202-
void f2fs_set_data_blkaddr(struct dnode_of_data *dn)
1196+
void f2fs_set_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr)
12031197
{
12041198
f2fs_wait_on_page_writeback(dn->node_page, NODE, true, true);
1205-
__set_data_blkaddr(dn);
1199+
__set_data_blkaddr(dn, blkaddr);
12061200
if (set_page_dirty(dn->node_page))
12071201
dn->node_changed = true;
12081202
}
12091203

12101204
void f2fs_update_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr)
12111205
{
1212-
dn->data_blkaddr = blkaddr;
1213-
f2fs_set_data_blkaddr(dn);
1206+
f2fs_set_data_blkaddr(dn, blkaddr);
12141207
f2fs_update_read_extent_cache(dn);
12151208
}
12161209

@@ -1237,8 +1230,7 @@ int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count)
12371230
block_t blkaddr = f2fs_data_blkaddr(dn);
12381231

12391232
if (blkaddr == NULL_ADDR) {
1240-
dn->data_blkaddr = NEW_ADDR;
1241-
__set_data_blkaddr(dn);
1233+
__set_data_blkaddr(dn, NEW_ADDR);
12421234
count--;
12431235
}
12441236
}
@@ -1492,11 +1484,9 @@ static int __allocate_data_block(struct dnode_of_data *dn, int seg_type)
14921484
old_blkaddr = dn->data_blkaddr;
14931485
f2fs_allocate_data_block(sbi, NULL, old_blkaddr, &dn->data_blkaddr,
14941486
&sum, seg_type, NULL);
1495-
if (GET_SEGNO(sbi, old_blkaddr) != NULL_SEGNO) {
1496-
invalidate_mapping_pages(META_MAPPING(sbi),
1497-
old_blkaddr, old_blkaddr);
1498-
f2fs_invalidate_compress_page(sbi, old_blkaddr);
1499-
}
1487+
if (GET_SEGNO(sbi, old_blkaddr) != NULL_SEGNO)
1488+
f2fs_invalidate_internal_cache(sbi, old_blkaddr);
1489+
15001490
f2fs_update_data_blkaddr(dn, dn->data_blkaddr);
15011491
return 0;
15021492
}
@@ -1992,7 +1982,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
19921982
if (ret)
19931983
return ret;
19941984

1995-
inode_lock(inode);
1985+
inode_lock_shared(inode);
19961986

19971987
maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
19981988
if (start > maxbytes) {
@@ -2112,7 +2102,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
21122102
if (ret == 1)
21132103
ret = 0;
21142104

2115-
inode_unlock(inode);
2105+
inode_unlock_shared(inode);
21162106
return ret;
21172107
}
21182108

@@ -2566,9 +2556,6 @@ int f2fs_encrypt_one_page(struct f2fs_io_info *fio)
25662556

25672557
page = fio->compressed_page ? fio->compressed_page : fio->page;
25682558

2569-
/* wait for GCed page writeback via META_MAPPING */
2570-
f2fs_wait_on_block_writeback(inode, fio->old_blkaddr);
2571-
25722559
if (fscrypt_inode_uses_inline_crypto(inode))
25732560
return 0;
25742561

@@ -2755,6 +2742,10 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)
27552742
goto out_writepage;
27562743
}
27572744

2745+
/* wait for GCed page writeback via META_MAPPING */
2746+
if (fio->post_read)
2747+
f2fs_wait_on_block_writeback(inode, fio->old_blkaddr);
2748+
27582749
/*
27592750
* If current allocation needs SSR,
27602751
* it had better in-place writes for updated data.
@@ -2810,8 +2801,6 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)
28102801
f2fs_outplace_write_data(&dn, fio);
28112802
trace_f2fs_do_write_data_page(page, OPU);
28122803
set_inode_flag(inode, FI_APPEND_WRITE);
2813-
if (page->index == 0)
2814-
set_inode_flag(inode, FI_FIRST_BLOCK_WRITTEN);
28152804
out_writepage:
28162805
f2fs_put_dnode(&dn);
28172806
out:
@@ -2894,9 +2883,6 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
28942883

28952884
zero_user_segment(page, offset, PAGE_SIZE);
28962885
write:
2897-
if (f2fs_is_drop_cache(inode))
2898-
goto out;
2899-
29002886
/* Dentry/quota blocks are controlled by checkpoint */
29012887
if (S_ISDIR(inode->i_mode) || quota_inode) {
29022888
/*

fs/f2fs/f2fs.h

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,12 @@ enum {
374374
MAX_DPOLICY,
375375
};
376376

377+
enum {
378+
DPOLICY_IO_AWARE_DISABLE, /* force to not be aware of IO */
379+
DPOLICY_IO_AWARE_ENABLE, /* force to be aware of IO */
380+
DPOLICY_IO_AWARE_MAX,
381+
};
382+
377383
struct discard_policy {
378384
int type; /* type of discard */
379385
unsigned int min_interval; /* used for candidates exist */
@@ -406,6 +412,7 @@ struct discard_cmd_control {
406412
unsigned int discard_urgent_util; /* utilization which issue discard proactively */
407413
unsigned int discard_granularity; /* discard granularity */
408414
unsigned int max_ordered_discard; /* maximum discard granularity issued by lba order */
415+
unsigned int discard_io_aware; /* io_aware policy */
409416
unsigned int undiscard_blks; /* # of undiscard blocks */
410417
unsigned int next_pos; /* next discard position */
411418
atomic_t issued_discard; /* # of issued discard */
@@ -774,8 +781,6 @@ enum {
774781
FI_UPDATE_WRITE, /* inode has in-place-update data */
775782
FI_NEED_IPU, /* used for ipu per file */
776783
FI_ATOMIC_FILE, /* indicate atomic file */
777-
FI_FIRST_BLOCK_WRITTEN, /* indicate #0 data block was written */
778-
FI_DROP_CACHE, /* drop dirty page cache */
779784
FI_DATA_EXIST, /* indicate data exists */
780785
FI_INLINE_DOTS, /* indicate inline dot dentries */
781786
FI_SKIP_WRITES, /* should skip data page writeback */
@@ -3272,22 +3277,13 @@ static inline bool f2fs_is_cow_file(struct inode *inode)
32723277
return is_inode_flag_set(inode, FI_COW_FILE);
32733278
}
32743279

3275-
static inline bool f2fs_is_first_block_written(struct inode *inode)
3276-
{
3277-
return is_inode_flag_set(inode, FI_FIRST_BLOCK_WRITTEN);
3278-
}
3279-
3280-
static inline bool f2fs_is_drop_cache(struct inode *inode)
3281-
{
3282-
return is_inode_flag_set(inode, FI_DROP_CACHE);
3283-
}
3284-
3280+
static inline __le32 *get_dnode_addr(struct inode *inode,
3281+
struct page *node_page);
32853282
static inline void *inline_data_addr(struct inode *inode, struct page *page)
32863283
{
3287-
struct f2fs_inode *ri = F2FS_INODE(page);
3288-
int extra_size = get_extra_isize(inode);
3284+
__le32 *addr = get_dnode_addr(inode, page);
32893285

3290-
return (void *)&(ri->i_addr[extra_size + DEF_INLINE_RESERVED_SIZE]);
3286+
return (void *)(addr + DEF_INLINE_RESERVED_SIZE);
32913287
}
32923288

32933289
static inline int f2fs_has_inline_dentry(struct inode *inode)
@@ -3432,6 +3428,17 @@ static inline int get_inline_xattr_addrs(struct inode *inode)
34323428
return F2FS_I(inode)->i_inline_xattr_size;
34333429
}
34343430

3431+
static inline __le32 *get_dnode_addr(struct inode *inode,
3432+
struct page *node_page)
3433+
{
3434+
int base = 0;
3435+
3436+
if (IS_INODE(node_page) && f2fs_has_extra_attr(inode))
3437+
base = get_extra_isize(inode);
3438+
3439+
return blkaddr_in_node(F2FS_NODE(node_page)) + base;
3440+
}
3441+
34353442
#define f2fs_get_inode_mode(i) \
34363443
((is_inode_flag_set(i, FI_ACL_MODE)) ? \
34373444
(F2FS_I(i)->i_acl_mode) : ((i)->i_mode))
@@ -3815,7 +3822,7 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio);
38153822
struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi,
38163823
block_t blk_addr, sector_t *sector);
38173824
int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr);
3818-
void f2fs_set_data_blkaddr(struct dnode_of_data *dn);
3825+
void f2fs_set_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr);
38193826
void f2fs_update_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr);
38203827
int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count);
38213828
int f2fs_reserve_new_block(struct dnode_of_data *dn);
@@ -4606,6 +4613,13 @@ static inline bool f2fs_is_readonly(struct f2fs_sb_info *sbi)
46064613
return f2fs_sb_has_readonly(sbi) || f2fs_readonly(sbi->sb);
46074614
}
46084615

4616+
static inline void f2fs_invalidate_internal_cache(struct f2fs_sb_info *sbi,
4617+
block_t blkaddr)
4618+
{
4619+
invalidate_mapping_pages(META_MAPPING(sbi), blkaddr, blkaddr);
4620+
f2fs_invalidate_compress_page(sbi, blkaddr);
4621+
}
4622+
46094623
#define EFSBADCRC EBADMSG /* Bad CRC detected */
46104624
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
46114625

0 commit comments

Comments
 (0)