sysfs.c (5298d4bfe80f6ae6ae2777bcd1357b0022d98573) sysfs.c (e4544b63a7ee49e7fbebf35ece0a6acd3b9617ae)
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 */

--- 104 unchanged lines hidden (view full) ---

113}
114
115static ssize_t sb_status_show(struct f2fs_attr *a,
116 struct f2fs_sb_info *sbi, char *buf)
117{
118 return sprintf(buf, "%lx\n", sbi->s_flag);
119}
120
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 */

--- 104 unchanged lines hidden (view full) ---

113}
114
115static ssize_t sb_status_show(struct f2fs_attr *a,
116 struct f2fs_sb_info *sbi, char *buf)
117{
118 return sprintf(buf, "%lx\n", sbi->s_flag);
119}
120
121static ssize_t pending_discard_show(struct f2fs_attr *a,
122 struct f2fs_sb_info *sbi, char *buf)
123{
124 if (!SM_I(sbi)->dcc_info)
125 return -EINVAL;
126 return sprintf(buf, "%llu\n", (unsigned long long)atomic_read(
127 &SM_I(sbi)->dcc_info->discard_cmd_cnt));
128}
129
121static ssize_t features_show(struct f2fs_attr *a,
122 struct f2fs_sb_info *sbi, char *buf)
123{
124 int len = 0;
125
126 if (f2fs_sb_has_encrypt(sbi))
127 len += scnprintf(buf, PAGE_SIZE - len, "%s",
128 "encryption");

--- 58 unchanged lines hidden (view full) ---

187 else
188 unusable = f2fs_get_unusable_blocks(sbi);
189 return sprintf(buf, "%llu\n", (unsigned long long)unusable);
190}
191
192static ssize_t encoding_show(struct f2fs_attr *a,
193 struct f2fs_sb_info *sbi, char *buf)
194{
130static ssize_t features_show(struct f2fs_attr *a,
131 struct f2fs_sb_info *sbi, char *buf)
132{
133 int len = 0;
134
135 if (f2fs_sb_has_encrypt(sbi))
136 len += scnprintf(buf, PAGE_SIZE - len, "%s",
137 "encryption");

--- 58 unchanged lines hidden (view full) ---

196 else
197 unusable = f2fs_get_unusable_blocks(sbi);
198 return sprintf(buf, "%llu\n", (unsigned long long)unusable);
199}
200
201static ssize_t encoding_show(struct f2fs_attr *a,
202 struct f2fs_sb_info *sbi, char *buf)
203{
195#if IS_ENABLED(CONFIG_UNICODE)
204#ifdef CONFIG_UNICODE
196 struct super_block *sb = sbi->sb;
197
198 if (f2fs_sb_has_casefold(sbi))
199 return sysfs_emit(buf, "UTF-8 (%d.%d.%d)\n",
200 (sb->s_encoding->version >> 16) & 0xff,
201 (sb->s_encoding->version >> 8) & 0xff,
202 sb->s_encoding->version & 0xff);
203#endif

--- 145 unchanged lines hidden (view full) ---

349 if (*name == '!') {
350 name++;
351 set = false;
352 }
353
354 if (!strlen(name) || strlen(name) >= F2FS_EXTENSION_LEN)
355 return -EINVAL;
356
205 struct super_block *sb = sbi->sb;
206
207 if (f2fs_sb_has_casefold(sbi))
208 return sysfs_emit(buf, "UTF-8 (%d.%d.%d)\n",
209 (sb->s_encoding->version >> 16) & 0xff,
210 (sb->s_encoding->version >> 8) & 0xff,
211 sb->s_encoding->version & 0xff);
212#endif

--- 145 unchanged lines hidden (view full) ---

358 if (*name == '!') {
359 name++;
360 set = false;
361 }
362
363 if (!strlen(name) || strlen(name) >= F2FS_EXTENSION_LEN)
364 return -EINVAL;
365
357 down_write(&sbi->sb_lock);
366 f2fs_down_write(&sbi->sb_lock);
358
359 ret = f2fs_update_extension_list(sbi, name, hot, set);
360 if (ret)
361 goto out;
362
363 ret = f2fs_commit_super(sbi, false);
364 if (ret)
365 f2fs_update_extension_list(sbi, name, hot, !set);
366out:
367
368 ret = f2fs_update_extension_list(sbi, name, hot, set);
369 if (ret)
370 goto out;
371
372 ret = f2fs_commit_super(sbi, false);
373 if (ret)
374 f2fs_update_extension_list(sbi, name, hot, !set);
375out:
367 up_write(&sbi->sb_lock);
376 f2fs_up_write(&sbi->sb_lock);
368 return ret ? ret : count;
369 }
370
371 if (!strcmp(a->attr.name, "ckpt_thread_ioprio")) {
372 const char *name = strim((char *)buf);
373 struct ckpt_req_control *cprc = &sbi->cprc_info;
374 int class;
375 long data;

--- 33 unchanged lines hidden (view full) ---

409 if (a->struct_type == FAULT_INFO_TYPE && t >= (1 << FAULT_MAX))
410 return -EINVAL;
411 if (a->struct_type == FAULT_INFO_RATE && t >= UINT_MAX)
412 return -EINVAL;
413#endif
414 if (a->struct_type == RESERVED_BLOCKS) {
415 spin_lock(&sbi->stat_lock);
416 if (t > (unsigned long)(sbi->user_block_count -
377 return ret ? ret : count;
378 }
379
380 if (!strcmp(a->attr.name, "ckpt_thread_ioprio")) {
381 const char *name = strim((char *)buf);
382 struct ckpt_req_control *cprc = &sbi->cprc_info;
383 int class;
384 long data;

--- 33 unchanged lines hidden (view full) ---

418 if (a->struct_type == FAULT_INFO_TYPE && t >= (1 << FAULT_MAX))
419 return -EINVAL;
420 if (a->struct_type == FAULT_INFO_RATE && t >= UINT_MAX)
421 return -EINVAL;
422#endif
423 if (a->struct_type == RESERVED_BLOCKS) {
424 spin_lock(&sbi->stat_lock);
425 if (t > (unsigned long)(sbi->user_block_count -
417 F2FS_OPTION(sbi).root_reserved_blocks)) {
426 F2FS_OPTION(sbi).root_reserved_blocks -
427 sbi->blocks_per_seg *
428 SM_I(sbi)->additional_reserved_segments)) {
418 spin_unlock(&sbi->stat_lock);
419 return -EINVAL;
420 }
421 *ui = t;
422 sbi->current_reserved_blocks = min(sbi->reserved_blocks,
423 sbi->user_block_count - valid_user_blocks(sbi));
424 spin_unlock(&sbi->stat_lock);
425 return count;

--- 46 unchanged lines hidden (view full) ---

472 return -EINVAL;
473 sbi->gc_mode = GC_AT;
474 } else {
475 sbi->gc_mode = GC_NORMAL;
476 }
477 return count;
478 }
479
429 spin_unlock(&sbi->stat_lock);
430 return -EINVAL;
431 }
432 *ui = t;
433 sbi->current_reserved_blocks = min(sbi->reserved_blocks,
434 sbi->user_block_count - valid_user_blocks(sbi));
435 spin_unlock(&sbi->stat_lock);
436 return count;

--- 46 unchanged lines hidden (view full) ---

483 return -EINVAL;
484 sbi->gc_mode = GC_AT;
485 } else {
486 sbi->gc_mode = GC_NORMAL;
487 }
488 return count;
489 }
490
491 if (!strcmp(a->attr.name, "gc_urgent_high_remaining")) {
492 spin_lock(&sbi->gc_urgent_high_lock);
493 sbi->gc_urgent_high_limited = t != 0;
494 sbi->gc_urgent_high_remaining = t;
495 spin_unlock(&sbi->gc_urgent_high_lock);
496
497 return count;
498 }
499
480#ifdef CONFIG_F2FS_IOSTAT
481 if (!strcmp(a->attr.name, "iostat_enable")) {
482 sbi->iostat_enable = !!t;
483 if (!sbi->iostat_enable)
484 f2fs_reset_iostat(sbi);
485 return count;
486 }
487

--- 239 unchanged lines hidden (view full) ---

727F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_pin_file_thresh, gc_pin_file_threshold);
728F2FS_RW_ATTR(F2FS_SBI, f2fs_super_block, extension_list, extension_list);
729#ifdef CONFIG_F2FS_FAULT_INJECTION
730F2FS_RW_ATTR(FAULT_INFO_RATE, f2fs_fault_info, inject_rate, inject_rate);
731F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type);
732#endif
733F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag);
734F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag);
500#ifdef CONFIG_F2FS_IOSTAT
501 if (!strcmp(a->attr.name, "iostat_enable")) {
502 sbi->iostat_enable = !!t;
503 if (!sbi->iostat_enable)
504 f2fs_reset_iostat(sbi);
505 return count;
506 }
507

--- 239 unchanged lines hidden (view full) ---

747F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_pin_file_thresh, gc_pin_file_threshold);
748F2FS_RW_ATTR(F2FS_SBI, f2fs_super_block, extension_list, extension_list);
749#ifdef CONFIG_F2FS_FAULT_INJECTION
750F2FS_RW_ATTR(FAULT_INFO_RATE, f2fs_fault_info, inject_rate, inject_rate);
751F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type);
752#endif
753F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag);
754F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag);
755F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_high_remaining, gc_urgent_high_remaining);
735F2FS_RW_ATTR(CPRC_INFO, ckpt_req_control, ckpt_thread_ioprio, ckpt_thread_ioprio);
736F2FS_GENERAL_RO_ATTR(dirty_segments);
737F2FS_GENERAL_RO_ATTR(free_segments);
738F2FS_GENERAL_RO_ATTR(ovp_segments);
739F2FS_GENERAL_RO_ATTR(lifetime_write_kbytes);
740F2FS_GENERAL_RO_ATTR(features);
741F2FS_GENERAL_RO_ATTR(current_reserved_blocks);
742F2FS_GENERAL_RO_ATTR(unusable);
743F2FS_GENERAL_RO_ATTR(encoding);
744F2FS_GENERAL_RO_ATTR(mounted_time_sec);
745F2FS_GENERAL_RO_ATTR(main_blkaddr);
756F2FS_RW_ATTR(CPRC_INFO, ckpt_req_control, ckpt_thread_ioprio, ckpt_thread_ioprio);
757F2FS_GENERAL_RO_ATTR(dirty_segments);
758F2FS_GENERAL_RO_ATTR(free_segments);
759F2FS_GENERAL_RO_ATTR(ovp_segments);
760F2FS_GENERAL_RO_ATTR(lifetime_write_kbytes);
761F2FS_GENERAL_RO_ATTR(features);
762F2FS_GENERAL_RO_ATTR(current_reserved_blocks);
763F2FS_GENERAL_RO_ATTR(unusable);
764F2FS_GENERAL_RO_ATTR(encoding);
765F2FS_GENERAL_RO_ATTR(mounted_time_sec);
766F2FS_GENERAL_RO_ATTR(main_blkaddr);
767F2FS_GENERAL_RO_ATTR(pending_discard);
746#ifdef CONFIG_F2FS_STAT_FS
747F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count);
748F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count);
749F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, gc_foreground_calls, call_count);
750F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, gc_background_calls, bg_gc);
751F2FS_GENERAL_RO_ATTR(moved_blocks_background);
752F2FS_GENERAL_RO_ATTR(moved_blocks_foreground);
753F2FS_GENERAL_RO_ATTR(avg_vblocks);
754#endif
755
756#ifdef CONFIG_FS_ENCRYPTION
757F2FS_FEATURE_RO_ATTR(encryption);
758F2FS_FEATURE_RO_ATTR(test_dummy_encryption_v2);
768#ifdef CONFIG_F2FS_STAT_FS
769F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count);
770F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count);
771F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, gc_foreground_calls, call_count);
772F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, gc_background_calls, bg_gc);
773F2FS_GENERAL_RO_ATTR(moved_blocks_background);
774F2FS_GENERAL_RO_ATTR(moved_blocks_foreground);
775F2FS_GENERAL_RO_ATTR(avg_vblocks);
776#endif
777
778#ifdef CONFIG_FS_ENCRYPTION
779F2FS_FEATURE_RO_ATTR(encryption);
780F2FS_FEATURE_RO_ATTR(test_dummy_encryption_v2);
759#if IS_ENABLED(CONFIG_UNICODE)
781#ifdef CONFIG_UNICODE
760F2FS_FEATURE_RO_ATTR(encrypted_casefold);
761#endif
762#endif /* CONFIG_FS_ENCRYPTION */
763#ifdef CONFIG_BLK_DEV_ZONED
764F2FS_FEATURE_RO_ATTR(block_zoned);
765#endif
766F2FS_FEATURE_RO_ATTR(atomic_write);
767F2FS_FEATURE_RO_ATTR(extra_attr);
768F2FS_FEATURE_RO_ATTR(project_quota);
769F2FS_FEATURE_RO_ATTR(inode_checksum);
770F2FS_FEATURE_RO_ATTR(flexible_inline_xattr);
771F2FS_FEATURE_RO_ATTR(quota_ino);
772F2FS_FEATURE_RO_ATTR(inode_crtime);
773F2FS_FEATURE_RO_ATTR(lost_found);
774#ifdef CONFIG_FS_VERITY
775F2FS_FEATURE_RO_ATTR(verity);
776#endif
777F2FS_FEATURE_RO_ATTR(sb_checksum);
782F2FS_FEATURE_RO_ATTR(encrypted_casefold);
783#endif
784#endif /* CONFIG_FS_ENCRYPTION */
785#ifdef CONFIG_BLK_DEV_ZONED
786F2FS_FEATURE_RO_ATTR(block_zoned);
787#endif
788F2FS_FEATURE_RO_ATTR(atomic_write);
789F2FS_FEATURE_RO_ATTR(extra_attr);
790F2FS_FEATURE_RO_ATTR(project_quota);
791F2FS_FEATURE_RO_ATTR(inode_checksum);
792F2FS_FEATURE_RO_ATTR(flexible_inline_xattr);
793F2FS_FEATURE_RO_ATTR(quota_ino);
794F2FS_FEATURE_RO_ATTR(inode_crtime);
795F2FS_FEATURE_RO_ATTR(lost_found);
796#ifdef CONFIG_FS_VERITY
797F2FS_FEATURE_RO_ATTR(verity);
798#endif
799F2FS_FEATURE_RO_ATTR(sb_checksum);
778#if IS_ENABLED(CONFIG_UNICODE)
800#ifdef CONFIG_UNICODE
779F2FS_FEATURE_RO_ATTR(casefold);
780#endif
781F2FS_FEATURE_RO_ATTR(readonly);
782#ifdef CONFIG_F2FS_FS_COMPRESSION
783F2FS_FEATURE_RO_ATTR(compression);
784F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_written_block, compr_written_block);
785F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_saved_block, compr_saved_block);
786F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_new_inode, compr_new_inode);

--- 19 unchanged lines hidden (view full) ---

806 ATTR_LIST(gc_max_sleep_time),
807 ATTR_LIST(gc_no_gc_sleep_time),
808 ATTR_LIST(gc_idle),
809 ATTR_LIST(gc_urgent),
810 ATTR_LIST(reclaim_segments),
811 ATTR_LIST(main_blkaddr),
812 ATTR_LIST(max_small_discards),
813 ATTR_LIST(discard_granularity),
801F2FS_FEATURE_RO_ATTR(casefold);
802#endif
803F2FS_FEATURE_RO_ATTR(readonly);
804#ifdef CONFIG_F2FS_FS_COMPRESSION
805F2FS_FEATURE_RO_ATTR(compression);
806F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_written_block, compr_written_block);
807F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_saved_block, compr_saved_block);
808F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_new_inode, compr_new_inode);

--- 19 unchanged lines hidden (view full) ---

828 ATTR_LIST(gc_max_sleep_time),
829 ATTR_LIST(gc_no_gc_sleep_time),
830 ATTR_LIST(gc_idle),
831 ATTR_LIST(gc_urgent),
832 ATTR_LIST(reclaim_segments),
833 ATTR_LIST(main_blkaddr),
834 ATTR_LIST(max_small_discards),
835 ATTR_LIST(discard_granularity),
836 ATTR_LIST(pending_discard),
814 ATTR_LIST(batched_trim_sections),
815 ATTR_LIST(ipu_policy),
816 ATTR_LIST(min_ipu_util),
817 ATTR_LIST(min_fsync_blocks),
818 ATTR_LIST(min_seq_blocks),
819 ATTR_LIST(min_hot_blocks),
820 ATTR_LIST(min_ssr_sections),
821 ATTR_LIST(max_victim_search),

--- 16 unchanged lines hidden (view full) ---

838 ATTR_LIST(gc_pin_file_thresh),
839 ATTR_LIST(extension_list),
840#ifdef CONFIG_F2FS_FAULT_INJECTION
841 ATTR_LIST(inject_rate),
842 ATTR_LIST(inject_type),
843#endif
844 ATTR_LIST(data_io_flag),
845 ATTR_LIST(node_io_flag),
837 ATTR_LIST(batched_trim_sections),
838 ATTR_LIST(ipu_policy),
839 ATTR_LIST(min_ipu_util),
840 ATTR_LIST(min_fsync_blocks),
841 ATTR_LIST(min_seq_blocks),
842 ATTR_LIST(min_hot_blocks),
843 ATTR_LIST(min_ssr_sections),
844 ATTR_LIST(max_victim_search),

--- 16 unchanged lines hidden (view full) ---

861 ATTR_LIST(gc_pin_file_thresh),
862 ATTR_LIST(extension_list),
863#ifdef CONFIG_F2FS_FAULT_INJECTION
864 ATTR_LIST(inject_rate),
865 ATTR_LIST(inject_type),
866#endif
867 ATTR_LIST(data_io_flag),
868 ATTR_LIST(node_io_flag),
869 ATTR_LIST(gc_urgent_high_remaining),
846 ATTR_LIST(ckpt_thread_ioprio),
847 ATTR_LIST(dirty_segments),
848 ATTR_LIST(free_segments),
849 ATTR_LIST(ovp_segments),
850 ATTR_LIST(unusable),
851 ATTR_LIST(lifetime_write_kbytes),
852 ATTR_LIST(features),
853 ATTR_LIST(reserved_blocks),

--- 27 unchanged lines hidden (view full) ---

881 NULL,
882};
883ATTRIBUTE_GROUPS(f2fs);
884
885static struct attribute *f2fs_feat_attrs[] = {
886#ifdef CONFIG_FS_ENCRYPTION
887 ATTR_LIST(encryption),
888 ATTR_LIST(test_dummy_encryption_v2),
870 ATTR_LIST(ckpt_thread_ioprio),
871 ATTR_LIST(dirty_segments),
872 ATTR_LIST(free_segments),
873 ATTR_LIST(ovp_segments),
874 ATTR_LIST(unusable),
875 ATTR_LIST(lifetime_write_kbytes),
876 ATTR_LIST(features),
877 ATTR_LIST(reserved_blocks),

--- 27 unchanged lines hidden (view full) ---

905 NULL,
906};
907ATTRIBUTE_GROUPS(f2fs);
908
909static struct attribute *f2fs_feat_attrs[] = {
910#ifdef CONFIG_FS_ENCRYPTION
911 ATTR_LIST(encryption),
912 ATTR_LIST(test_dummy_encryption_v2),
889#if IS_ENABLED(CONFIG_UNICODE)
913#ifdef CONFIG_UNICODE
890 ATTR_LIST(encrypted_casefold),
891#endif
892#endif /* CONFIG_FS_ENCRYPTION */
893#ifdef CONFIG_BLK_DEV_ZONED
894 ATTR_LIST(block_zoned),
895#endif
896 ATTR_LIST(atomic_write),
897 ATTR_LIST(extra_attr),
898 ATTR_LIST(project_quota),
899 ATTR_LIST(inode_checksum),
900 ATTR_LIST(flexible_inline_xattr),
901 ATTR_LIST(quota_ino),
902 ATTR_LIST(inode_crtime),
903 ATTR_LIST(lost_found),
904#ifdef CONFIG_FS_VERITY
905 ATTR_LIST(verity),
906#endif
907 ATTR_LIST(sb_checksum),
914 ATTR_LIST(encrypted_casefold),
915#endif
916#endif /* CONFIG_FS_ENCRYPTION */
917#ifdef CONFIG_BLK_DEV_ZONED
918 ATTR_LIST(block_zoned),
919#endif
920 ATTR_LIST(atomic_write),
921 ATTR_LIST(extra_attr),
922 ATTR_LIST(project_quota),
923 ATTR_LIST(inode_checksum),
924 ATTR_LIST(flexible_inline_xattr),
925 ATTR_LIST(quota_ino),
926 ATTR_LIST(inode_crtime),
927 ATTR_LIST(lost_found),
928#ifdef CONFIG_FS_VERITY
929 ATTR_LIST(verity),
930#endif
931 ATTR_LIST(sb_checksum),
908#if IS_ENABLED(CONFIG_UNICODE)
932#ifdef CONFIG_UNICODE
909 ATTR_LIST(casefold),
910#endif
911 ATTR_LIST(readonly),
912#ifdef CONFIG_F2FS_FS_COMPRESSION
913 ATTR_LIST(compression),
914#endif
915 ATTR_LIST(pin_file),
916 NULL,

--- 317 unchanged lines hidden ---
933 ATTR_LIST(casefold),
934#endif
935 ATTR_LIST(readonly),
936#ifdef CONFIG_F2FS_FS_COMPRESSION
937 ATTR_LIST(compression),
938#endif
939 ATTR_LIST(pin_file),
940 NULL,

--- 317 unchanged lines hidden ---