Skip to content

Commit 9290122

Browse files
committed
Merge tag 'f2fs-for-6-6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs updates from Jaegeuk Kim: "In this cycle, we don't have a highlighted feature enhancement, but mostly have fixed issues mainly in two parts: 1) zoned block device, and 2) compression support. For zoned block device, we've tried to improve the power-off recovery flow as much as possible. For compression, we found some corner cases caused by wrong compression policy and logics. Other than them, there were some reverts and stat corrections. Bug fixes: - use finish zone command when closing a zone - check zone type before sending async reset zone command - fix to assign compress_level for lz4 correctly - fix error path of f2fs_submit_page_read() - don't {,de}compress non-full cluster - send small discard commands during checkpoint back - flush inode if atomic file is aborted - correct to account gc/cp stats And, there are minor bug fixes, avoiding false lockdep warning, and clean-ups" * tag 'f2fs-for-6-6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (25 commits) f2fs: use finish zone command when closing a zone f2fs: compress: fix to assign compress_level for lz4 correctly f2fs: fix error path of f2fs_submit_page_read() f2fs: clean up error handling in sanity_check_{compress_,}inode() f2fs: avoid false alarm of circular locking Revert "f2fs: do not issue small discard commands during checkpoint" f2fs: doc: fix description of max_small_discards f2fs: should update REQ_TIME for direct write f2fs: fix to account cp stats correctly f2fs: fix to account gc stats correctly f2fs: remove unneeded check condition in __f2fs_setxattr() f2fs: fix to update i_ctime in __f2fs_setxattr() Revert "f2fs: fix to do sanity check on extent cache correctly" f2fs: increase usage of folio_next_index() helper f2fs: Only lfs mode is allowed with zoned block device feature f2fs: check zone type before sending async reset zone command f2fs: compress: don't {,de}compress non-full cluster f2fs: allow f2fs_ioc_{,de}compress_file to be interrupted f2fs: don't reopen the main block device in f2fs_scan_devices f2fs: fix to avoid mmap vs set_compress_option case ...
2 parents b89b029 + 3b71661 commit 9290122

File tree

15 files changed

+264
-171
lines changed

15 files changed

+264
-171
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ What: /sys/fs/f2fs/<disk>/max_small_discards
102102
Date: November 2013
103103
Contact: "Jaegeuk Kim" <jaegeuk.kim@samsung.com>
104104
Description: Controls the issue rate of discard commands that consist of small
105-
blocks less than 2MB. The candidates to be discarded are cached until
106-
checkpoint is triggered, and issued during the checkpoint.
107-
By default, it is disabled with 0.
105+
blocks less than 2MB. The candidates to be discarded are cached during
106+
checkpoint, and issued by issue_discard thread after checkpoint.
107+
It is enabled by default.
108108

109109
What: /sys/fs/f2fs/<disk>/max_ordered_discard
110110
Date: October 2022

fs/f2fs/checkpoint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1701,9 +1701,9 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
17011701
}
17021702

17031703
f2fs_restore_inmem_curseg(sbi);
1704+
stat_inc_cp_count(sbi);
17041705
stop:
17051706
unblock_operations(sbi);
1706-
stat_inc_cp_count(sbi->stat_info);
17071707

17081708
if (cpc->reason & CP_RECOVERY)
17091709
f2fs_notice(sbi, "checkpoint: version = %llx", ckpt_ver);

fs/f2fs/compress.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -649,13 +649,8 @@ static int f2fs_compress_pages(struct compress_ctx *cc)
649649
goto destroy_compress_ctx;
650650
}
651651

652-
for (i = 0; i < cc->nr_cpages; i++) {
652+
for (i = 0; i < cc->nr_cpages; i++)
653653
cc->cpages[i] = f2fs_compress_alloc_page();
654-
if (!cc->cpages[i]) {
655-
ret = -ENOMEM;
656-
goto out_free_cpages;
657-
}
658-
}
659654

660655
cc->rbuf = f2fs_vmap(cc->rpages, cc->cluster_size);
661656
if (!cc->rbuf) {
@@ -1574,8 +1569,6 @@ static int f2fs_prepare_decomp_mem(struct decompress_io_ctx *dic,
15741569
}
15751570

15761571
dic->tpages[i] = f2fs_compress_alloc_page();
1577-
if (!dic->tpages[i])
1578-
return -ENOMEM;
15791572
}
15801573

15811574
dic->rbuf = f2fs_vmap(dic->tpages, dic->cluster_size);
@@ -1656,11 +1649,6 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc)
16561649
struct page *page;
16571650

16581651
page = f2fs_compress_alloc_page();
1659-
if (!page) {
1660-
ret = -ENOMEM;
1661-
goto out_free;
1662-
}
1663-
16641652
f2fs_set_compressed_page(page, cc->inode,
16651653
start_idx + i + 1, dic);
16661654
dic->cpages[i] = page;

fs/f2fs/data.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,9 @@ static int f2fs_submit_page_read(struct inode *inode, struct page *page,
11671167
f2fs_wait_on_block_writeback(inode, blkaddr);
11681168

11691169
if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
1170+
iostat_update_and_unbind_ctx(bio);
1171+
if (bio->bi_private)
1172+
mempool_free(bio->bi_private, bio_post_read_ctx_pool);
11701173
bio_put(bio);
11711174
return -EFAULT;
11721175
}
@@ -1389,18 +1392,14 @@ struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,
13891392
{
13901393
struct address_space *mapping = inode->i_mapping;
13911394
struct page *page;
1392-
repeat:
1395+
13931396
page = f2fs_get_read_data_page(inode, index, 0, for_write, NULL);
13941397
if (IS_ERR(page))
13951398
return page;
13961399

13971400
/* wait for read completion */
13981401
lock_page(page);
1399-
if (unlikely(page->mapping != mapping)) {
1400-
f2fs_put_page(page, 1);
1401-
goto repeat;
1402-
}
1403-
if (unlikely(!PageUptodate(page))) {
1402+
if (unlikely(page->mapping != mapping || !PageUptodate(page))) {
14041403
f2fs_put_page(page, 1);
14051404
return ERR_PTR(-EIO);
14061405
}
@@ -3236,8 +3235,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
32363235
}
32373236
goto next;
32383237
}
3239-
done_index = folio->index +
3240-
folio_nr_pages(folio);
3238+
done_index = folio_next_index(folio);
32413239
done = 1;
32423240
break;
32433241
}

fs/f2fs/debug.c

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ static void update_general_status(struct f2fs_sb_info *sbi)
215215
si->valid_blks[type] += blks;
216216
}
217217

218+
for (i = 0; i < MAX_CALL_TYPE; i++)
219+
si->cp_call_count[i] = atomic_read(&sbi->cp_call_count[i]);
220+
218221
for (i = 0; i < 2; i++) {
219222
si->segment_count[i] = sbi->segment_count[i];
220223
si->block_count[i] = sbi->block_count[i];
@@ -497,7 +500,9 @@ static int stat_show(struct seq_file *s, void *v)
497500
seq_printf(s, " - Prefree: %d\n - Free: %d (%d)\n\n",
498501
si->prefree_count, si->free_segs, si->free_secs);
499502
seq_printf(s, "CP calls: %d (BG: %d)\n",
500-
si->cp_count, si->bg_cp_count);
503+
si->cp_call_count[TOTAL_CALL],
504+
si->cp_call_count[BACKGROUND]);
505+
seq_printf(s, "CP count: %d\n", si->cp_count);
501506
seq_printf(s, " - cp blocks : %u\n", si->meta_count[META_CP]);
502507
seq_printf(s, " - sit blocks : %u\n",
503508
si->meta_count[META_SIT]);
@@ -511,12 +516,24 @@ static int stat_show(struct seq_file *s, void *v)
511516
seq_printf(s, " - Total : %4d\n", si->nr_total_ckpt);
512517
seq_printf(s, " - Cur time : %4d(ms)\n", si->cur_ckpt_time);
513518
seq_printf(s, " - Peak time : %4d(ms)\n", si->peak_ckpt_time);
514-
seq_printf(s, "GC calls: %d (BG: %d)\n",
515-
si->call_count, si->bg_gc);
516-
seq_printf(s, " - data segments : %d (%d)\n",
517-
si->data_segs, si->bg_data_segs);
518-
seq_printf(s, " - node segments : %d (%d)\n",
519-
si->node_segs, si->bg_node_segs);
519+
seq_printf(s, "GC calls: %d (gc_thread: %d)\n",
520+
si->gc_call_count[BACKGROUND] +
521+
si->gc_call_count[FOREGROUND],
522+
si->gc_call_count[BACKGROUND]);
523+
if (__is_large_section(sbi)) {
524+
seq_printf(s, " - data sections : %d (BG: %d)\n",
525+
si->gc_secs[DATA][BG_GC] + si->gc_secs[DATA][FG_GC],
526+
si->gc_secs[DATA][BG_GC]);
527+
seq_printf(s, " - node sections : %d (BG: %d)\n",
528+
si->gc_secs[NODE][BG_GC] + si->gc_secs[NODE][FG_GC],
529+
si->gc_secs[NODE][BG_GC]);
530+
}
531+
seq_printf(s, " - data segments : %d (BG: %d)\n",
532+
si->gc_segs[DATA][BG_GC] + si->gc_segs[DATA][FG_GC],
533+
si->gc_segs[DATA][BG_GC]);
534+
seq_printf(s, " - node segments : %d (BG: %d)\n",
535+
si->gc_segs[NODE][BG_GC] + si->gc_segs[NODE][FG_GC],
536+
si->gc_segs[NODE][BG_GC]);
520537
seq_puts(s, " - Reclaimed segs :\n");
521538
seq_printf(s, " - Normal : %d\n", sbi->gc_reclaimed_segs[GC_NORMAL]);
522539
seq_printf(s, " - Idle CB : %d\n", sbi->gc_reclaimed_segs[GC_IDLE_CB]);
@@ -687,6 +704,8 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
687704
atomic_set(&sbi->inplace_count, 0);
688705
for (i = META_CP; i < META_MAX; i++)
689706
atomic_set(&sbi->meta_count[i], 0);
707+
for (i = 0; i < MAX_CALL_TYPE; i++)
708+
atomic_set(&sbi->cp_call_count[i], 0);
690709

691710
atomic_set(&sbi->max_aw_cnt, 0);
692711

fs/f2fs/f2fs.h

Lines changed: 61 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,13 @@ enum errors_option {
13831383
MOUNT_ERRORS_PANIC, /* panic on errors */
13841384
};
13851385

1386+
enum {
1387+
BACKGROUND,
1388+
FOREGROUND,
1389+
MAX_CALL_TYPE,
1390+
TOTAL_CALL = FOREGROUND,
1391+
};
1392+
13861393
static inline int f2fs_test_bit(unsigned int nr, char *addr);
13871394
static inline void f2fs_set_bit(unsigned int nr, char *addr);
13881395
static inline void f2fs_clear_bit(unsigned int nr, char *addr);
@@ -1695,6 +1702,7 @@ struct f2fs_sb_info {
16951702
unsigned int io_skip_bggc; /* skip background gc for in-flight IO */
16961703
unsigned int other_skip_bggc; /* skip background gc for other reasons */
16971704
unsigned int ndirty_inode[NR_INODE_TYPE]; /* # of dirty inodes */
1705+
atomic_t cp_call_count[MAX_CALL_TYPE]; /* # of cp call */
16981706
#endif
16991707
spinlock_t stat_lock; /* lock for stat operations */
17001708

@@ -2114,15 +2122,6 @@ static inline int f2fs_down_read_trylock(struct f2fs_rwsem *sem)
21142122
return down_read_trylock(&sem->internal_rwsem);
21152123
}
21162124

2117-
#ifdef CONFIG_DEBUG_LOCK_ALLOC
2118-
static inline void f2fs_down_read_nested(struct f2fs_rwsem *sem, int subclass)
2119-
{
2120-
down_read_nested(&sem->internal_rwsem, subclass);
2121-
}
2122-
#else
2123-
#define f2fs_down_read_nested(sem, subclass) f2fs_down_read(sem)
2124-
#endif
2125-
21262125
static inline void f2fs_up_read(struct f2fs_rwsem *sem)
21272126
{
21282127
up_read(&sem->internal_rwsem);
@@ -2133,6 +2132,21 @@ static inline void f2fs_down_write(struct f2fs_rwsem *sem)
21332132
down_write(&sem->internal_rwsem);
21342133
}
21352134

2135+
#ifdef CONFIG_DEBUG_LOCK_ALLOC
2136+
static inline void f2fs_down_read_nested(struct f2fs_rwsem *sem, int subclass)
2137+
{
2138+
down_read_nested(&sem->internal_rwsem, subclass);
2139+
}
2140+
2141+
static inline void f2fs_down_write_nested(struct f2fs_rwsem *sem, int subclass)
2142+
{
2143+
down_write_nested(&sem->internal_rwsem, subclass);
2144+
}
2145+
#else
2146+
#define f2fs_down_read_nested(sem, subclass) f2fs_down_read(sem)
2147+
#define f2fs_down_write_nested(sem, subclass) f2fs_down_write(sem)
2148+
#endif
2149+
21362150
static inline int f2fs_down_write_trylock(struct f2fs_rwsem *sem)
21372151
{
21382152
return down_write_trylock(&sem->internal_rwsem);
@@ -3887,7 +3901,7 @@ struct f2fs_stat_info {
38873901
int nats, dirty_nats, sits, dirty_sits;
38883902
int free_nids, avail_nids, alloc_nids;
38893903
int total_count, utilization;
3890-
int bg_gc, nr_wb_cp_data, nr_wb_data;
3904+
int nr_wb_cp_data, nr_wb_data;
38913905
int nr_rd_data, nr_rd_node, nr_rd_meta;
38923906
int nr_dio_read, nr_dio_write;
38933907
unsigned int io_skip_bggc, other_skip_bggc;
@@ -3907,9 +3921,11 @@ struct f2fs_stat_info {
39073921
int rsvd_segs, overp_segs;
39083922
int dirty_count, node_pages, meta_pages, compress_pages;
39093923
int compress_page_hit;
3910-
int prefree_count, call_count, cp_count, bg_cp_count;
3911-
int tot_segs, node_segs, data_segs, free_segs, free_secs;
3912-
int bg_node_segs, bg_data_segs;
3924+
int prefree_count, free_segs, free_secs;
3925+
int cp_call_count[MAX_CALL_TYPE], cp_count;
3926+
int gc_call_count[MAX_CALL_TYPE];
3927+
int gc_segs[2][2];
3928+
int gc_secs[2][2];
39133929
int tot_blks, data_blks, node_blks;
39143930
int bg_data_blks, bg_node_blks;
39153931
int curseg[NR_CURSEG_TYPE];
@@ -3931,10 +3947,9 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
39313947
return (struct f2fs_stat_info *)sbi->stat_info;
39323948
}
39333949

3934-
#define stat_inc_cp_count(si) ((si)->cp_count++)
3935-
#define stat_inc_bg_cp_count(si) ((si)->bg_cp_count++)
3936-
#define stat_inc_call_count(si) ((si)->call_count++)
3937-
#define stat_inc_bggc_count(si) ((si)->bg_gc++)
3950+
#define stat_inc_cp_call_count(sbi, foreground) \
3951+
atomic_inc(&sbi->cp_call_count[(foreground)])
3952+
#define stat_inc_cp_count(si) (F2FS_STAT(sbi)->cp_count++)
39383953
#define stat_io_skip_bggc_count(sbi) ((sbi)->io_skip_bggc++)
39393954
#define stat_other_skip_bggc_count(sbi) ((sbi)->other_skip_bggc++)
39403955
#define stat_inc_dirty_inode(sbi, type) ((sbi)->ndirty_inode[type]++)
@@ -4019,18 +4034,12 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
40194034
if (cur > max) \
40204035
atomic_set(&F2FS_I_SB(inode)->max_aw_cnt, cur); \
40214036
} while (0)
4022-
#define stat_inc_seg_count(sbi, type, gc_type) \
4023-
do { \
4024-
struct f2fs_stat_info *si = F2FS_STAT(sbi); \
4025-
si->tot_segs++; \
4026-
if ((type) == SUM_TYPE_DATA) { \
4027-
si->data_segs++; \
4028-
si->bg_data_segs += (gc_type == BG_GC) ? 1 : 0; \
4029-
} else { \
4030-
si->node_segs++; \
4031-
si->bg_node_segs += (gc_type == BG_GC) ? 1 : 0; \
4032-
} \
4033-
} while (0)
4037+
#define stat_inc_gc_call_count(sbi, foreground) \
4038+
(F2FS_STAT(sbi)->gc_call_count[(foreground)]++)
4039+
#define stat_inc_gc_sec_count(sbi, type, gc_type) \
4040+
(F2FS_STAT(sbi)->gc_secs[(type)][(gc_type)]++)
4041+
#define stat_inc_gc_seg_count(sbi, type, gc_type) \
4042+
(F2FS_STAT(sbi)->gc_segs[(type)][(gc_type)]++)
40344043

40354044
#define stat_inc_tot_blk_count(si, blks) \
40364045
((si)->tot_blks += (blks))
@@ -4057,10 +4066,8 @@ void __init f2fs_create_root_stats(void);
40574066
void f2fs_destroy_root_stats(void);
40584067
void f2fs_update_sit_info(struct f2fs_sb_info *sbi);
40594068
#else
4060-
#define stat_inc_cp_count(si) do { } while (0)
4061-
#define stat_inc_bg_cp_count(si) do { } while (0)
4062-
#define stat_inc_call_count(si) do { } while (0)
4063-
#define stat_inc_bggc_count(si) do { } while (0)
4069+
#define stat_inc_cp_call_count(sbi, foreground) do { } while (0)
4070+
#define stat_inc_cp_count(sbi) do { } while (0)
40644071
#define stat_io_skip_bggc_count(sbi) do { } while (0)
40654072
#define stat_other_skip_bggc_count(sbi) do { } while (0)
40664073
#define stat_inc_dirty_inode(sbi, type) do { } while (0)
@@ -4088,7 +4095,9 @@ void f2fs_update_sit_info(struct f2fs_sb_info *sbi);
40884095
#define stat_inc_seg_type(sbi, curseg) do { } while (0)
40894096
#define stat_inc_block_count(sbi, curseg) do { } while (0)
40904097
#define stat_inc_inplace_blocks(sbi) do { } while (0)
4091-
#define stat_inc_seg_count(sbi, type, gc_type) do { } while (0)
4098+
#define stat_inc_gc_call_count(sbi, foreground) do { } while (0)
4099+
#define stat_inc_gc_sec_count(sbi, type, gc_type) do { } while (0)
4100+
#define stat_inc_gc_seg_count(sbi, type, gc_type) do { } while (0)
40924101
#define stat_inc_tot_blk_count(si, blks) do { } while (0)
40934102
#define stat_inc_data_blk_count(sbi, blks, gc_type) do { } while (0)
40944103
#define stat_inc_node_blk_count(sbi, blks, gc_type) do { } while (0)
@@ -4425,6 +4434,22 @@ static inline bool f2fs_blkz_is_seq(struct f2fs_sb_info *sbi, int devi,
44254434
}
44264435
#endif
44274436

4437+
static inline int f2fs_bdev_index(struct f2fs_sb_info *sbi,
4438+
struct block_device *bdev)
4439+
{
4440+
int i;
4441+
4442+
if (!f2fs_is_multi_device(sbi))
4443+
return 0;
4444+
4445+
for (i = 0; i < sbi->s_ndevs; i++)
4446+
if (FDEV(i).bdev == bdev)
4447+
return i;
4448+
4449+
WARN_ON(1);
4450+
return -1;
4451+
}
4452+
44284453
static inline bool f2fs_hw_should_discard(struct f2fs_sb_info *sbi)
44294454
{
44304455
return f2fs_sb_has_blkzoned(sbi);
@@ -4485,7 +4510,8 @@ static inline bool f2fs_low_mem_mode(struct f2fs_sb_info *sbi)
44854510
static inline bool f2fs_may_compress(struct inode *inode)
44864511
{
44874512
if (IS_SWAPFILE(inode) || f2fs_is_pinned_file(inode) ||
4488-
f2fs_is_atomic_file(inode) || f2fs_has_inline_data(inode))
4513+
f2fs_is_atomic_file(inode) || f2fs_has_inline_data(inode) ||
4514+
f2fs_is_mmap_file(inode))
44894515
return false;
44904516
return S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode);
44914517
}

0 commit comments

Comments
 (0)