sysfs.c (e291c116f60f3c1ca98090f0f8e7c77e658562fb) | sysfs.c (71644dff481180ba024ac4f5cb1f068756357adf) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * f2fs sysfs interface 4 * 5 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 6 * http://www.samsung.com/ 7 * Copyright (c) 2017 Chao Yu <chao@kernel.org> 8 */ --- 81 unchanged lines hidden (view full) --- 90 else if (struct_type == ATGC_INFO) 91 return (unsigned char *)&sbi->am; 92 return NULL; 93} 94 95static ssize_t dirty_segments_show(struct f2fs_attr *a, 96 struct f2fs_sb_info *sbi, char *buf) 97{ | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * f2fs sysfs interface 4 * 5 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 6 * http://www.samsung.com/ 7 * Copyright (c) 2017 Chao Yu <chao@kernel.org> 8 */ --- 81 unchanged lines hidden (view full) --- 90 else if (struct_type == ATGC_INFO) 91 return (unsigned char *)&sbi->am; 92 return NULL; 93} 94 95static ssize_t dirty_segments_show(struct f2fs_attr *a, 96 struct f2fs_sb_info *sbi, char *buf) 97{ |
98 return sprintf(buf, "%llu\n", | 98 return sysfs_emit(buf, "%llu\n", |
99 (unsigned long long)(dirty_segments(sbi))); 100} 101 102static ssize_t free_segments_show(struct f2fs_attr *a, 103 struct f2fs_sb_info *sbi, char *buf) 104{ | 99 (unsigned long long)(dirty_segments(sbi))); 100} 101 102static ssize_t free_segments_show(struct f2fs_attr *a, 103 struct f2fs_sb_info *sbi, char *buf) 104{ |
105 return sprintf(buf, "%llu\n", | 105 return sysfs_emit(buf, "%llu\n", |
106 (unsigned long long)(free_segments(sbi))); 107} 108 109static ssize_t ovp_segments_show(struct f2fs_attr *a, 110 struct f2fs_sb_info *sbi, char *buf) 111{ | 106 (unsigned long long)(free_segments(sbi))); 107} 108 109static ssize_t ovp_segments_show(struct f2fs_attr *a, 110 struct f2fs_sb_info *sbi, char *buf) 111{ |
112 return sprintf(buf, "%llu\n", | 112 return sysfs_emit(buf, "%llu\n", |
113 (unsigned long long)(overprovision_segments(sbi))); 114} 115 116static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a, 117 struct f2fs_sb_info *sbi, char *buf) 118{ | 113 (unsigned long long)(overprovision_segments(sbi))); 114} 115 116static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a, 117 struct f2fs_sb_info *sbi, char *buf) 118{ |
119 return sprintf(buf, "%llu\n", | 119 return sysfs_emit(buf, "%llu\n", |
120 (unsigned long long)(sbi->kbytes_written + 121 ((f2fs_get_sectors_written(sbi) - 122 sbi->sectors_written_start) >> 1))); 123} 124 125static ssize_t sb_status_show(struct f2fs_attr *a, 126 struct f2fs_sb_info *sbi, char *buf) 127{ | 120 (unsigned long long)(sbi->kbytes_written + 121 ((f2fs_get_sectors_written(sbi) - 122 sbi->sectors_written_start) >> 1))); 123} 124 125static ssize_t sb_status_show(struct f2fs_attr *a, 126 struct f2fs_sb_info *sbi, char *buf) 127{ |
128 return sprintf(buf, "%lx\n", sbi->s_flag); | 128 return sysfs_emit(buf, "%lx\n", sbi->s_flag); |
129} 130 131static ssize_t cp_status_show(struct f2fs_attr *a, 132 struct f2fs_sb_info *sbi, char *buf) 133{ | 129} 130 131static ssize_t cp_status_show(struct f2fs_attr *a, 132 struct f2fs_sb_info *sbi, char *buf) 133{ |
134 return sprintf(buf, "%x\n", le32_to_cpu(F2FS_CKPT(sbi)->ckpt_flags)); | 134 return sysfs_emit(buf, "%x\n", le32_to_cpu(F2FS_CKPT(sbi)->ckpt_flags)); |
135} 136 137static ssize_t pending_discard_show(struct f2fs_attr *a, 138 struct f2fs_sb_info *sbi, char *buf) 139{ 140 if (!SM_I(sbi)->dcc_info) 141 return -EINVAL; | 135} 136 137static ssize_t pending_discard_show(struct f2fs_attr *a, 138 struct f2fs_sb_info *sbi, char *buf) 139{ 140 if (!SM_I(sbi)->dcc_info) 141 return -EINVAL; |
142 return sprintf(buf, "%llu\n", (unsigned long long)atomic_read( | 142 return sysfs_emit(buf, "%llu\n", (unsigned long long)atomic_read( |
143 &SM_I(sbi)->dcc_info->discard_cmd_cnt)); 144} 145 | 143 &SM_I(sbi)->dcc_info->discard_cmd_cnt)); 144} 145 |
146static ssize_t gc_mode_show(struct f2fs_attr *a, 147 struct f2fs_sb_info *sbi, char *buf) 148{ 149 return sysfs_emit(buf, "%s\n", gc_mode_names[sbi->gc_mode]); 150} 151 |
|
146static ssize_t features_show(struct f2fs_attr *a, 147 struct f2fs_sb_info *sbi, char *buf) 148{ 149 int len = 0; 150 151 if (f2fs_sb_has_encrypt(sbi)) 152 len += scnprintf(buf, PAGE_SIZE - len, "%s", 153 "encryption"); --- 40 unchanged lines hidden (view full) --- 194 len ? ", " : "", "pin_file"); 195 len += scnprintf(buf + len, PAGE_SIZE - len, "\n"); 196 return len; 197} 198 199static ssize_t current_reserved_blocks_show(struct f2fs_attr *a, 200 struct f2fs_sb_info *sbi, char *buf) 201{ | 152static ssize_t features_show(struct f2fs_attr *a, 153 struct f2fs_sb_info *sbi, char *buf) 154{ 155 int len = 0; 156 157 if (f2fs_sb_has_encrypt(sbi)) 158 len += scnprintf(buf, PAGE_SIZE - len, "%s", 159 "encryption"); --- 40 unchanged lines hidden (view full) --- 200 len ? ", " : "", "pin_file"); 201 len += scnprintf(buf + len, PAGE_SIZE - len, "\n"); 202 return len; 203} 204 205static ssize_t current_reserved_blocks_show(struct f2fs_attr *a, 206 struct f2fs_sb_info *sbi, char *buf) 207{ |
202 return sprintf(buf, "%u\n", sbi->current_reserved_blocks); | 208 return sysfs_emit(buf, "%u\n", sbi->current_reserved_blocks); |
203} 204 205static ssize_t unusable_show(struct f2fs_attr *a, 206 struct f2fs_sb_info *sbi, char *buf) 207{ 208 block_t unusable; 209 210 if (test_opt(sbi, DISABLE_CHECKPOINT)) 211 unusable = sbi->unusable_block_count; 212 else 213 unusable = f2fs_get_unusable_blocks(sbi); | 209} 210 211static ssize_t unusable_show(struct f2fs_attr *a, 212 struct f2fs_sb_info *sbi, char *buf) 213{ 214 block_t unusable; 215 216 if (test_opt(sbi, DISABLE_CHECKPOINT)) 217 unusable = sbi->unusable_block_count; 218 else 219 unusable = f2fs_get_unusable_blocks(sbi); |
214 return sprintf(buf, "%llu\n", (unsigned long long)unusable); | 220 return sysfs_emit(buf, "%llu\n", (unsigned long long)unusable); |
215} 216 217static ssize_t encoding_show(struct f2fs_attr *a, 218 struct f2fs_sb_info *sbi, char *buf) 219{ 220#if IS_ENABLED(CONFIG_UNICODE) 221 struct super_block *sb = sbi->sb; 222 223 if (f2fs_sb_has_casefold(sbi)) 224 return sysfs_emit(buf, "UTF-8 (%d.%d.%d)\n", 225 (sb->s_encoding->version >> 16) & 0xff, 226 (sb->s_encoding->version >> 8) & 0xff, 227 sb->s_encoding->version & 0xff); 228#endif | 221} 222 223static ssize_t encoding_show(struct f2fs_attr *a, 224 struct f2fs_sb_info *sbi, char *buf) 225{ 226#if IS_ENABLED(CONFIG_UNICODE) 227 struct super_block *sb = sbi->sb; 228 229 if (f2fs_sb_has_casefold(sbi)) 230 return sysfs_emit(buf, "UTF-8 (%d.%d.%d)\n", 231 (sb->s_encoding->version >> 16) & 0xff, 232 (sb->s_encoding->version >> 8) & 0xff, 233 sb->s_encoding->version & 0xff); 234#endif |
229 return sprintf(buf, "(none)"); | 235 return sysfs_emit(buf, "(none)"); |
230} 231 232static ssize_t mounted_time_sec_show(struct f2fs_attr *a, 233 struct f2fs_sb_info *sbi, char *buf) 234{ | 236} 237 238static ssize_t mounted_time_sec_show(struct f2fs_attr *a, 239 struct f2fs_sb_info *sbi, char *buf) 240{ |
235 return sprintf(buf, "%llu", SIT_I(sbi)->mounted_time); | 241 return sysfs_emit(buf, "%llu", SIT_I(sbi)->mounted_time); |
236} 237 238#ifdef CONFIG_F2FS_STAT_FS 239static ssize_t moved_blocks_foreground_show(struct f2fs_attr *a, 240 struct f2fs_sb_info *sbi, char *buf) 241{ 242 struct f2fs_stat_info *si = F2FS_STAT(sbi); 243 | 242} 243 244#ifdef CONFIG_F2FS_STAT_FS 245static ssize_t moved_blocks_foreground_show(struct f2fs_attr *a, 246 struct f2fs_sb_info *sbi, char *buf) 247{ 248 struct f2fs_stat_info *si = F2FS_STAT(sbi); 249 |
244 return sprintf(buf, "%llu\n", | 250 return sysfs_emit(buf, "%llu\n", |
245 (unsigned long long)(si->tot_blks - 246 (si->bg_data_blks + si->bg_node_blks))); 247} 248 249static ssize_t moved_blocks_background_show(struct f2fs_attr *a, 250 struct f2fs_sb_info *sbi, char *buf) 251{ 252 struct f2fs_stat_info *si = F2FS_STAT(sbi); 253 | 251 (unsigned long long)(si->tot_blks - 252 (si->bg_data_blks + si->bg_node_blks))); 253} 254 255static ssize_t moved_blocks_background_show(struct f2fs_attr *a, 256 struct f2fs_sb_info *sbi, char *buf) 257{ 258 struct f2fs_stat_info *si = F2FS_STAT(sbi); 259 |
254 return sprintf(buf, "%llu\n", | 260 return sysfs_emit(buf, "%llu\n", |
255 (unsigned long long)(si->bg_data_blks + si->bg_node_blks)); 256} 257 258static ssize_t avg_vblocks_show(struct f2fs_attr *a, 259 struct f2fs_sb_info *sbi, char *buf) 260{ 261 struct f2fs_stat_info *si = F2FS_STAT(sbi); 262 263 si->dirty_count = dirty_segments(sbi); 264 f2fs_update_sit_info(sbi); | 261 (unsigned long long)(si->bg_data_blks + si->bg_node_blks)); 262} 263 264static ssize_t avg_vblocks_show(struct f2fs_attr *a, 265 struct f2fs_sb_info *sbi, char *buf) 266{ 267 struct f2fs_stat_info *si = F2FS_STAT(sbi); 268 269 si->dirty_count = dirty_segments(sbi); 270 f2fs_update_sit_info(sbi); |
265 return sprintf(buf, "%llu\n", (unsigned long long)(si->avg_vblocks)); | 271 return sysfs_emit(buf, "%llu\n", (unsigned long long)(si->avg_vblocks)); |
266} 267#endif 268 269static ssize_t main_blkaddr_show(struct f2fs_attr *a, 270 struct f2fs_sb_info *sbi, char *buf) 271{ 272 return sysfs_emit(buf, "%llu\n", 273 (unsigned long long)MAIN_BLKADDR(sbi)); --- 53 unchanged lines hidden (view full) --- 327 328 if (!strcmp(a->attr.name, "compr_saved_block")) 329 return sysfs_emit(buf, "%llu\n", sbi->compr_saved_block); 330 331 if (!strcmp(a->attr.name, "compr_new_inode")) 332 return sysfs_emit(buf, "%u\n", sbi->compr_new_inode); 333#endif 334 | 272} 273#endif 274 275static ssize_t main_blkaddr_show(struct f2fs_attr *a, 276 struct f2fs_sb_info *sbi, char *buf) 277{ 278 return sysfs_emit(buf, "%llu\n", 279 (unsigned long long)MAIN_BLKADDR(sbi)); --- 53 unchanged lines hidden (view full) --- 333 334 if (!strcmp(a->attr.name, "compr_saved_block")) 335 return sysfs_emit(buf, "%llu\n", sbi->compr_saved_block); 336 337 if (!strcmp(a->attr.name, "compr_new_inode")) 338 return sysfs_emit(buf, "%u\n", sbi->compr_new_inode); 339#endif 340 |
335 if (!strcmp(a->attr.name, "gc_urgent")) 336 return sysfs_emit(buf, "%s\n", 337 gc_mode_names[sbi->gc_mode]); 338 | |
339 if (!strcmp(a->attr.name, "gc_segment_mode")) | 341 if (!strcmp(a->attr.name, "gc_segment_mode")) |
340 return sysfs_emit(buf, "%s\n", 341 gc_mode_names[sbi->gc_segment_mode]); | 342 return sysfs_emit(buf, "%u\n", sbi->gc_segment_mode); |
342 343 if (!strcmp(a->attr.name, "gc_reclaimed_segments")) { 344 return sysfs_emit(buf, "%u\n", 345 sbi->gc_reclaimed_segs[sbi->gc_segment_mode]); 346 } 347 348 if (!strcmp(a->attr.name, "current_atomic_write")) { 349 s64 current_write = atomic64_read(&sbi->current_atomic_write); --- 7 unchanged lines hidden (view full) --- 357 if (!strcmp(a->attr.name, "committed_atomic_block")) 358 return sysfs_emit(buf, "%llu\n", sbi->committed_atomic_block); 359 360 if (!strcmp(a->attr.name, "revoked_atomic_block")) 361 return sysfs_emit(buf, "%llu\n", sbi->revoked_atomic_block); 362 363 ui = (unsigned int *)(ptr + a->offset); 364 | 343 344 if (!strcmp(a->attr.name, "gc_reclaimed_segments")) { 345 return sysfs_emit(buf, "%u\n", 346 sbi->gc_reclaimed_segs[sbi->gc_segment_mode]); 347 } 348 349 if (!strcmp(a->attr.name, "current_atomic_write")) { 350 s64 current_write = atomic64_read(&sbi->current_atomic_write); --- 7 unchanged lines hidden (view full) --- 358 if (!strcmp(a->attr.name, "committed_atomic_block")) 359 return sysfs_emit(buf, "%llu\n", sbi->committed_atomic_block); 360 361 if (!strcmp(a->attr.name, "revoked_atomic_block")) 362 return sysfs_emit(buf, "%llu\n", sbi->revoked_atomic_block); 363 364 ui = (unsigned int *)(ptr + a->offset); 365 |
365 return sprintf(buf, "%u\n", *ui); | 366 return sysfs_emit(buf, "%u\n", *ui); |
366} 367 368static ssize_t __sbi_store(struct f2fs_attr *a, 369 struct f2fs_sb_info *sbi, 370 const char *buf, size_t count) 371{ 372 unsigned char *ptr; 373 unsigned long t; --- 104 unchanged lines hidden (view full) --- 478 if (!f2fs_block_unit_discard(sbi)) 479 return -EINVAL; 480 if (t == *ui) 481 return count; 482 *ui = t; 483 return count; 484 } 485 | 367} 368 369static ssize_t __sbi_store(struct f2fs_attr *a, 370 struct f2fs_sb_info *sbi, 371 const char *buf, size_t count) 372{ 373 unsigned char *ptr; 374 unsigned long t; --- 104 unchanged lines hidden (view full) --- 479 if (!f2fs_block_unit_discard(sbi)) 480 return -EINVAL; 481 if (t == *ui) 482 return count; 483 *ui = t; 484 return count; 485 } 486 |
487 if (!strcmp(a->attr.name, "max_ordered_discard")) { 488 if (t == 0 || t > MAX_PLIST_NUM) 489 return -EINVAL; 490 if (!f2fs_block_unit_discard(sbi)) 491 return -EINVAL; 492 *ui = t; 493 return count; 494 } 495 496 if (!strcmp(a->attr.name, "discard_urgent_util")) { 497 if (t > 100) 498 return -EINVAL; 499 *ui = t; 500 return count; 501 } 502 |
|
486 if (!strcmp(a->attr.name, "migration_granularity")) { 487 if (t == 0 || t > sbi->segs_per_sec) 488 return -EINVAL; 489 } 490 | 503 if (!strcmp(a->attr.name, "migration_granularity")) { 504 if (t == 0 || t > sbi->segs_per_sec) 505 return -EINVAL; 506 } 507 |
491 if (!strcmp(a->attr.name, "trim_sections")) 492 return -EINVAL; 493 | |
494 if (!strcmp(a->attr.name, "gc_urgent")) { 495 if (t == 0) { 496 sbi->gc_mode = GC_NORMAL; 497 } else if (t == 1) { 498 sbi->gc_mode = GC_URGENT_HIGH; 499 if (sbi->gc_thread) { 500 sbi->gc_thread->gc_wake = 1; 501 wake_up_interruptible_all( --- 24 unchanged lines hidden (view full) --- 526 return -EINVAL; 527 sbi->gc_mode = GC_IDLE_AT; 528 } else { 529 sbi->gc_mode = GC_NORMAL; 530 } 531 return count; 532 } 533 | 508 if (!strcmp(a->attr.name, "gc_urgent")) { 509 if (t == 0) { 510 sbi->gc_mode = GC_NORMAL; 511 } else if (t == 1) { 512 sbi->gc_mode = GC_URGENT_HIGH; 513 if (sbi->gc_thread) { 514 sbi->gc_thread->gc_wake = 1; 515 wake_up_interruptible_all( --- 24 unchanged lines hidden (view full) --- 540 return -EINVAL; 541 sbi->gc_mode = GC_IDLE_AT; 542 } else { 543 sbi->gc_mode = GC_NORMAL; 544 } 545 return count; 546 } 547 |
534 if (!strcmp(a->attr.name, "gc_urgent_high_remaining")) { 535 spin_lock(&sbi->gc_urgent_high_lock); 536 sbi->gc_urgent_high_remaining = t; 537 spin_unlock(&sbi->gc_urgent_high_lock); | 548 if (!strcmp(a->attr.name, "gc_remaining_trials")) { 549 spin_lock(&sbi->gc_remaining_trials_lock); 550 sbi->gc_remaining_trials = t; 551 spin_unlock(&sbi->gc_remaining_trials_lock); |
538 539 return count; 540 } 541 542#ifdef CONFIG_F2FS_IOSTAT 543 if (!strcmp(a->attr.name, "iostat_enable")) { 544 sbi->iostat_enable = !!t; 545 if (!sbi->iostat_enable) --- 98 unchanged lines hidden (view full) --- 644 645 if (!strcmp(a->attr.name, "revoked_atomic_block")) { 646 if (t != 0) 647 return -EINVAL; 648 sbi->revoked_atomic_block = 0; 649 return count; 650 } 651 | 552 553 return count; 554 } 555 556#ifdef CONFIG_F2FS_IOSTAT 557 if (!strcmp(a->attr.name, "iostat_enable")) { 558 sbi->iostat_enable = !!t; 559 if (!sbi->iostat_enable) --- 98 unchanged lines hidden (view full) --- 658 659 if (!strcmp(a->attr.name, "revoked_atomic_block")) { 660 if (t != 0) 661 return -EINVAL; 662 sbi->revoked_atomic_block = 0; 663 return count; 664 } 665 |
666 if (!strcmp(a->attr.name, "readdir_ra")) { 667 sbi->readdir_ra = !!t; 668 return count; 669 } 670 671 if (!strcmp(a->attr.name, "hot_data_age_threshold")) { 672 if (t == 0 || t >= sbi->warm_data_age_threshold) 673 return -EINVAL; 674 if (t == *ui) 675 return count; 676 *ui = (unsigned int)t; 677 return count; 678 } 679 680 if (!strcmp(a->attr.name, "warm_data_age_threshold")) { 681 if (t == 0 || t <= sbi->hot_data_age_threshold) 682 return -EINVAL; 683 if (t == *ui) 684 return count; 685 *ui = (unsigned int)t; 686 return count; 687 } 688 |
|
652 *ui = (unsigned int)t; 653 654 return count; 655} 656 657static ssize_t f2fs_sbi_store(struct f2fs_attr *a, 658 struct f2fs_sb_info *sbi, 659 const char *buf, size_t count) --- 56 unchanged lines hidden (view full) --- 716 * sysfs entry rule where each entry should expose single value. 717 * This list covers old feature list provided by 2) and beyond. Therefore, 718 * please add new on-disk feature in this list only. 719 * - ref. F2FS_SB_FEATURE_RO_ATTR() 720 */ 721static ssize_t f2fs_feature_show(struct f2fs_attr *a, 722 struct f2fs_sb_info *sbi, char *buf) 723{ | 689 *ui = (unsigned int)t; 690 691 return count; 692} 693 694static ssize_t f2fs_sbi_store(struct f2fs_attr *a, 695 struct f2fs_sb_info *sbi, 696 const char *buf, size_t count) --- 56 unchanged lines hidden (view full) --- 753 * sysfs entry rule where each entry should expose single value. 754 * This list covers old feature list provided by 2) and beyond. Therefore, 755 * please add new on-disk feature in this list only. 756 * - ref. F2FS_SB_FEATURE_RO_ATTR() 757 */ 758static ssize_t f2fs_feature_show(struct f2fs_attr *a, 759 struct f2fs_sb_info *sbi, char *buf) 760{ |
724 return sprintf(buf, "supported\n"); | 761 return sysfs_emit(buf, "supported\n"); |
725} 726 727#define F2FS_FEATURE_RO_ATTR(_name) \ 728static struct f2fs_attr f2fs_attr_##_name = { \ 729 .attr = {.name = __stringify(_name), .mode = 0444 }, \ 730 .show = f2fs_feature_show, \ 731} 732 733static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a, 734 struct f2fs_sb_info *sbi, char *buf) 735{ 736 if (F2FS_HAS_FEATURE(sbi, a->id)) | 762} 763 764#define F2FS_FEATURE_RO_ATTR(_name) \ 765static struct f2fs_attr f2fs_attr_##_name = { \ 766 .attr = {.name = __stringify(_name), .mode = 0444 }, \ 767 .show = f2fs_feature_show, \ 768} 769 770static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a, 771 struct f2fs_sb_info *sbi, char *buf) 772{ 773 if (F2FS_HAS_FEATURE(sbi, a->id)) |
737 return sprintf(buf, "supported\n"); 738 return sprintf(buf, "unsupported\n"); | 774 return sysfs_emit(buf, "supported\n"); 775 return sysfs_emit(buf, "unsupported\n"); |
739} 740 741#define F2FS_SB_FEATURE_RO_ATTR(_name, _feat) \ 742static struct f2fs_attr f2fs_attr_sb_##_name = { \ 743 .attr = {.name = __stringify(_name), .mode = 0444 }, \ 744 .show = f2fs_sb_feature_show, \ 745 .id = F2FS_FEATURE_##_feat, \ 746} --- 36 unchanged lines hidden (view full) --- 783F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_idle, gc_mode); 784F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent, gc_mode); 785F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments); 786F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_small_discards, max_discards); 787F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_discard_request, max_discard_request); 788F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, min_discard_issue_time, min_discard_issue_time); 789F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, mid_discard_issue_time, mid_discard_issue_time); 790F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_discard_issue_time, max_discard_issue_time); | 776} 777 778#define F2FS_SB_FEATURE_RO_ATTR(_name, _feat) \ 779static struct f2fs_attr f2fs_attr_sb_##_name = { \ 780 .attr = {.name = __stringify(_name), .mode = 0444 }, \ 781 .show = f2fs_sb_feature_show, \ 782 .id = F2FS_FEATURE_##_feat, \ 783} --- 36 unchanged lines hidden (view full) --- 820F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_idle, gc_mode); 821F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent, gc_mode); 822F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments); 823F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_small_discards, max_discards); 824F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_discard_request, max_discard_request); 825F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, min_discard_issue_time, min_discard_issue_time); 826F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, mid_discard_issue_time, mid_discard_issue_time); 827F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_discard_issue_time, max_discard_issue_time); |
828F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, discard_urgent_util, discard_urgent_util); |
|
791F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, discard_granularity, discard_granularity); | 829F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, discard_granularity, discard_granularity); |
830F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_ordered_discard, max_ordered_discard); |
|
792F2FS_RW_ATTR(RESERVED_BLOCKS, f2fs_sb_info, reserved_blocks, reserved_blocks); | 831F2FS_RW_ATTR(RESERVED_BLOCKS, f2fs_sb_info, reserved_blocks, reserved_blocks); |
793F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, batched_trim_sections, trim_sections); | |
794F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy); 795F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util); 796F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_fsync_blocks, min_fsync_blocks); 797F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_seq_blocks, min_seq_blocks); 798F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_hot_blocks, min_hot_blocks); 799F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ssr_sections, min_ssr_sections); 800F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ram_thresh, ram_thresh); 801F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ra_nid_pages, ra_nid_pages); --- 18 unchanged lines hidden (view full) --- 820F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_pin_file_thresh, gc_pin_file_threshold); 821F2FS_RW_ATTR(F2FS_SBI, f2fs_super_block, extension_list, extension_list); 822#ifdef CONFIG_F2FS_FAULT_INJECTION 823F2FS_RW_ATTR(FAULT_INFO_RATE, f2fs_fault_info, inject_rate, inject_rate); 824F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type); 825#endif 826F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag); 827F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag); | 832F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy); 833F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util); 834F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_fsync_blocks, min_fsync_blocks); 835F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_seq_blocks, min_seq_blocks); 836F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_hot_blocks, min_hot_blocks); 837F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ssr_sections, min_ssr_sections); 838F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ram_thresh, ram_thresh); 839F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ra_nid_pages, ra_nid_pages); --- 18 unchanged lines hidden (view full) --- 858F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_pin_file_thresh, gc_pin_file_threshold); 859F2FS_RW_ATTR(F2FS_SBI, f2fs_super_block, extension_list, extension_list); 860#ifdef CONFIG_F2FS_FAULT_INJECTION 861F2FS_RW_ATTR(FAULT_INFO_RATE, f2fs_fault_info, inject_rate, inject_rate); 862F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type); 863#endif 864F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag); 865F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag); |
828F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_high_remaining, gc_urgent_high_remaining); | 866F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_remaining_trials, gc_remaining_trials); |
829F2FS_RW_ATTR(CPRC_INFO, ckpt_req_control, ckpt_thread_ioprio, ckpt_thread_ioprio); 830F2FS_GENERAL_RO_ATTR(dirty_segments); 831F2FS_GENERAL_RO_ATTR(free_segments); 832F2FS_GENERAL_RO_ATTR(ovp_segments); 833F2FS_GENERAL_RO_ATTR(lifetime_write_kbytes); 834F2FS_GENERAL_RO_ATTR(features); 835F2FS_GENERAL_RO_ATTR(current_reserved_blocks); 836F2FS_GENERAL_RO_ATTR(unusable); 837F2FS_GENERAL_RO_ATTR(encoding); 838F2FS_GENERAL_RO_ATTR(mounted_time_sec); 839F2FS_GENERAL_RO_ATTR(main_blkaddr); 840F2FS_GENERAL_RO_ATTR(pending_discard); | 867F2FS_RW_ATTR(CPRC_INFO, ckpt_req_control, ckpt_thread_ioprio, ckpt_thread_ioprio); 868F2FS_GENERAL_RO_ATTR(dirty_segments); 869F2FS_GENERAL_RO_ATTR(free_segments); 870F2FS_GENERAL_RO_ATTR(ovp_segments); 871F2FS_GENERAL_RO_ATTR(lifetime_write_kbytes); 872F2FS_GENERAL_RO_ATTR(features); 873F2FS_GENERAL_RO_ATTR(current_reserved_blocks); 874F2FS_GENERAL_RO_ATTR(unusable); 875F2FS_GENERAL_RO_ATTR(encoding); 876F2FS_GENERAL_RO_ATTR(mounted_time_sec); 877F2FS_GENERAL_RO_ATTR(main_blkaddr); 878F2FS_GENERAL_RO_ATTR(pending_discard); |
879F2FS_GENERAL_RO_ATTR(gc_mode); |
|
841#ifdef CONFIG_F2FS_STAT_FS 842F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count); 843F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count); 844F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, gc_foreground_calls, call_count); 845F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, gc_background_calls, bg_gc); 846F2FS_GENERAL_RO_ATTR(moved_blocks_background); 847F2FS_GENERAL_RO_ATTR(moved_blocks_foreground); 848F2FS_GENERAL_RO_ATTR(avg_vblocks); --- 48 unchanged lines hidden (view full) --- 897F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_fragment_hole, max_fragment_hole); 898 899/* For atomic write */ 900F2FS_RO_ATTR(F2FS_SBI, f2fs_sb_info, current_atomic_write, current_atomic_write); 901F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, peak_atomic_write, peak_atomic_write); 902F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, committed_atomic_block, committed_atomic_block); 903F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, revoked_atomic_block, revoked_atomic_block); 904 | 880#ifdef CONFIG_F2FS_STAT_FS 881F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count); 882F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count); 883F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, gc_foreground_calls, call_count); 884F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, gc_background_calls, bg_gc); 885F2FS_GENERAL_RO_ATTR(moved_blocks_background); 886F2FS_GENERAL_RO_ATTR(moved_blocks_foreground); 887F2FS_GENERAL_RO_ATTR(avg_vblocks); --- 48 unchanged lines hidden (view full) --- 936F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_fragment_hole, max_fragment_hole); 937 938/* For atomic write */ 939F2FS_RO_ATTR(F2FS_SBI, f2fs_sb_info, current_atomic_write, current_atomic_write); 940F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, peak_atomic_write, peak_atomic_write); 941F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, committed_atomic_block, committed_atomic_block); 942F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, revoked_atomic_block, revoked_atomic_block); 943 |
944/* For block age extent cache */ 945F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, hot_data_age_threshold, hot_data_age_threshold); 946F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, warm_data_age_threshold, warm_data_age_threshold); 947 |
|
905#define ATTR_LIST(name) (&f2fs_attr_##name.attr) 906static struct attribute *f2fs_attrs[] = { 907 ATTR_LIST(gc_urgent_sleep_time), 908 ATTR_LIST(gc_min_sleep_time), 909 ATTR_LIST(gc_max_sleep_time), 910 ATTR_LIST(gc_no_gc_sleep_time), 911 ATTR_LIST(gc_idle), 912 ATTR_LIST(gc_urgent), 913 ATTR_LIST(reclaim_segments), 914 ATTR_LIST(main_blkaddr), 915 ATTR_LIST(max_small_discards), 916 ATTR_LIST(max_discard_request), 917 ATTR_LIST(min_discard_issue_time), 918 ATTR_LIST(mid_discard_issue_time), 919 ATTR_LIST(max_discard_issue_time), | 948#define ATTR_LIST(name) (&f2fs_attr_##name.attr) 949static struct attribute *f2fs_attrs[] = { 950 ATTR_LIST(gc_urgent_sleep_time), 951 ATTR_LIST(gc_min_sleep_time), 952 ATTR_LIST(gc_max_sleep_time), 953 ATTR_LIST(gc_no_gc_sleep_time), 954 ATTR_LIST(gc_idle), 955 ATTR_LIST(gc_urgent), 956 ATTR_LIST(reclaim_segments), 957 ATTR_LIST(main_blkaddr), 958 ATTR_LIST(max_small_discards), 959 ATTR_LIST(max_discard_request), 960 ATTR_LIST(min_discard_issue_time), 961 ATTR_LIST(mid_discard_issue_time), 962 ATTR_LIST(max_discard_issue_time), |
963 ATTR_LIST(discard_urgent_util), |
|
920 ATTR_LIST(discard_granularity), | 964 ATTR_LIST(discard_granularity), |
965 ATTR_LIST(max_ordered_discard), |
|
921 ATTR_LIST(pending_discard), | 966 ATTR_LIST(pending_discard), |
922 ATTR_LIST(batched_trim_sections), | 967 ATTR_LIST(gc_mode), |
923 ATTR_LIST(ipu_policy), 924 ATTR_LIST(min_ipu_util), 925 ATTR_LIST(min_fsync_blocks), 926 ATTR_LIST(min_seq_blocks), 927 ATTR_LIST(min_hot_blocks), 928 ATTR_LIST(min_ssr_sections), 929 ATTR_LIST(max_victim_search), 930 ATTR_LIST(migration_granularity), --- 16 unchanged lines hidden (view full) --- 947 ATTR_LIST(gc_pin_file_thresh), 948 ATTR_LIST(extension_list), 949#ifdef CONFIG_F2FS_FAULT_INJECTION 950 ATTR_LIST(inject_rate), 951 ATTR_LIST(inject_type), 952#endif 953 ATTR_LIST(data_io_flag), 954 ATTR_LIST(node_io_flag), | 968 ATTR_LIST(ipu_policy), 969 ATTR_LIST(min_ipu_util), 970 ATTR_LIST(min_fsync_blocks), 971 ATTR_LIST(min_seq_blocks), 972 ATTR_LIST(min_hot_blocks), 973 ATTR_LIST(min_ssr_sections), 974 ATTR_LIST(max_victim_search), 975 ATTR_LIST(migration_granularity), --- 16 unchanged lines hidden (view full) --- 992 ATTR_LIST(gc_pin_file_thresh), 993 ATTR_LIST(extension_list), 994#ifdef CONFIG_F2FS_FAULT_INJECTION 995 ATTR_LIST(inject_rate), 996 ATTR_LIST(inject_type), 997#endif 998 ATTR_LIST(data_io_flag), 999 ATTR_LIST(node_io_flag), |
955 ATTR_LIST(gc_urgent_high_remaining), | 1000 ATTR_LIST(gc_remaining_trials), |
956 ATTR_LIST(ckpt_thread_ioprio), 957 ATTR_LIST(dirty_segments), 958 ATTR_LIST(free_segments), 959 ATTR_LIST(ovp_segments), 960 ATTR_LIST(unusable), 961 ATTR_LIST(lifetime_write_kbytes), 962 ATTR_LIST(features), 963 ATTR_LIST(reserved_blocks), --- 26 unchanged lines hidden (view full) --- 990 ATTR_LIST(gc_segment_mode), 991 ATTR_LIST(gc_reclaimed_segments), 992 ATTR_LIST(max_fragment_chunk), 993 ATTR_LIST(max_fragment_hole), 994 ATTR_LIST(current_atomic_write), 995 ATTR_LIST(peak_atomic_write), 996 ATTR_LIST(committed_atomic_block), 997 ATTR_LIST(revoked_atomic_block), | 1001 ATTR_LIST(ckpt_thread_ioprio), 1002 ATTR_LIST(dirty_segments), 1003 ATTR_LIST(free_segments), 1004 ATTR_LIST(ovp_segments), 1005 ATTR_LIST(unusable), 1006 ATTR_LIST(lifetime_write_kbytes), 1007 ATTR_LIST(features), 1008 ATTR_LIST(reserved_blocks), --- 26 unchanged lines hidden (view full) --- 1035 ATTR_LIST(gc_segment_mode), 1036 ATTR_LIST(gc_reclaimed_segments), 1037 ATTR_LIST(max_fragment_chunk), 1038 ATTR_LIST(max_fragment_hole), 1039 ATTR_LIST(current_atomic_write), 1040 ATTR_LIST(peak_atomic_write), 1041 ATTR_LIST(committed_atomic_block), 1042 ATTR_LIST(revoked_atomic_block), |
1043 ATTR_LIST(hot_data_age_threshold), 1044 ATTR_LIST(warm_data_age_threshold), |
|
998 NULL, 999}; 1000ATTRIBUTE_GROUPS(f2fs); 1001 1002static struct attribute *f2fs_feat_attrs[] = { 1003#ifdef CONFIG_FS_ENCRYPTION 1004 ATTR_LIST(encryption), 1005 ATTR_LIST(test_dummy_encryption_v2), --- 232 unchanged lines hidden (view full) --- 1238 if ((i % 10) == 9 || i == (MAIN_SECS(sbi) - 1)) 1239 seq_putc(seq, '\n'); 1240 else 1241 seq_putc(seq, ' '); 1242 } 1243 return 0; 1244} 1245 | 1045 NULL, 1046}; 1047ATTRIBUTE_GROUPS(f2fs); 1048 1049static struct attribute *f2fs_feat_attrs[] = { 1050#ifdef CONFIG_FS_ENCRYPTION 1051 ATTR_LIST(encryption), 1052 ATTR_LIST(test_dummy_encryption_v2), --- 232 unchanged lines hidden (view full) --- 1285 if ((i % 10) == 9 || i == (MAIN_SECS(sbi) - 1)) 1286 seq_putc(seq, '\n'); 1287 else 1288 seq_putc(seq, ' '); 1289 } 1290 return 0; 1291} 1292 |
1293static int __maybe_unused discard_plist_seq_show(struct seq_file *seq, 1294 void *offset) 1295{ 1296 struct super_block *sb = seq->private; 1297 struct f2fs_sb_info *sbi = F2FS_SB(sb); 1298 struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; 1299 int i, count; 1300 1301 seq_puts(seq, "Discard pend list(Show diacrd_cmd count on each entry, .:not exist):\n"); 1302 if (!f2fs_realtime_discard_enable(sbi)) 1303 return 0; 1304 1305 if (dcc) { 1306 mutex_lock(&dcc->cmd_lock); 1307 for (i = 0; i < MAX_PLIST_NUM; i++) { 1308 struct list_head *pend_list; 1309 struct discard_cmd *dc, *tmp; 1310 1311 if (i % 8 == 0) 1312 seq_printf(seq, " %-3d", i); 1313 count = 0; 1314 pend_list = &dcc->pend_list[i]; 1315 list_for_each_entry_safe(dc, tmp, pend_list, list) 1316 count++; 1317 if (count) 1318 seq_printf(seq, " %7d", count); 1319 else 1320 seq_puts(seq, " ."); 1321 if (i % 8 == 7) 1322 seq_putc(seq, '\n'); 1323 } 1324 seq_putc(seq, '\n'); 1325 mutex_unlock(&dcc->cmd_lock); 1326 } 1327 1328 return 0; 1329} 1330 |
|
1246int __init f2fs_init_sysfs(void) 1247{ 1248 int ret; 1249 1250 kobject_set_name(&f2fs_kset.kobj, "f2fs"); 1251 f2fs_kset.kobj.parent = fs_kobj; 1252 ret = kset_register(&f2fs_kset); 1253 if (ret) --- 54 unchanged lines hidden (view full) --- 1308 proc_create_single_data("segment_bits", 0444, sbi->s_proc, 1309 segment_bits_seq_show, sb); 1310#ifdef CONFIG_F2FS_IOSTAT 1311 proc_create_single_data("iostat_info", 0444, sbi->s_proc, 1312 iostat_info_seq_show, sb); 1313#endif 1314 proc_create_single_data("victim_bits", 0444, sbi->s_proc, 1315 victim_bits_seq_show, sb); | 1331int __init f2fs_init_sysfs(void) 1332{ 1333 int ret; 1334 1335 kobject_set_name(&f2fs_kset.kobj, "f2fs"); 1336 f2fs_kset.kobj.parent = fs_kobj; 1337 ret = kset_register(&f2fs_kset); 1338 if (ret) --- 54 unchanged lines hidden (view full) --- 1393 proc_create_single_data("segment_bits", 0444, sbi->s_proc, 1394 segment_bits_seq_show, sb); 1395#ifdef CONFIG_F2FS_IOSTAT 1396 proc_create_single_data("iostat_info", 0444, sbi->s_proc, 1397 iostat_info_seq_show, sb); 1398#endif 1399 proc_create_single_data("victim_bits", 0444, sbi->s_proc, 1400 victim_bits_seq_show, sb); |
1401 proc_create_single_data("discard_plist_info", 0444, sbi->s_proc, 1402 discard_plist_seq_show, sb); |
|
1316 } 1317 return 0; 1318put_feature_list_kobj: 1319 kobject_put(&sbi->s_feature_list_kobj); 1320 wait_for_completion(&sbi->s_feature_list_kobj_unregister); 1321put_stat_kobj: 1322 kobject_put(&sbi->s_stat_kobj); 1323 wait_for_completion(&sbi->s_stat_kobj_unregister); --- 7 unchanged lines hidden (view full) --- 1331{ 1332 if (sbi->s_proc) { 1333#ifdef CONFIG_F2FS_IOSTAT 1334 remove_proc_entry("iostat_info", sbi->s_proc); 1335#endif 1336 remove_proc_entry("segment_info", sbi->s_proc); 1337 remove_proc_entry("segment_bits", sbi->s_proc); 1338 remove_proc_entry("victim_bits", sbi->s_proc); | 1403 } 1404 return 0; 1405put_feature_list_kobj: 1406 kobject_put(&sbi->s_feature_list_kobj); 1407 wait_for_completion(&sbi->s_feature_list_kobj_unregister); 1408put_stat_kobj: 1409 kobject_put(&sbi->s_stat_kobj); 1410 wait_for_completion(&sbi->s_stat_kobj_unregister); --- 7 unchanged lines hidden (view full) --- 1418{ 1419 if (sbi->s_proc) { 1420#ifdef CONFIG_F2FS_IOSTAT 1421 remove_proc_entry("iostat_info", sbi->s_proc); 1422#endif 1423 remove_proc_entry("segment_info", sbi->s_proc); 1424 remove_proc_entry("segment_bits", sbi->s_proc); 1425 remove_proc_entry("victim_bits", sbi->s_proc); |
1426 remove_proc_entry("discard_plist_info", sbi->s_proc); |
|
1339 remove_proc_entry(sbi->sb->s_id, f2fs_proc_root); 1340 } 1341 1342 kobject_del(&sbi->s_stat_kobj); 1343 kobject_put(&sbi->s_stat_kobj); 1344 wait_for_completion(&sbi->s_stat_kobj_unregister); 1345 kobject_del(&sbi->s_feature_list_kobj); 1346 kobject_put(&sbi->s_feature_list_kobj); 1347 wait_for_completion(&sbi->s_feature_list_kobj_unregister); 1348 1349 kobject_del(&sbi->s_kobj); 1350 kobject_put(&sbi->s_kobj); 1351 wait_for_completion(&sbi->s_kobj_unregister); 1352} | 1427 remove_proc_entry(sbi->sb->s_id, f2fs_proc_root); 1428 } 1429 1430 kobject_del(&sbi->s_stat_kobj); 1431 kobject_put(&sbi->s_stat_kobj); 1432 wait_for_completion(&sbi->s_stat_kobj_unregister); 1433 kobject_del(&sbi->s_feature_list_kobj); 1434 kobject_put(&sbi->s_feature_list_kobj); 1435 wait_for_completion(&sbi->s_feature_list_kobj_unregister); 1436 1437 kobject_del(&sbi->s_kobj); 1438 kobject_put(&sbi->s_kobj); 1439 wait_for_completion(&sbi->s_kobj_unregister); 1440} |