@@ -842,68 +842,160 @@ static struct f2fs_attr f2fs_attr_##_name = { \
842
842
#define F2FS_GENERAL_RO_ATTR (name ) \
843
843
static struct f2fs_attr f2fs_attr_##name = __ATTR(name, 0444, name##_show, NULL)
844
844
845
- #define F2FS_STAT_ATTR (_struct_type , _struct_name , _name , _elname ) \
846
- static struct f2fs_attr f2fs_attr_##_name = { \
847
- .attr = {.name = __stringify(_name), .mode = 0444 }, \
848
- .show = f2fs_sbi_show, \
849
- .struct_type = _struct_type, \
850
- .offset = offsetof(struct _struct_name, _elname), \
851
- }
845
+ #ifdef CONFIG_F2FS_STAT_FS
846
+ #define STAT_INFO_RO_ATTR (name , elname ) \
847
+ F2FS_RO_ATTR(STAT_INFO, f2fs_stat_info, name, elname)
848
+ #endif
852
849
853
- F2FS_RW_ATTR (GC_THREAD , f2fs_gc_kthread , gc_urgent_sleep_time ,
854
- urgent_sleep_time );
855
- F2FS_RW_ATTR (GC_THREAD , f2fs_gc_kthread , gc_min_sleep_time , min_sleep_time );
856
- F2FS_RW_ATTR (GC_THREAD , f2fs_gc_kthread , gc_max_sleep_time , max_sleep_time );
857
- F2FS_RW_ATTR (GC_THREAD , f2fs_gc_kthread , gc_no_gc_sleep_time , no_gc_sleep_time );
858
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , gc_idle , gc_mode );
859
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , gc_urgent , gc_mode );
860
- F2FS_RW_ATTR (SM_INFO , f2fs_sm_info , reclaim_segments , rec_prefree_segments );
861
- F2FS_RW_ATTR (DCC_INFO , discard_cmd_control , max_small_discards , max_discards );
862
- F2FS_RW_ATTR (DCC_INFO , discard_cmd_control , max_discard_request , max_discard_request );
863
- F2FS_RW_ATTR (DCC_INFO , discard_cmd_control , min_discard_issue_time , min_discard_issue_time );
864
- F2FS_RW_ATTR (DCC_INFO , discard_cmd_control , mid_discard_issue_time , mid_discard_issue_time );
865
- F2FS_RW_ATTR (DCC_INFO , discard_cmd_control , max_discard_issue_time , max_discard_issue_time );
866
- F2FS_RW_ATTR (DCC_INFO , discard_cmd_control , discard_io_aware_gran , discard_io_aware_gran );
867
- F2FS_RW_ATTR (DCC_INFO , discard_cmd_control , discard_urgent_util , discard_urgent_util );
868
- F2FS_RW_ATTR (DCC_INFO , discard_cmd_control , discard_granularity , discard_granularity );
869
- F2FS_RW_ATTR (DCC_INFO , discard_cmd_control , max_ordered_discard , max_ordered_discard );
870
- F2FS_RW_ATTR (RESERVED_BLOCKS , f2fs_sb_info , reserved_blocks , reserved_blocks );
871
- F2FS_RW_ATTR (SM_INFO , f2fs_sm_info , ipu_policy , ipu_policy );
872
- F2FS_RW_ATTR (SM_INFO , f2fs_sm_info , min_ipu_util , min_ipu_util );
873
- F2FS_RW_ATTR (SM_INFO , f2fs_sm_info , min_fsync_blocks , min_fsync_blocks );
874
- F2FS_RW_ATTR (SM_INFO , f2fs_sm_info , min_seq_blocks , min_seq_blocks );
875
- F2FS_RW_ATTR (SM_INFO , f2fs_sm_info , min_hot_blocks , min_hot_blocks );
876
- F2FS_RW_ATTR (SM_INFO , f2fs_sm_info , min_ssr_sections , min_ssr_sections );
877
- F2FS_RW_ATTR (NM_INFO , f2fs_nm_info , ram_thresh , ram_thresh );
878
- F2FS_RW_ATTR (NM_INFO , f2fs_nm_info , ra_nid_pages , ra_nid_pages );
879
- F2FS_RW_ATTR (NM_INFO , f2fs_nm_info , dirty_nats_ratio , dirty_nats_ratio );
880
- F2FS_RW_ATTR (NM_INFO , f2fs_nm_info , max_roll_forward_node_blocks , max_rf_node_blocks );
881
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , max_victim_search , max_victim_search );
882
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , migration_granularity , migration_granularity );
883
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , dir_level , dir_level );
884
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , cp_interval , interval_time [CP_TIME ]);
885
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , idle_interval , interval_time [REQ_TIME ]);
886
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , discard_idle_interval ,
887
- interval_time [DISCARD_TIME ]);
888
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , gc_idle_interval , interval_time [GC_TIME ]);
889
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info ,
890
- umount_discard_timeout , interval_time [UMOUNT_DISCARD_TIMEOUT ]);
891
- #ifdef CONFIG_F2FS_IOSTAT
892
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , iostat_enable , iostat_enable );
893
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , iostat_period_ms , iostat_period_ms );
850
+ #define GC_THREAD_RW_ATTR (name , elname ) \
851
+ F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, name, elname)
852
+
853
+ #define SM_INFO_RW_ATTR (name , elname ) \
854
+ F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, name, elname)
855
+
856
+ #define SM_INFO_GENERAL_RW_ATTR (elname ) \
857
+ SM_INFO_RW_ATTR(elname, elname)
858
+
859
+ #define DCC_INFO_RW_ATTR (name , elname ) \
860
+ F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, name, elname)
861
+
862
+ #define DCC_INFO_GENERAL_RW_ATTR (elname ) \
863
+ DCC_INFO_RW_ATTR(elname, elname)
864
+
865
+ #define NM_INFO_RW_ATTR (name , elname ) \
866
+ F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, name, elname)
867
+
868
+ #define NM_INFO_GENERAL_RW_ATTR (elname ) \
869
+ NM_INFO_RW_ATTR(elname, elname)
870
+
871
+ #define F2FS_SBI_RW_ATTR (name , elname ) \
872
+ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, name, elname)
873
+
874
+ #define F2FS_SBI_GENERAL_RW_ATTR (elname ) \
875
+ F2FS_SBI_RW_ATTR(elname, elname)
876
+
877
+ #define F2FS_SBI_GENERAL_RO_ATTR (elname ) \
878
+ F2FS_RO_ATTR(F2FS_SBI, f2fs_sb_info, elname, elname)
879
+
880
+ #ifdef CONFIG_F2FS_FAULT_INJECTION
881
+ #define FAULT_INFO_GENERAL_RW_ATTR (type , elname ) \
882
+ F2FS_RW_ATTR(type, f2fs_fault_info, elname, elname)
894
883
#endif
895
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , readdir_ra , readdir_ra );
896
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , max_io_bytes , max_io_bytes );
897
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , gc_pin_file_thresh , gc_pin_file_threshold );
884
+
885
+ #define RESERVED_BLOCKS_GENERAL_RW_ATTR (elname ) \
886
+ F2FS_RW_ATTR(RESERVED_BLOCKS, f2fs_sb_info, elname, elname)
887
+
888
+ #define CPRC_INFO_GENERAL_RW_ATTR (elname ) \
889
+ F2FS_RW_ATTR(CPRC_INFO, ckpt_req_control, elname, elname)
890
+
891
+ #define ATGC_INFO_RW_ATTR (name , elname ) \
892
+ F2FS_RW_ATTR(ATGC_INFO, atgc_management, name, elname)
893
+
894
+ /* GC_THREAD ATTR */
895
+ GC_THREAD_RW_ATTR (gc_urgent_sleep_time , urgent_sleep_time );
896
+ GC_THREAD_RW_ATTR (gc_min_sleep_time , min_sleep_time );
897
+ GC_THREAD_RW_ATTR (gc_max_sleep_time , max_sleep_time );
898
+ GC_THREAD_RW_ATTR (gc_no_gc_sleep_time , no_gc_sleep_time );
899
+
900
+ /* SM_INFO ATTR */
901
+ SM_INFO_RW_ATTR (reclaim_segments , rec_prefree_segments );
902
+ SM_INFO_GENERAL_RW_ATTR (ipu_policy );
903
+ SM_INFO_GENERAL_RW_ATTR (min_ipu_util );
904
+ SM_INFO_GENERAL_RW_ATTR (min_fsync_blocks );
905
+ SM_INFO_GENERAL_RW_ATTR (min_seq_blocks );
906
+ SM_INFO_GENERAL_RW_ATTR (min_hot_blocks );
907
+ SM_INFO_GENERAL_RW_ATTR (min_ssr_sections );
908
+
909
+ /* DCC_INFO ATTR */
910
+ DCC_INFO_RW_ATTR (max_small_discards , max_discards );
911
+ DCC_INFO_GENERAL_RW_ATTR (max_discard_request );
912
+ DCC_INFO_GENERAL_RW_ATTR (min_discard_issue_time );
913
+ DCC_INFO_GENERAL_RW_ATTR (mid_discard_issue_time );
914
+ DCC_INFO_GENERAL_RW_ATTR (max_discard_issue_time );
915
+ DCC_INFO_GENERAL_RW_ATTR (discard_io_aware_gran );
916
+ DCC_INFO_GENERAL_RW_ATTR (discard_urgent_util );
917
+ DCC_INFO_GENERAL_RW_ATTR (discard_granularity );
918
+ DCC_INFO_GENERAL_RW_ATTR (max_ordered_discard );
919
+
920
+ /* NM_INFO ATTR */
921
+ NM_INFO_RW_ATTR (max_roll_forward_node_blocks , max_rf_node_blocks );
922
+ NM_INFO_GENERAL_RW_ATTR (ram_thresh );
923
+ NM_INFO_GENERAL_RW_ATTR (ra_nid_pages );
924
+ NM_INFO_GENERAL_RW_ATTR (dirty_nats_ratio );
925
+
926
+ /* F2FS_SBI ATTR */
898
927
F2FS_RW_ATTR (F2FS_SBI , f2fs_super_block , extension_list , extension_list );
928
+ F2FS_SBI_RW_ATTR (gc_idle , gc_mode );
929
+ F2FS_SBI_RW_ATTR (gc_urgent , gc_mode );
930
+ F2FS_SBI_RW_ATTR (cp_interval , interval_time [CP_TIME ]);
931
+ F2FS_SBI_RW_ATTR (idle_interval , interval_time [REQ_TIME ]);
932
+ F2FS_SBI_RW_ATTR (discard_idle_interval , interval_time [DISCARD_TIME ]);
933
+ F2FS_SBI_RW_ATTR (gc_idle_interval , interval_time [GC_TIME ]);
934
+ F2FS_SBI_RW_ATTR (umount_discard_timeout , interval_time [UMOUNT_DISCARD_TIMEOUT ]);
935
+ F2FS_SBI_RW_ATTR (gc_pin_file_thresh , gc_pin_file_threshold );
936
+ F2FS_SBI_RW_ATTR (gc_reclaimed_segments , gc_reclaimed_segs );
937
+ F2FS_SBI_GENERAL_RW_ATTR (max_victim_search );
938
+ F2FS_SBI_GENERAL_RW_ATTR (migration_granularity );
939
+ F2FS_SBI_GENERAL_RW_ATTR (dir_level );
940
+ #ifdef CONFIG_F2FS_IOSTAT
941
+ F2FS_SBI_GENERAL_RW_ATTR (iostat_enable );
942
+ F2FS_SBI_GENERAL_RW_ATTR (iostat_period_ms );
943
+ #endif
944
+ F2FS_SBI_GENERAL_RW_ATTR (readdir_ra );
945
+ F2FS_SBI_GENERAL_RW_ATTR (max_io_bytes );
946
+ F2FS_SBI_GENERAL_RW_ATTR (data_io_flag );
947
+ F2FS_SBI_GENERAL_RW_ATTR (node_io_flag );
948
+ F2FS_SBI_GENERAL_RW_ATTR (gc_remaining_trials );
949
+ F2FS_SBI_GENERAL_RW_ATTR (seq_file_ra_mul );
950
+ F2FS_SBI_GENERAL_RW_ATTR (gc_segment_mode );
951
+ F2FS_SBI_GENERAL_RW_ATTR (max_fragment_chunk );
952
+ F2FS_SBI_GENERAL_RW_ATTR (max_fragment_hole );
953
+ #ifdef CONFIG_F2FS_FS_COMPRESSION
954
+ F2FS_SBI_GENERAL_RW_ATTR (compr_written_block );
955
+ F2FS_SBI_GENERAL_RW_ATTR (compr_saved_block );
956
+ F2FS_SBI_GENERAL_RW_ATTR (compr_new_inode );
957
+ F2FS_SBI_GENERAL_RW_ATTR (compress_percent );
958
+ F2FS_SBI_GENERAL_RW_ATTR (compress_watermark );
959
+ #endif
960
+ /* atomic write */
961
+ F2FS_SBI_GENERAL_RO_ATTR (current_atomic_write );
962
+ F2FS_SBI_GENERAL_RW_ATTR (peak_atomic_write );
963
+ F2FS_SBI_GENERAL_RW_ATTR (committed_atomic_block );
964
+ F2FS_SBI_GENERAL_RW_ATTR (revoked_atomic_block );
965
+ /* block age extent cache */
966
+ F2FS_SBI_GENERAL_RW_ATTR (hot_data_age_threshold );
967
+ F2FS_SBI_GENERAL_RW_ATTR (warm_data_age_threshold );
968
+ F2FS_SBI_GENERAL_RW_ATTR (last_age_weight );
969
+ #ifdef CONFIG_BLK_DEV_ZONED
970
+ F2FS_SBI_GENERAL_RO_ATTR (unusable_blocks_per_sec );
971
+ #endif
972
+
973
+ /* STAT_INFO ATTR */
974
+ #ifdef CONFIG_F2FS_STAT_FS
975
+ STAT_INFO_RO_ATTR (cp_foreground_calls , cp_count );
976
+ STAT_INFO_RO_ATTR (cp_background_calls , bg_cp_count );
977
+ STAT_INFO_RO_ATTR (gc_foreground_calls , call_count );
978
+ STAT_INFO_RO_ATTR (gc_background_calls , bg_gc );
979
+ #endif
980
+
981
+ /* FAULT_INFO ATTR */
899
982
#ifdef CONFIG_F2FS_FAULT_INJECTION
900
- F2FS_RW_ATTR (FAULT_INFO_RATE , f2fs_fault_info , inject_rate , inject_rate );
901
- F2FS_RW_ATTR (FAULT_INFO_TYPE , f2fs_fault_info , inject_type , inject_type );
983
+ FAULT_INFO_GENERAL_RW_ATTR (FAULT_INFO_RATE , inject_rate );
984
+ FAULT_INFO_GENERAL_RW_ATTR (FAULT_INFO_TYPE , inject_type );
902
985
#endif
903
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , data_io_flag , data_io_flag );
904
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , node_io_flag , node_io_flag );
905
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , gc_remaining_trials , gc_remaining_trials );
906
- F2FS_RW_ATTR (CPRC_INFO , ckpt_req_control , ckpt_thread_ioprio , ckpt_thread_ioprio );
986
+
987
+ /* RESERVED_BLOCKS ATTR */
988
+ RESERVED_BLOCKS_GENERAL_RW_ATTR (reserved_blocks );
989
+
990
+ /* CPRC_INFO ATTR */
991
+ CPRC_INFO_GENERAL_RW_ATTR (ckpt_thread_ioprio );
992
+
993
+ /* ATGC_INFO ATTR */
994
+ ATGC_INFO_RW_ATTR (atgc_candidate_ratio , candidate_ratio );
995
+ ATGC_INFO_RW_ATTR (atgc_candidate_count , max_candidate_count );
996
+ ATGC_INFO_RW_ATTR (atgc_age_weight , age_weight );
997
+ ATGC_INFO_RW_ATTR (atgc_age_threshold , age_threshold );
998
+
907
999
F2FS_GENERAL_RO_ATTR (dirty_segments );
908
1000
F2FS_GENERAL_RO_ATTR (free_segments );
909
1001
F2FS_GENERAL_RO_ATTR (ovp_segments );
@@ -917,10 +1009,6 @@ F2FS_GENERAL_RO_ATTR(main_blkaddr);
917
1009
F2FS_GENERAL_RO_ATTR (pending_discard );
918
1010
F2FS_GENERAL_RO_ATTR (gc_mode );
919
1011
#ifdef CONFIG_F2FS_STAT_FS
920
- F2FS_STAT_ATTR (STAT_INFO , f2fs_stat_info , cp_foreground_calls , cp_count );
921
- F2FS_STAT_ATTR (STAT_INFO , f2fs_stat_info , cp_background_calls , bg_cp_count );
922
- F2FS_STAT_ATTR (STAT_INFO , f2fs_stat_info , gc_foreground_calls , call_count );
923
- F2FS_STAT_ATTR (STAT_INFO , f2fs_stat_info , gc_background_calls , bg_gc );
924
1012
F2FS_GENERAL_RO_ATTR (moved_blocks_background );
925
1013
F2FS_GENERAL_RO_ATTR (moved_blocks_foreground );
926
1014
F2FS_GENERAL_RO_ATTR (avg_vblocks );
@@ -935,8 +1023,6 @@ F2FS_FEATURE_RO_ATTR(encrypted_casefold);
935
1023
#endif /* CONFIG_FS_ENCRYPTION */
936
1024
#ifdef CONFIG_BLK_DEV_ZONED
937
1025
F2FS_FEATURE_RO_ATTR (block_zoned );
938
- F2FS_RO_ATTR (F2FS_SBI , f2fs_sb_info , unusable_blocks_per_sec ,
939
- unusable_blocks_per_sec );
940
1026
#endif
941
1027
F2FS_FEATURE_RO_ATTR (atomic_write );
942
1028
F2FS_FEATURE_RO_ATTR (extra_attr );
@@ -956,37 +1042,9 @@ F2FS_FEATURE_RO_ATTR(casefold);
956
1042
F2FS_FEATURE_RO_ATTR (readonly );
957
1043
#ifdef CONFIG_F2FS_FS_COMPRESSION
958
1044
F2FS_FEATURE_RO_ATTR (compression );
959
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , compr_written_block , compr_written_block );
960
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , compr_saved_block , compr_saved_block );
961
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , compr_new_inode , compr_new_inode );
962
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , compress_percent , compress_percent );
963
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , compress_watermark , compress_watermark );
964
1045
#endif
965
1046
F2FS_FEATURE_RO_ATTR (pin_file );
966
1047
967
- /* For ATGC */
968
- F2FS_RW_ATTR (ATGC_INFO , atgc_management , atgc_candidate_ratio , candidate_ratio );
969
- F2FS_RW_ATTR (ATGC_INFO , atgc_management , atgc_candidate_count , max_candidate_count );
970
- F2FS_RW_ATTR (ATGC_INFO , atgc_management , atgc_age_weight , age_weight );
971
- F2FS_RW_ATTR (ATGC_INFO , atgc_management , atgc_age_threshold , age_threshold );
972
-
973
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , seq_file_ra_mul , seq_file_ra_mul );
974
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , gc_segment_mode , gc_segment_mode );
975
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , gc_reclaimed_segments , gc_reclaimed_segs );
976
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , max_fragment_chunk , max_fragment_chunk );
977
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , max_fragment_hole , max_fragment_hole );
978
-
979
- /* For atomic write */
980
- F2FS_RO_ATTR (F2FS_SBI , f2fs_sb_info , current_atomic_write , current_atomic_write );
981
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , peak_atomic_write , peak_atomic_write );
982
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , committed_atomic_block , committed_atomic_block );
983
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , revoked_atomic_block , revoked_atomic_block );
984
-
985
- /* For block age extent cache */
986
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , hot_data_age_threshold , hot_data_age_threshold );
987
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , warm_data_age_threshold , warm_data_age_threshold );
988
- F2FS_RW_ATTR (F2FS_SBI , f2fs_sb_info , last_age_weight , last_age_weight );
989
-
990
1048
#define ATTR_LIST (name ) (&f2fs_attr_##name.attr)
991
1049
static struct attribute * f2fs_attrs [] = {
992
1050
ATTR_LIST (gc_urgent_sleep_time ),
0 commit comments