Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+264 -171
+3 -3
Documentation/ABI/testing/sysfs-fs-f2fs
··· 102 102 Date: November 2013 103 103 Contact: "Jaegeuk Kim" <jaegeuk.kim@samsung.com> 104 104 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. 108 108 109 109 What: /sys/fs/f2fs/<disk>/max_ordered_discard 110 110 Date: October 2022
+1 -1
fs/f2fs/checkpoint.c
··· 1701 1701 } 1702 1702 1703 1703 f2fs_restore_inmem_curseg(sbi); 1704 + stat_inc_cp_count(sbi); 1704 1705 stop: 1705 1706 unblock_operations(sbi); 1706 - stat_inc_cp_count(sbi->stat_info); 1707 1707 1708 1708 if (cpc->reason & CP_RECOVERY) 1709 1709 f2fs_notice(sbi, "checkpoint: version = %llx", ckpt_ver);
+1 -13
fs/f2fs/compress.c
··· 649 649 goto destroy_compress_ctx; 650 650 } 651 651 652 - for (i = 0; i < cc->nr_cpages; i++) { 652 + for (i = 0; i < cc->nr_cpages; i++) 653 653 cc->cpages[i] = f2fs_compress_alloc_page(); 654 - if (!cc->cpages[i]) { 655 - ret = -ENOMEM; 656 - goto out_free_cpages; 657 - } 658 - } 659 654 660 655 cc->rbuf = f2fs_vmap(cc->rpages, cc->cluster_size); 661 656 if (!cc->rbuf) { ··· 1569 1574 } 1570 1575 1571 1576 dic->tpages[i] = f2fs_compress_alloc_page(); 1572 - if (!dic->tpages[i]) 1573 - return -ENOMEM; 1574 1577 } 1575 1578 1576 1579 dic->rbuf = f2fs_vmap(dic->tpages, dic->cluster_size); ··· 1649 1656 struct page *page; 1650 1657 1651 1658 page = f2fs_compress_alloc_page(); 1652 - if (!page) { 1653 - ret = -ENOMEM; 1654 - goto out_free; 1655 - } 1656 - 1657 1659 f2fs_set_compressed_page(page, cc->inode, 1658 1660 start_idx + i + 1, dic); 1659 1661 dic->cpages[i] = page;
+6 -8
fs/f2fs/data.c
··· 1167 1167 f2fs_wait_on_block_writeback(inode, blkaddr); 1168 1168 1169 1169 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); 1170 1173 bio_put(bio); 1171 1174 return -EFAULT; 1172 1175 } ··· 1392 1389 { 1393 1390 struct address_space *mapping = inode->i_mapping; 1394 1391 struct page *page; 1395 - repeat: 1392 + 1396 1393 page = f2fs_get_read_data_page(inode, index, 0, for_write, NULL); 1397 1394 if (IS_ERR(page)) 1398 1395 return page; 1399 1396 1400 1397 /* wait for read completion */ 1401 1398 lock_page(page); 1402 - if (unlikely(page->mapping != mapping)) { 1403 - f2fs_put_page(page, 1); 1404 - goto repeat; 1405 - } 1406 - if (unlikely(!PageUptodate(page))) { 1399 + if (unlikely(page->mapping != mapping || !PageUptodate(page))) { 1407 1400 f2fs_put_page(page, 1); 1408 1401 return ERR_PTR(-EIO); 1409 1402 } ··· 3235 3236 } 3236 3237 goto next; 3237 3238 } 3238 - done_index = folio->index + 3239 - folio_nr_pages(folio); 3239 + done_index = folio_next_index(folio); 3240 3240 done = 1; 3241 3241 break; 3242 3242 }
+26 -7
fs/f2fs/debug.c
··· 215 215 si->valid_blks[type] += blks; 216 216 } 217 217 218 + for (i = 0; i < MAX_CALL_TYPE; i++) 219 + si->cp_call_count[i] = atomic_read(&sbi->cp_call_count[i]); 220 + 218 221 for (i = 0; i < 2; i++) { 219 222 si->segment_count[i] = sbi->segment_count[i]; 220 223 si->block_count[i] = sbi->block_count[i]; ··· 500 497 seq_printf(s, " - Prefree: %d\n - Free: %d (%d)\n\n", 501 498 si->prefree_count, si->free_segs, si->free_secs); 502 499 seq_printf(s, "CP calls: %d (BG: %d)\n", 503 - si->cp_count, si->bg_cp_count); 500 + si->cp_call_count[TOTAL_CALL], 501 + si->cp_call_count[BACKGROUND]); 502 + seq_printf(s, "CP count: %d\n", si->cp_count); 504 503 seq_printf(s, " - cp blocks : %u\n", si->meta_count[META_CP]); 505 504 seq_printf(s, " - sit blocks : %u\n", 506 505 si->meta_count[META_SIT]); ··· 516 511 seq_printf(s, " - Total : %4d\n", si->nr_total_ckpt); 517 512 seq_printf(s, " - Cur time : %4d(ms)\n", si->cur_ckpt_time); 518 513 seq_printf(s, " - Peak time : %4d(ms)\n", si->peak_ckpt_time); 519 - seq_printf(s, "GC calls: %d (BG: %d)\n", 520 - si->call_count, si->bg_gc); 521 - seq_printf(s, " - data segments : %d (%d)\n", 522 - si->data_segs, si->bg_data_segs); 523 - seq_printf(s, " - node segments : %d (%d)\n", 524 - si->node_segs, si->bg_node_segs); 514 + seq_printf(s, "GC calls: %d (gc_thread: %d)\n", 515 + si->gc_call_count[BACKGROUND] + 516 + si->gc_call_count[FOREGROUND], 517 + si->gc_call_count[BACKGROUND]); 518 + if (__is_large_section(sbi)) { 519 + seq_printf(s, " - data sections : %d (BG: %d)\n", 520 + si->gc_secs[DATA][BG_GC] + si->gc_secs[DATA][FG_GC], 521 + si->gc_secs[DATA][BG_GC]); 522 + seq_printf(s, " - node sections : %d (BG: %d)\n", 523 + si->gc_secs[NODE][BG_GC] + si->gc_secs[NODE][FG_GC], 524 + si->gc_secs[NODE][BG_GC]); 525 + } 526 + seq_printf(s, " - data segments : %d (BG: %d)\n", 527 + si->gc_segs[DATA][BG_GC] + si->gc_segs[DATA][FG_GC], 528 + si->gc_segs[DATA][BG_GC]); 529 + seq_printf(s, " - node segments : %d (BG: %d)\n", 530 + si->gc_segs[NODE][BG_GC] + si->gc_segs[NODE][FG_GC], 531 + si->gc_segs[NODE][BG_GC]); 525 532 seq_puts(s, " - Reclaimed segs :\n"); 526 533 seq_printf(s, " - Normal : %d\n", sbi->gc_reclaimed_segs[GC_NORMAL]); 527 534 seq_printf(s, " - Idle CB : %d\n", sbi->gc_reclaimed_segs[GC_IDLE_CB]); ··· 704 687 atomic_set(&sbi->inplace_count, 0); 705 688 for (i = META_CP; i < META_MAX; i++) 706 689 atomic_set(&sbi->meta_count[i], 0); 690 + for (i = 0; i < MAX_CALL_TYPE; i++) 691 + atomic_set(&sbi->cp_call_count[i], 0); 707 692 708 693 atomic_set(&sbi->max_aw_cnt, 0); 709 694
+61 -35
fs/f2fs/f2fs.h
··· 1383 1383 MOUNT_ERRORS_PANIC, /* panic on errors */ 1384 1384 }; 1385 1385 1386 + enum { 1387 + BACKGROUND, 1388 + FOREGROUND, 1389 + MAX_CALL_TYPE, 1390 + TOTAL_CALL = FOREGROUND, 1391 + }; 1392 + 1386 1393 static inline int f2fs_test_bit(unsigned int nr, char *addr); 1387 1394 static inline void f2fs_set_bit(unsigned int nr, char *addr); 1388 1395 static inline void f2fs_clear_bit(unsigned int nr, char *addr); ··· 1702 1695 unsigned int io_skip_bggc; /* skip background gc for in-flight IO */ 1703 1696 unsigned int other_skip_bggc; /* skip background gc for other reasons */ 1704 1697 unsigned int ndirty_inode[NR_INODE_TYPE]; /* # of dirty inodes */ 1698 + atomic_t cp_call_count[MAX_CALL_TYPE]; /* # of cp call */ 1705 1699 #endif 1706 1700 spinlock_t stat_lock; /* lock for stat operations */ 1707 1701 ··· 2122 2114 return down_read_trylock(&sem->internal_rwsem); 2123 2115 } 2124 2116 2125 - #ifdef CONFIG_DEBUG_LOCK_ALLOC 2126 - static inline void f2fs_down_read_nested(struct f2fs_rwsem *sem, int subclass) 2127 - { 2128 - down_read_nested(&sem->internal_rwsem, subclass); 2129 - } 2130 - #else 2131 - #define f2fs_down_read_nested(sem, subclass) f2fs_down_read(sem) 2132 - #endif 2133 - 2134 2117 static inline void f2fs_up_read(struct f2fs_rwsem *sem) 2135 2118 { 2136 2119 up_read(&sem->internal_rwsem); ··· 2131 2132 { 2132 2133 down_write(&sem->internal_rwsem); 2133 2134 } 2135 + 2136 + #ifdef CONFIG_DEBUG_LOCK_ALLOC 2137 + static inline void f2fs_down_read_nested(struct f2fs_rwsem *sem, int subclass) 2138 + { 2139 + down_read_nested(&sem->internal_rwsem, subclass); 2140 + } 2141 + 2142 + static inline void f2fs_down_write_nested(struct f2fs_rwsem *sem, int subclass) 2143 + { 2144 + down_write_nested(&sem->internal_rwsem, subclass); 2145 + } 2146 + #else 2147 + #define f2fs_down_read_nested(sem, subclass) f2fs_down_read(sem) 2148 + #define f2fs_down_write_nested(sem, subclass) f2fs_down_write(sem) 2149 + #endif 2134 2150 2135 2151 static inline int f2fs_down_write_trylock(struct f2fs_rwsem *sem) 2136 2152 { ··· 3901 3887 int nats, dirty_nats, sits, dirty_sits; 3902 3888 int free_nids, avail_nids, alloc_nids; 3903 3889 int total_count, utilization; 3904 - int bg_gc, nr_wb_cp_data, nr_wb_data; 3890 + int nr_wb_cp_data, nr_wb_data; 3905 3891 int nr_rd_data, nr_rd_node, nr_rd_meta; 3906 3892 int nr_dio_read, nr_dio_write; 3907 3893 unsigned int io_skip_bggc, other_skip_bggc; ··· 3921 3907 int rsvd_segs, overp_segs; 3922 3908 int dirty_count, node_pages, meta_pages, compress_pages; 3923 3909 int compress_page_hit; 3924 - int prefree_count, call_count, cp_count, bg_cp_count; 3925 - int tot_segs, node_segs, data_segs, free_segs, free_secs; 3926 - int bg_node_segs, bg_data_segs; 3910 + int prefree_count, free_segs, free_secs; 3911 + int cp_call_count[MAX_CALL_TYPE], cp_count; 3912 + int gc_call_count[MAX_CALL_TYPE]; 3913 + int gc_segs[2][2]; 3914 + int gc_secs[2][2]; 3927 3915 int tot_blks, data_blks, node_blks; 3928 3916 int bg_data_blks, bg_node_blks; 3929 3917 int curseg[NR_CURSEG_TYPE]; ··· 3947 3931 return (struct f2fs_stat_info *)sbi->stat_info; 3948 3932 } 3949 3933 3950 - #define stat_inc_cp_count(si) ((si)->cp_count++) 3951 - #define stat_inc_bg_cp_count(si) ((si)->bg_cp_count++) 3952 - #define stat_inc_call_count(si) ((si)->call_count++) 3953 - #define stat_inc_bggc_count(si) ((si)->bg_gc++) 3934 + #define stat_inc_cp_call_count(sbi, foreground) \ 3935 + atomic_inc(&sbi->cp_call_count[(foreground)]) 3936 + #define stat_inc_cp_count(si) (F2FS_STAT(sbi)->cp_count++) 3954 3937 #define stat_io_skip_bggc_count(sbi) ((sbi)->io_skip_bggc++) 3955 3938 #define stat_other_skip_bggc_count(sbi) ((sbi)->other_skip_bggc++) 3956 3939 #define stat_inc_dirty_inode(sbi, type) ((sbi)->ndirty_inode[type]++) ··· 4034 4019 if (cur > max) \ 4035 4020 atomic_set(&F2FS_I_SB(inode)->max_aw_cnt, cur); \ 4036 4021 } while (0) 4037 - #define stat_inc_seg_count(sbi, type, gc_type) \ 4038 - do { \ 4039 - struct f2fs_stat_info *si = F2FS_STAT(sbi); \ 4040 - si->tot_segs++; \ 4041 - if ((type) == SUM_TYPE_DATA) { \ 4042 - si->data_segs++; \ 4043 - si->bg_data_segs += (gc_type == BG_GC) ? 1 : 0; \ 4044 - } else { \ 4045 - si->node_segs++; \ 4046 - si->bg_node_segs += (gc_type == BG_GC) ? 1 : 0; \ 4047 - } \ 4048 - } while (0) 4022 + #define stat_inc_gc_call_count(sbi, foreground) \ 4023 + (F2FS_STAT(sbi)->gc_call_count[(foreground)]++) 4024 + #define stat_inc_gc_sec_count(sbi, type, gc_type) \ 4025 + (F2FS_STAT(sbi)->gc_secs[(type)][(gc_type)]++) 4026 + #define stat_inc_gc_seg_count(sbi, type, gc_type) \ 4027 + (F2FS_STAT(sbi)->gc_segs[(type)][(gc_type)]++) 4049 4028 4050 4029 #define stat_inc_tot_blk_count(si, blks) \ 4051 4030 ((si)->tot_blks += (blks)) ··· 4066 4057 void f2fs_destroy_root_stats(void); 4067 4058 void f2fs_update_sit_info(struct f2fs_sb_info *sbi); 4068 4059 #else 4069 - #define stat_inc_cp_count(si) do { } while (0) 4070 - #define stat_inc_bg_cp_count(si) do { } while (0) 4071 - #define stat_inc_call_count(si) do { } while (0) 4072 - #define stat_inc_bggc_count(si) do { } while (0) 4060 + #define stat_inc_cp_call_count(sbi, foreground) do { } while (0) 4061 + #define stat_inc_cp_count(sbi) do { } while (0) 4073 4062 #define stat_io_skip_bggc_count(sbi) do { } while (0) 4074 4063 #define stat_other_skip_bggc_count(sbi) do { } while (0) 4075 4064 #define stat_inc_dirty_inode(sbi, type) do { } while (0) ··· 4095 4088 #define stat_inc_seg_type(sbi, curseg) do { } while (0) 4096 4089 #define stat_inc_block_count(sbi, curseg) do { } while (0) 4097 4090 #define stat_inc_inplace_blocks(sbi) do { } while (0) 4098 - #define stat_inc_seg_count(sbi, type, gc_type) do { } while (0) 4091 + #define stat_inc_gc_call_count(sbi, foreground) do { } while (0) 4092 + #define stat_inc_gc_sec_count(sbi, type, gc_type) do { } while (0) 4093 + #define stat_inc_gc_seg_count(sbi, type, gc_type) do { } while (0) 4099 4094 #define stat_inc_tot_blk_count(si, blks) do { } while (0) 4100 4095 #define stat_inc_data_blk_count(sbi, blks, gc_type) do { } while (0) 4101 4096 #define stat_inc_node_blk_count(sbi, blks, gc_type) do { } while (0) ··· 4434 4425 } 4435 4426 #endif 4436 4427 4428 + static inline int f2fs_bdev_index(struct f2fs_sb_info *sbi, 4429 + struct block_device *bdev) 4430 + { 4431 + int i; 4432 + 4433 + if (!f2fs_is_multi_device(sbi)) 4434 + return 0; 4435 + 4436 + for (i = 0; i < sbi->s_ndevs; i++) 4437 + if (FDEV(i).bdev == bdev) 4438 + return i; 4439 + 4440 + WARN_ON(1); 4441 + return -1; 4442 + } 4443 + 4437 4444 static inline bool f2fs_hw_should_discard(struct f2fs_sb_info *sbi) 4438 4445 { 4439 4446 return f2fs_sb_has_blkzoned(sbi); ··· 4510 4485 static inline bool f2fs_may_compress(struct inode *inode) 4511 4486 { 4512 4487 if (IS_SWAPFILE(inode) || f2fs_is_pinned_file(inode) || 4513 - f2fs_is_atomic_file(inode) || f2fs_has_inline_data(inode)) 4488 + f2fs_is_atomic_file(inode) || f2fs_has_inline_data(inode) || 4489 + f2fs_is_mmap_file(inode)) 4514 4490 return false; 4515 4491 return S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode); 4516 4492 }
+43 -17
fs/f2fs/file.c
··· 526 526 527 527 file_accessed(file); 528 528 vma->vm_ops = &f2fs_file_vm_ops; 529 + 530 + f2fs_down_read(&F2FS_I(inode)->i_sem); 529 531 set_inode_flag(inode, FI_MMAP_FILE); 532 + f2fs_up_read(&F2FS_I(inode)->i_sem); 533 + 530 534 return 0; 531 535 } 532 536 ··· 1728 1724 if (has_not_enough_free_secs(sbi, 0, 1729 1725 GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))) { 1730 1726 f2fs_down_write(&sbi->gc_lock); 1727 + stat_inc_gc_call_count(sbi, FOREGROUND); 1731 1728 err = f2fs_gc(sbi, &gc_control); 1732 1729 if (err && err != -ENODATA) 1733 1730 goto out_err; ··· 1924 1919 int err = f2fs_convert_inline_inode(inode); 1925 1920 if (err) 1926 1921 return err; 1927 - if (!f2fs_may_compress(inode)) 1922 + 1923 + f2fs_down_write(&F2FS_I(inode)->i_sem); 1924 + if (!f2fs_may_compress(inode) || 1925 + (S_ISREG(inode->i_mode) && 1926 + F2FS_HAS_BLOCKS(inode))) { 1927 + f2fs_up_write(&F2FS_I(inode)->i_sem); 1928 1928 return -EINVAL; 1929 - if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode)) 1930 - return -EINVAL; 1931 - if (set_compress_context(inode)) 1932 - return -EOPNOTSUPP; 1929 + } 1930 + err = set_compress_context(inode); 1931 + f2fs_up_write(&F2FS_I(inode)->i_sem); 1932 + 1933 + if (err) 1934 + return err; 1933 1935 } 1934 1936 } 1935 1937 ··· 2477 2465 2478 2466 gc_control.init_gc_type = sync ? FG_GC : BG_GC; 2479 2467 gc_control.err_gc_skipped = sync; 2468 + stat_inc_gc_call_count(sbi, FOREGROUND); 2480 2469 ret = f2fs_gc(sbi, &gc_control); 2481 2470 out: 2482 2471 mnt_drop_write_file(filp); ··· 2521 2508 } 2522 2509 2523 2510 gc_control.victim_segno = GET_SEGNO(sbi, range->start); 2511 + stat_inc_gc_call_count(sbi, FOREGROUND); 2524 2512 ret = f2fs_gc(sbi, &gc_control); 2525 2513 if (ret) { 2526 2514 if (ret == -EBUSY) ··· 3004 2990 sm->last_victim[ALLOC_NEXT] = end_segno + 1; 3005 2991 3006 2992 gc_control.victim_segno = start_segno; 2993 + stat_inc_gc_call_count(sbi, FOREGROUND); 3007 2994 ret = f2fs_gc(sbi, &gc_control); 3008 2995 if (ret == -EAGAIN) 3009 2996 ret = 0; ··· 3991 3976 file_start_write(filp); 3992 3977 inode_lock(inode); 3993 3978 3979 + f2fs_down_write(&F2FS_I(inode)->i_sem); 3994 3980 if (f2fs_is_mmap_file(inode) || get_dirty_pages(inode)) { 3995 3981 ret = -EBUSY; 3996 3982 goto out; ··· 4011 3995 f2fs_warn(sbi, "compression algorithm is successfully set, " 4012 3996 "but current kernel doesn't support this algorithm."); 4013 3997 out: 3998 + f2fs_up_write(&F2FS_I(inode)->i_sem); 4014 3999 inode_unlock(inode); 4015 4000 file_end_write(filp); 4016 4001 ··· 4096 4079 last_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); 4097 4080 4098 4081 count = last_idx - page_idx; 4099 - while (count) { 4100 - int len = min(cluster_size, count); 4101 - 4102 - ret = redirty_blocks(inode, page_idx, len); 4082 + while (count && count >= cluster_size) { 4083 + ret = redirty_blocks(inode, page_idx, cluster_size); 4103 4084 if (ret < 0) 4104 4085 break; 4105 4086 ··· 4107 4092 break; 4108 4093 } 4109 4094 4110 - count -= len; 4111 - page_idx += len; 4095 + count -= cluster_size; 4096 + page_idx += cluster_size; 4097 + 4098 + cond_resched(); 4099 + if (fatal_signal_pending(current)) { 4100 + ret = -EINTR; 4101 + break; 4102 + } 4112 4103 } 4113 4104 4114 4105 if (!ret) ··· 4174 4153 last_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); 4175 4154 4176 4155 count = last_idx - page_idx; 4177 - while (count) { 4178 - int len = min(cluster_size, count); 4179 - 4180 - ret = redirty_blocks(inode, page_idx, len); 4156 + while (count && count >= cluster_size) { 4157 + ret = redirty_blocks(inode, page_idx, cluster_size); 4181 4158 if (ret < 0) 4182 4159 break; 4183 4160 ··· 4185 4166 break; 4186 4167 } 4187 4168 4188 - count -= len; 4189 - page_idx += len; 4169 + count -= cluster_size; 4170 + page_idx += cluster_size; 4171 + 4172 + cond_resched(); 4173 + if (fatal_signal_pending(current)) { 4174 + ret = -EINTR; 4175 + break; 4176 + } 4190 4177 } 4191 4178 4192 4179 if (!ret) ··· 4604 4579 dec_page_count(sbi, F2FS_DIO_WRITE); 4605 4580 if (error) 4606 4581 return error; 4582 + f2fs_update_time(sbi, REQ_TIME); 4607 4583 f2fs_update_iostat(sbi, NULL, APP_DIRECT_IO, size); 4608 4584 return 0; 4609 4585 }
+12 -6
fs/f2fs/gc.c
··· 121 121 else 122 122 increase_sleep_time(gc_th, &wait_ms); 123 123 do_gc: 124 - if (!foreground) 125 - stat_inc_bggc_count(sbi->stat_info); 124 + stat_inc_gc_call_count(sbi, foreground ? 125 + FOREGROUND : BACKGROUND); 126 126 127 127 sync_mode = F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC; 128 128 ··· 1685 1685 int seg_freed = 0, migrated = 0; 1686 1686 unsigned char type = IS_DATASEG(get_seg_entry(sbi, segno)->type) ? 1687 1687 SUM_TYPE_DATA : SUM_TYPE_NODE; 1688 + unsigned char data_type = (type == SUM_TYPE_DATA) ? DATA : NODE; 1688 1689 int submitted = 0; 1689 1690 1690 1691 if (__is_large_section(sbi)) ··· 1767 1766 segno, gc_type, 1768 1767 force_migrate); 1769 1768 1770 - stat_inc_seg_count(sbi, type, gc_type); 1769 + stat_inc_gc_seg_count(sbi, data_type, gc_type); 1771 1770 sbi->gc_reclaimed_segs[sbi->gc_mode]++; 1772 1771 migrated++; 1773 1772 ··· 1784 1783 } 1785 1784 1786 1785 if (submitted) 1787 - f2fs_submit_merged_write(sbi, 1788 - (type == SUM_TYPE_NODE) ? NODE : DATA); 1786 + f2fs_submit_merged_write(sbi, data_type); 1789 1787 1790 1788 blk_finish_plug(&plug); 1791 1789 1792 - stat_inc_call_count(sbi->stat_info); 1790 + if (migrated) 1791 + stat_inc_gc_sec_count(sbi, data_type, gc_type); 1793 1792 1794 1793 return seg_freed; 1795 1794 } ··· 1840 1839 * secure free segments which doesn't need fggc any more. 1841 1840 */ 1842 1841 if (prefree_segments(sbi)) { 1842 + stat_inc_cp_call_count(sbi, TOTAL_CALL); 1843 1843 ret = f2fs_write_checkpoint(sbi, &cpc); 1844 1844 if (ret) 1845 1845 goto stop; ··· 1889 1887 round++; 1890 1888 if (skipped_round > MAX_SKIP_GC_COUNT && 1891 1889 skipped_round * 2 >= round) { 1890 + stat_inc_cp_call_count(sbi, TOTAL_CALL); 1892 1891 ret = f2fs_write_checkpoint(sbi, &cpc); 1893 1892 goto stop; 1894 1893 } ··· 1905 1902 */ 1906 1903 if (free_sections(sbi) <= upper_secs + NR_GC_CHECKPOINT_SECS && 1907 1904 prefree_segments(sbi)) { 1905 + stat_inc_cp_call_count(sbi, TOTAL_CALL); 1908 1906 ret = f2fs_write_checkpoint(sbi, &cpc); 1909 1907 if (ret) 1910 1908 goto stop; ··· 2033 2029 if (gc_only) 2034 2030 goto out; 2035 2031 2032 + stat_inc_cp_call_count(sbi, TOTAL_CALL); 2036 2033 err = f2fs_write_checkpoint(sbi, &cpc); 2037 2034 if (err) 2038 2035 goto out; ··· 2228 2223 clear_sbi_flag(sbi, SBI_IS_RESIZEFS); 2229 2224 set_sbi_flag(sbi, SBI_IS_DIRTY); 2230 2225 2226 + stat_inc_cp_call_count(sbi, TOTAL_CALL); 2231 2227 err = f2fs_write_checkpoint(sbi, &cpc); 2232 2228 if (err) { 2233 2229 update_fs_metadata(sbi, secs);
+2 -1
fs/f2fs/inline.c
··· 641 641 } 642 642 643 643 if (inode) { 644 - f2fs_down_write(&F2FS_I(inode)->i_sem); 644 + f2fs_down_write_nested(&F2FS_I(inode)->i_sem, 645 + SINGLE_DEPTH_NESTING); 645 646 page = f2fs_init_inode_metadata(inode, dir, fname, ipage); 646 647 if (IS_ERR(page)) { 647 648 err = PTR_ERR(page);
+10 -25
fs/f2fs/inode.c
··· 214 214 f2fs_warn(sbi, 215 215 "%s: inode (ino=%lx) has unsupported compress algorithm: %u, run fsck to fix", 216 216 __func__, inode->i_ino, ri->i_compress_algorithm); 217 - goto err; 217 + return false; 218 218 } 219 219 if (le64_to_cpu(ri->i_compr_blocks) > 220 220 SECTOR_TO_BLOCK(inode->i_blocks)) { ··· 222 222 "%s: inode (ino=%lx) has inconsistent i_compr_blocks:%llu, i_blocks:%llu, run fsck to fix", 223 223 __func__, inode->i_ino, le64_to_cpu(ri->i_compr_blocks), 224 224 SECTOR_TO_BLOCK(inode->i_blocks)); 225 - goto err; 225 + return false; 226 226 } 227 227 if (ri->i_log_cluster_size < MIN_COMPRESS_LOG_SIZE || 228 228 ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE) { 229 229 f2fs_warn(sbi, 230 230 "%s: inode (ino=%lx) has unsupported log cluster size: %u, run fsck to fix", 231 231 __func__, inode->i_ino, ri->i_log_cluster_size); 232 - goto err; 232 + return false; 233 233 } 234 234 235 235 clevel = le16_to_cpu(ri->i_compress_flag) >> ··· 273 273 err_level: 274 274 f2fs_warn(sbi, "%s: inode (ino=%lx) has unsupported compress level: %u, run fsck to fix", 275 275 __func__, inode->i_ino, clevel); 276 - err: 277 - set_sbi_flag(sbi, SBI_NEED_FSCK); 278 276 return false; 279 277 } 280 278 ··· 285 287 286 288 iblocks = le64_to_cpu(F2FS_INODE(node_page)->i_blocks); 287 289 if (!iblocks) { 288 - set_sbi_flag(sbi, SBI_NEED_FSCK); 289 290 f2fs_warn(sbi, "%s: corrupted inode i_blocks i_ino=%lx iblocks=%llu, run fsck to fix.", 290 291 __func__, inode->i_ino, iblocks); 291 292 return false; 292 293 } 293 294 294 295 if (ino_of_node(node_page) != nid_of_node(node_page)) { 295 - set_sbi_flag(sbi, SBI_NEED_FSCK); 296 296 f2fs_warn(sbi, "%s: corrupted inode footer i_ino=%lx, ino,nid: [%u, %u] run fsck to fix.", 297 297 __func__, inode->i_ino, 298 298 ino_of_node(node_page), nid_of_node(node_page)); ··· 299 303 300 304 if (f2fs_has_extra_attr(inode)) { 301 305 if (!f2fs_sb_has_extra_attr(sbi)) { 302 - set_sbi_flag(sbi, SBI_NEED_FSCK); 303 306 f2fs_warn(sbi, "%s: inode (ino=%lx) is with extra_attr, but extra_attr feature is off", 304 307 __func__, inode->i_ino); 305 308 return false; ··· 306 311 if (fi->i_extra_isize > F2FS_TOTAL_EXTRA_ATTR_SIZE || 307 312 fi->i_extra_isize < F2FS_MIN_EXTRA_ATTR_SIZE || 308 313 fi->i_extra_isize % sizeof(__le32)) { 309 - set_sbi_flag(sbi, SBI_NEED_FSCK); 310 314 f2fs_warn(sbi, "%s: inode (ino=%lx) has corrupted i_extra_isize: %d, max: %zu", 311 315 __func__, inode->i_ino, fi->i_extra_isize, 312 316 F2FS_TOTAL_EXTRA_ATTR_SIZE); ··· 315 321 f2fs_has_inline_xattr(inode) && 316 322 (!fi->i_inline_xattr_size || 317 323 fi->i_inline_xattr_size > MAX_INLINE_XATTR_SIZE)) { 318 - set_sbi_flag(sbi, SBI_NEED_FSCK); 319 324 f2fs_warn(sbi, "%s: inode (ino=%lx) has corrupted i_inline_xattr_size: %d, max: %zu", 320 325 __func__, inode->i_ino, fi->i_inline_xattr_size, 321 326 MAX_INLINE_XATTR_SIZE); ··· 328 335 return false; 329 336 } 330 337 } else if (f2fs_sb_has_flexible_inline_xattr(sbi)) { 331 - set_sbi_flag(sbi, SBI_NEED_FSCK); 332 338 f2fs_warn(sbi, "%s: corrupted inode ino=%lx, run fsck to fix.", 333 339 __func__, inode->i_ino); 334 340 return false; ··· 335 343 336 344 if (!f2fs_sb_has_extra_attr(sbi)) { 337 345 if (f2fs_sb_has_project_quota(sbi)) { 338 - set_sbi_flag(sbi, SBI_NEED_FSCK); 339 346 f2fs_warn(sbi, "%s: corrupted inode ino=%lx, wrong feature flag: %u, run fsck to fix.", 340 347 __func__, inode->i_ino, F2FS_FEATURE_PRJQUOTA); 341 348 return false; 342 349 } 343 350 if (f2fs_sb_has_inode_chksum(sbi)) { 344 - set_sbi_flag(sbi, SBI_NEED_FSCK); 345 351 f2fs_warn(sbi, "%s: corrupted inode ino=%lx, wrong feature flag: %u, run fsck to fix.", 346 352 __func__, inode->i_ino, F2FS_FEATURE_INODE_CHKSUM); 347 353 return false; 348 354 } 349 355 if (f2fs_sb_has_flexible_inline_xattr(sbi)) { 350 - set_sbi_flag(sbi, SBI_NEED_FSCK); 351 356 f2fs_warn(sbi, "%s: corrupted inode ino=%lx, wrong feature flag: %u, run fsck to fix.", 352 357 __func__, inode->i_ino, F2FS_FEATURE_FLEXIBLE_INLINE_XATTR); 353 358 return false; 354 359 } 355 360 if (f2fs_sb_has_inode_crtime(sbi)) { 356 - set_sbi_flag(sbi, SBI_NEED_FSCK); 357 361 f2fs_warn(sbi, "%s: corrupted inode ino=%lx, wrong feature flag: %u, run fsck to fix.", 358 362 __func__, inode->i_ino, F2FS_FEATURE_INODE_CRTIME); 359 363 return false; 360 364 } 361 365 if (f2fs_sb_has_compression(sbi)) { 362 - set_sbi_flag(sbi, SBI_NEED_FSCK); 363 366 f2fs_warn(sbi, "%s: corrupted inode ino=%lx, wrong feature flag: %u, run fsck to fix.", 364 367 __func__, inode->i_ino, F2FS_FEATURE_COMPRESSION); 365 368 return false; ··· 362 375 } 363 376 364 377 if (f2fs_sanity_check_inline_data(inode)) { 365 - set_sbi_flag(sbi, SBI_NEED_FSCK); 366 378 f2fs_warn(sbi, "%s: inode (ino=%lx, mode=%u) should not have inline_data, run fsck to fix", 367 379 __func__, inode->i_ino, inode->i_mode); 368 380 return false; 369 381 } 370 382 371 383 if (f2fs_has_inline_dentry(inode) && !S_ISDIR(inode->i_mode)) { 372 - set_sbi_flag(sbi, SBI_NEED_FSCK); 373 384 f2fs_warn(sbi, "%s: inode (ino=%lx, mode=%u) should not have inline_dentry, run fsck to fix", 374 385 __func__, inode->i_ino, inode->i_mode); 375 386 return false; 376 387 } 377 388 378 389 if ((fi->i_flags & F2FS_CASEFOLD_FL) && !f2fs_sb_has_casefold(sbi)) { 379 - set_sbi_flag(sbi, SBI_NEED_FSCK); 380 390 f2fs_warn(sbi, "%s: inode (ino=%lx) has casefold flag, but casefold feature is off", 381 391 __func__, inode->i_ino); 382 392 return false; ··· 459 475 fi->i_inline_xattr_size = 0; 460 476 } 461 477 478 + if (!sanity_check_inode(inode, node_page)) { 479 + f2fs_put_page(node_page, 1); 480 + set_sbi_flag(sbi, SBI_NEED_FSCK); 481 + f2fs_handle_error(sbi, ERROR_CORRUPTED_INODE); 482 + return -EFSCORRUPTED; 483 + } 484 + 462 485 /* check data exist */ 463 486 if (f2fs_has_inline_data(inode) && !f2fs_exist_data(inode)) 464 487 __recover_inline_status(inode, node_page); ··· 534 543 /* Need all the flag bits */ 535 544 f2fs_init_read_extent_tree(inode, node_page); 536 545 f2fs_init_age_extent_tree(inode); 537 - 538 - if (!sanity_check_inode(inode, node_page)) { 539 - f2fs_put_page(node_page, 1); 540 - f2fs_handle_error(sbi, ERROR_CORRUPTED_INODE); 541 - return -EFSCORRUPTED; 542 - } 543 546 544 547 if (!sanity_check_extent_cache(inode)) { 545 548 f2fs_put_page(node_page, 1);
+1
fs/f2fs/recovery.c
··· 924 924 struct cp_control cpc = { 925 925 .reason = CP_RECOVERY, 926 926 }; 927 + stat_inc_cp_call_count(sbi, TOTAL_CALL); 927 928 err = f2fs_write_checkpoint(sbi, &cpc); 928 929 } 929 930 }
+59 -30
fs/f2fs/segment.c
··· 205 205 f2fs_i_size_write(inode, fi->original_i_size); 206 206 fi->original_i_size = 0; 207 207 } 208 + /* avoid stale dirty inode during eviction */ 209 + sync_inode_metadata(inode, 0); 208 210 } 209 211 210 212 static int __replace_atomic_write_block(struct inode *inode, pgoff_t index, ··· 435 433 .err_gc_skipped = false, 436 434 .nr_free_secs = 1 }; 437 435 f2fs_down_write(&sbi->gc_lock); 436 + stat_inc_gc_call_count(sbi, FOREGROUND); 438 437 f2fs_gc(sbi, &gc_control); 439 438 } 440 439 } ··· 513 510 514 511 mutex_unlock(&sbi->flush_lock); 515 512 } 513 + stat_inc_cp_call_count(sbi, BACKGROUND); 516 514 f2fs_sync_fs(sbi->sb, 1); 517 - stat_inc_bg_cp_count(sbi->stat_info); 518 515 } 519 516 520 517 static int __submit_flush_wait(struct f2fs_sb_info *sbi, ··· 1261 1258 1262 1259 #ifdef CONFIG_BLK_DEV_ZONED 1263 1260 if (f2fs_sb_has_blkzoned(sbi) && bdev_is_zoned(bdev)) { 1264 - __submit_zone_reset_cmd(sbi, dc, flag, wait_list, issued); 1265 - return 0; 1261 + int devi = f2fs_bdev_index(sbi, bdev); 1262 + 1263 + if (devi < 0) 1264 + return -EINVAL; 1265 + 1266 + if (f2fs_blkz_is_seq(sbi, devi, dc->di.start)) { 1267 + __submit_zone_reset_cmd(sbi, dc, flag, 1268 + wait_list, issued); 1269 + return 0; 1270 + } 1266 1271 } 1267 1272 #endif 1268 1273 ··· 1796 1785 dc = __lookup_discard_cmd(sbi, blkaddr); 1797 1786 #ifdef CONFIG_BLK_DEV_ZONED 1798 1787 if (dc && f2fs_sb_has_blkzoned(sbi) && bdev_is_zoned(dc->bdev)) { 1799 - /* force submit zone reset */ 1800 - if (dc->state == D_PREP) 1801 - __submit_zone_reset_cmd(sbi, dc, REQ_SYNC, 1802 - &dcc->wait_list, NULL); 1803 - dc->ref++; 1804 - mutex_unlock(&dcc->cmd_lock); 1805 - /* wait zone reset */ 1806 - __wait_one_discard_bio(sbi, dc); 1807 - return; 1788 + int devi = f2fs_bdev_index(sbi, dc->bdev); 1789 + 1790 + if (devi < 0) { 1791 + mutex_unlock(&dcc->cmd_lock); 1792 + return; 1793 + } 1794 + 1795 + if (f2fs_blkz_is_seq(sbi, devi, dc->di.start)) { 1796 + /* force submit zone reset */ 1797 + if (dc->state == D_PREP) 1798 + __submit_zone_reset_cmd(sbi, dc, REQ_SYNC, 1799 + &dcc->wait_list, NULL); 1800 + dc->ref++; 1801 + mutex_unlock(&dcc->cmd_lock); 1802 + /* wait zone reset */ 1803 + __wait_one_discard_bio(sbi, dc); 1804 + return; 1805 + } 1808 1806 } 1809 1807 #endif 1810 1808 if (dc) { ··· 2213 2193 len = next_pos - cur_pos; 2214 2194 2215 2195 if (f2fs_sb_has_blkzoned(sbi) || 2216 - !force || len < cpc->trim_minlen) 2196 + (force && len < cpc->trim_minlen)) 2217 2197 goto skip; 2218 2198 2219 2199 f2fs_issue_discard(sbi, entry->start_blkaddr + cur_pos, ··· 3248 3228 goto out; 3249 3229 3250 3230 f2fs_down_write(&sbi->gc_lock); 3231 + stat_inc_cp_call_count(sbi, TOTAL_CALL); 3251 3232 err = f2fs_write_checkpoint(sbi, &cpc); 3252 3233 f2fs_up_write(&sbi->gc_lock); 3253 3234 if (err) ··· 4867 4846 { 4868 4847 unsigned int wp_segno, wp_blkoff, zone_secno, zone_segno, segno; 4869 4848 block_t zone_block, wp_block, last_valid_block; 4849 + unsigned int log_sectors_per_block = sbi->log_blocksize - SECTOR_SHIFT; 4870 4850 int i, s, b, ret; 4871 4851 struct seg_entry *se; 4872 4852 4873 4853 if (zone->type != BLK_ZONE_TYPE_SEQWRITE_REQ) 4874 4854 return 0; 4875 4855 4876 - wp_block = fdev->start_blk + (zone->wp >> sbi->log_sectors_per_block); 4856 + wp_block = fdev->start_blk + (zone->wp >> log_sectors_per_block); 4877 4857 wp_segno = GET_SEGNO(sbi, wp_block); 4878 4858 wp_blkoff = wp_block - START_BLOCK(sbi, wp_segno); 4879 - zone_block = fdev->start_blk + (zone->start >> 4880 - sbi->log_sectors_per_block); 4859 + zone_block = fdev->start_blk + (zone->start >> log_sectors_per_block); 4881 4860 zone_segno = GET_SEGNO(sbi, zone_block); 4882 4861 zone_secno = GET_SEC_FROM_SEG(sbi, zone_segno); 4883 4862 ··· 4927 4906 "pointer. Reset the write pointer: wp[0x%x,0x%x]", 4928 4907 wp_segno, wp_blkoff); 4929 4908 ret = __f2fs_issue_discard_zone(sbi, fdev->bdev, zone_block, 4930 - zone->len >> sbi->log_sectors_per_block); 4909 + zone->len >> log_sectors_per_block); 4931 4910 if (ret) 4932 4911 f2fs_err(sbi, "Discard zone failed: %s (errno=%d)", 4933 4912 fdev->path, ret); ··· 4948 4927 GET_BLKOFF_FROM_SEG0(sbi, last_valid_block), 4949 4928 wp_segno, wp_blkoff); 4950 4929 4951 - ret = blkdev_issue_zeroout(fdev->bdev, zone->wp, 4952 - zone->len - (zone->wp - zone->start), 4953 - GFP_NOFS, 0); 4954 - if (ret) 4955 - f2fs_err(sbi, "Fill up zone failed: %s (errno=%d)", 4956 - fdev->path, ret); 4930 + ret = blkdev_zone_mgmt(fdev->bdev, REQ_OP_ZONE_FINISH, 4931 + zone->start, zone->len, GFP_NOFS); 4932 + if (ret == -EOPNOTSUPP) { 4933 + ret = blkdev_issue_zeroout(fdev->bdev, zone->wp, 4934 + zone->len - (zone->wp - zone->start), 4935 + GFP_NOFS, 0); 4936 + if (ret) 4937 + f2fs_err(sbi, "Fill up zone failed: %s (errno=%d)", 4938 + fdev->path, ret); 4939 + } else if (ret) { 4940 + f2fs_err(sbi, "Finishing zone failed: %s (errno=%d)", 4941 + fdev->path, ret); 4942 + } 4957 4943 4958 4944 return ret; 4959 4945 } ··· 4995 4967 struct blk_zone zone; 4996 4968 unsigned int cs_section, wp_segno, wp_blkoff, wp_sector_off; 4997 4969 block_t cs_zone_block, wp_block; 4970 + unsigned int log_sectors_per_block = sbi->log_blocksize - SECTOR_SHIFT; 4998 4971 sector_t zone_sector; 4999 4972 int err; 5000 4973 ··· 5007 4978 return 0; 5008 4979 5009 4980 /* report zone for the sector the curseg points to */ 5010 - zone_sector = (sector_t)(cs_zone_block - zbd->start_blk) << 5011 - sbi->log_sectors_per_block; 4981 + zone_sector = (sector_t)(cs_zone_block - zbd->start_blk) 4982 + << log_sectors_per_block; 5012 4983 err = blkdev_report_zones(zbd->bdev, zone_sector, 1, 5013 4984 report_one_zone_cb, &zone); 5014 4985 if (err != 1) { ··· 5020 4991 if (zone.type != BLK_ZONE_TYPE_SEQWRITE_REQ) 5021 4992 return 0; 5022 4993 5023 - wp_block = zbd->start_blk + (zone.wp >> sbi->log_sectors_per_block); 4994 + wp_block = zbd->start_blk + (zone.wp >> log_sectors_per_block); 5024 4995 wp_segno = GET_SEGNO(sbi, wp_block); 5025 4996 wp_blkoff = wp_block - START_BLOCK(sbi, wp_segno); 5026 - wp_sector_off = zone.wp & GENMASK(sbi->log_sectors_per_block - 1, 0); 4997 + wp_sector_off = zone.wp & GENMASK(log_sectors_per_block - 1, 0); 5027 4998 5028 4999 if (cs->segno == wp_segno && cs->next_blkoff == wp_blkoff && 5029 5000 wp_sector_off == 0) ··· 5050 5021 if (!zbd) 5051 5022 return 0; 5052 5023 5053 - zone_sector = (sector_t)(cs_zone_block - zbd->start_blk) << 5054 - sbi->log_sectors_per_block; 5024 + zone_sector = (sector_t)(cs_zone_block - zbd->start_blk) 5025 + << log_sectors_per_block; 5055 5026 err = blkdev_report_zones(zbd->bdev, zone_sector, 1, 5056 5027 report_one_zone_cb, &zone); 5057 5028 if (err != 1) { ··· 5069 5040 "Reset the zone: curseg[0x%x,0x%x]", 5070 5041 type, cs->segno, cs->next_blkoff); 5071 5042 err = __f2fs_issue_discard_zone(sbi, zbd->bdev, cs_zone_block, 5072 - zone.len >> sbi->log_sectors_per_block); 5043 + zone.len >> log_sectors_per_block); 5073 5044 if (err) { 5074 5045 f2fs_err(sbi, "Discard zone failed: %s (errno=%d)", 5075 5046 zbd->path, err);
+22 -18
fs/f2fs/super.c
··· 591 591 unsigned int level; 592 592 593 593 if (strlen(str) == 3) { 594 - F2FS_OPTION(sbi).compress_level = LZ4HC_DEFAULT_CLEVEL; 594 + F2FS_OPTION(sbi).compress_level = 0; 595 595 return 0; 596 596 } 597 597 ··· 862 862 if (!name) 863 863 return -ENOMEM; 864 864 if (!strcmp(name, "adaptive")) { 865 - if (f2fs_sb_has_blkzoned(sbi)) { 866 - f2fs_warn(sbi, "adaptive mode is not allowed with zoned block device feature"); 867 - kfree(name); 868 - return -EINVAL; 869 - } 870 865 F2FS_OPTION(sbi).fs_mode = FS_MODE_ADAPTIVE; 871 866 } else if (!strcmp(name, "lfs")) { 872 867 F2FS_OPTION(sbi).fs_mode = FS_MODE_LFS; ··· 1326 1331 F2FS_OPTION(sbi).discard_unit = 1327 1332 DISCARD_UNIT_SECTION; 1328 1333 } 1334 + 1335 + if (F2FS_OPTION(sbi).fs_mode != FS_MODE_LFS) { 1336 + f2fs_info(sbi, "Only lfs mode is allowed with zoned block device feature"); 1337 + return -EINVAL; 1338 + } 1329 1339 #else 1330 1340 f2fs_err(sbi, "Zoned block device support is not enabled"); 1331 1341 return -EINVAL; ··· 1561 1561 int i; 1562 1562 1563 1563 for (i = 0; i < sbi->s_ndevs; i++) { 1564 - blkdev_put(FDEV(i).bdev, sbi->sb); 1564 + if (i > 0) 1565 + blkdev_put(FDEV(i).bdev, sbi->sb); 1565 1566 #ifdef CONFIG_BLK_DEV_ZONED 1566 1567 kvfree(FDEV(i).blkz_seq); 1567 1568 #endif ··· 1601 1600 struct cp_control cpc = { 1602 1601 .reason = CP_UMOUNT, 1603 1602 }; 1603 + stat_inc_cp_call_count(sbi, TOTAL_CALL); 1604 1604 err = f2fs_write_checkpoint(sbi, &cpc); 1605 1605 } 1606 1606 ··· 1611 1609 struct cp_control cpc = { 1612 1610 .reason = CP_UMOUNT | CP_TRIMMED, 1613 1611 }; 1612 + stat_inc_cp_call_count(sbi, TOTAL_CALL); 1614 1613 err = f2fs_write_checkpoint(sbi, &cpc); 1615 1614 } 1616 1615 ··· 1708 1705 if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING))) 1709 1706 return -EAGAIN; 1710 1707 1711 - if (sync) 1708 + if (sync) { 1709 + stat_inc_cp_call_count(sbi, TOTAL_CALL); 1712 1710 err = f2fs_issue_checkpoint(sbi); 1711 + } 1713 1712 1714 1713 return err; 1715 1714 } ··· 2210 2205 .nr_free_secs = 1 }; 2211 2206 2212 2207 f2fs_down_write(&sbi->gc_lock); 2208 + stat_inc_gc_call_count(sbi, FOREGROUND); 2213 2209 err = f2fs_gc(sbi, &gc_control); 2214 2210 if (err == -ENODATA) { 2215 2211 err = 0; ··· 2236 2230 f2fs_down_write(&sbi->gc_lock); 2237 2231 cpc.reason = CP_PAUSE; 2238 2232 set_sbi_flag(sbi, SBI_CP_DISABLED); 2233 + stat_inc_cp_call_count(sbi, TOTAL_CALL); 2239 2234 err = f2fs_write_checkpoint(sbi, &cpc); 2240 2235 if (err) 2241 2236 goto out_unlock; ··· 4197 4190 sbi->aligned_blksize = true; 4198 4191 4199 4192 for (i = 0; i < max_devices; i++) { 4200 - 4201 - if (i > 0 && !RDEV(i).path[0]) 4193 + if (i == 0) 4194 + FDEV(0).bdev = sbi->sb->s_bdev; 4195 + else if (!RDEV(i).path[0]) 4202 4196 break; 4203 4197 4204 - if (max_devices == 1) { 4205 - /* Single zoned block device mount */ 4206 - FDEV(0).bdev = 4207 - blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev, mode, 4208 - sbi->sb, NULL); 4209 - } else { 4198 + if (max_devices > 1) { 4210 4199 /* Multi-device mount */ 4211 4200 memcpy(FDEV(i).path, RDEV(i).path, MAX_PATH_LEN); 4212 4201 FDEV(i).total_segments = ··· 4218 4215 FDEV(i).end_blk = FDEV(i).start_blk + 4219 4216 (FDEV(i).total_segments << 4220 4217 sbi->log_blocks_per_seg) - 1; 4218 + FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path, 4219 + mode, sbi->sb, NULL); 4221 4220 } 4222 - FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path, mode, 4223 - sbi->sb, NULL); 4224 4221 } 4225 4222 if (IS_ERR(FDEV(i).bdev)) 4226 4223 return PTR_ERR(FDEV(i).bdev); ··· 4873 4870 struct cp_control cpc = { 4874 4871 .reason = CP_UMOUNT, 4875 4872 }; 4873 + stat_inc_cp_call_count(sbi, TOTAL_CALL); 4876 4874 f2fs_write_checkpoint(sbi, &cpc); 4877 4875 } 4878 4876
+14 -4
fs/f2fs/sysfs.c
··· 356 356 if (!strcmp(a->attr.name, "revoked_atomic_block")) 357 357 return sysfs_emit(buf, "%llu\n", sbi->revoked_atomic_block); 358 358 359 + #ifdef CONFIG_F2FS_STAT_FS 360 + if (!strcmp(a->attr.name, "cp_foreground_calls")) 361 + return sysfs_emit(buf, "%d\n", 362 + atomic_read(&sbi->cp_call_count[TOTAL_CALL]) - 363 + atomic_read(&sbi->cp_call_count[BACKGROUND])); 364 + if (!strcmp(a->attr.name, "cp_background_calls")) 365 + return sysfs_emit(buf, "%d\n", 366 + atomic_read(&sbi->cp_call_count[BACKGROUND])); 367 + #endif 368 + 359 369 ui = (unsigned int *)(ptr + a->offset); 360 370 361 371 return sysfs_emit(buf, "%u\n", *ui); ··· 982 972 983 973 /* STAT_INFO ATTR */ 984 974 #ifdef CONFIG_F2FS_STAT_FS 985 - STAT_INFO_RO_ATTR(cp_foreground_calls, cp_count); 986 - STAT_INFO_RO_ATTR(cp_background_calls, bg_cp_count); 987 - STAT_INFO_RO_ATTR(gc_foreground_calls, call_count); 988 - STAT_INFO_RO_ATTR(gc_background_calls, bg_gc); 975 + STAT_INFO_RO_ATTR(cp_foreground_calls, cp_call_count[FOREGROUND]); 976 + STAT_INFO_RO_ATTR(cp_background_calls, cp_call_count[BACKGROUND]); 977 + STAT_INFO_RO_ATTR(gc_foreground_calls, gc_call_count[FOREGROUND]); 978 + STAT_INFO_RO_ATTR(gc_background_calls, gc_call_count[BACKGROUND]); 989 979 #endif 990 980 991 981 /* FAULT_INFO ATTR */
+3 -3
fs/f2fs/xattr.c
··· 757 757 if (index == F2FS_XATTR_INDEX_ENCRYPTION && 758 758 !strcmp(name, F2FS_XATTR_NAME_ENCRYPTION_CONTEXT)) 759 759 f2fs_set_encrypted_inode(inode); 760 - f2fs_mark_inode_dirty_sync(inode, true); 761 - if (!error && S_ISDIR(inode->i_mode)) 760 + if (S_ISDIR(inode->i_mode)) 762 761 set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_CP); 763 762 764 763 same: 765 764 if (is_inode_flag_set(inode, FI_ACL_MODE)) { 766 765 inode->i_mode = F2FS_I(inode)->i_acl_mode; 767 - inode_set_ctime_current(inode); 768 766 clear_inode_flag(inode, FI_ACL_MODE); 769 767 } 770 768 769 + inode_set_ctime_current(inode); 770 + f2fs_mark_inode_dirty_sync(inode, true); 771 771 exit: 772 772 kfree(base_addr); 773 773 return error;