0001
0002
0003 #ifndef __FAST_COMMIT_H__
0004 #define __FAST_COMMIT_H__
0005
0006
0007
0008
0009
0010
0011
0012 #define EXT4_FC_TAG_ADD_RANGE 0x0001
0013 #define EXT4_FC_TAG_DEL_RANGE 0x0002
0014 #define EXT4_FC_TAG_CREAT 0x0003
0015 #define EXT4_FC_TAG_LINK 0x0004
0016 #define EXT4_FC_TAG_UNLINK 0x0005
0017 #define EXT4_FC_TAG_INODE 0x0006
0018 #define EXT4_FC_TAG_PAD 0x0007
0019 #define EXT4_FC_TAG_TAIL 0x0008
0020 #define EXT4_FC_TAG_HEAD 0x0009
0021
0022 #define EXT4_FC_SUPPORTED_FEATURES 0x0
0023
0024
0025
0026
0027 struct ext4_fc_tl {
0028 __le16 fc_tag;
0029 __le16 fc_len;
0030 };
0031
0032
0033 struct ext4_fc_head {
0034 __le32 fc_features;
0035 __le32 fc_tid;
0036 };
0037
0038
0039 struct ext4_fc_add_range {
0040 __le32 fc_ino;
0041 __u8 fc_ex[12];
0042 };
0043
0044
0045 struct ext4_fc_del_range {
0046 __le32 fc_ino;
0047 __le32 fc_lblk;
0048 __le32 fc_len;
0049 };
0050
0051
0052
0053
0054
0055 struct ext4_fc_dentry_info {
0056 __le32 fc_parent_ino;
0057 __le32 fc_ino;
0058 __u8 fc_dname[];
0059 };
0060
0061
0062 struct ext4_fc_inode {
0063 __le32 fc_ino;
0064 __u8 fc_raw_inode[];
0065 };
0066
0067
0068 struct ext4_fc_tail {
0069 __le32 fc_tid;
0070 __le32 fc_crc;
0071 };
0072
0073
0074
0075
0076 enum {
0077 EXT4_FC_STATUS_OK = 0,
0078 EXT4_FC_STATUS_INELIGIBLE,
0079 EXT4_FC_STATUS_SKIPPED,
0080 EXT4_FC_STATUS_FAILED,
0081 };
0082
0083
0084
0085
0086 enum {
0087 EXT4_FC_REASON_XATTR = 0,
0088 EXT4_FC_REASON_CROSS_RENAME,
0089 EXT4_FC_REASON_JOURNAL_FLAG_CHANGE,
0090 EXT4_FC_REASON_NOMEM,
0091 EXT4_FC_REASON_SWAP_BOOT,
0092 EXT4_FC_REASON_RESIZE,
0093 EXT4_FC_REASON_RENAME_DIR,
0094 EXT4_FC_REASON_FALLOC_RANGE,
0095 EXT4_FC_REASON_INODE_JOURNAL_DATA,
0096 EXT4_FC_REASON_MAX
0097 };
0098
0099 #ifdef __KERNEL__
0100
0101
0102
0103
0104 struct ext4_fc_dentry_update {
0105 int fcd_op;
0106 int fcd_parent;
0107 int fcd_ino;
0108 struct qstr fcd_name;
0109 unsigned char fcd_iname[DNAME_INLINE_LEN];
0110 struct list_head fcd_list;
0111 struct list_head fcd_dilist;
0112 };
0113
0114 struct ext4_fc_stats {
0115 unsigned int fc_ineligible_reason_count[EXT4_FC_REASON_MAX];
0116 unsigned long fc_num_commits;
0117 unsigned long fc_ineligible_commits;
0118 unsigned long fc_failed_commits;
0119 unsigned long fc_skipped_commits;
0120 unsigned long fc_numblks;
0121 u64 s_fc_avg_commit_time;
0122 };
0123
0124 #define EXT4_FC_REPLAY_REALLOC_INCREMENT 4
0125
0126
0127
0128
0129
0130
0131
0132
0133 struct ext4_fc_alloc_region {
0134 ext4_lblk_t lblk;
0135 ext4_fsblk_t pblk;
0136 int ino, len;
0137 };
0138
0139
0140
0141
0142 struct ext4_fc_replay_state {
0143 int fc_replay_num_tags;
0144 int fc_replay_expected_off;
0145 int fc_current_pass;
0146 int fc_cur_tag;
0147 int fc_crc;
0148 struct ext4_fc_alloc_region *fc_regions;
0149 int fc_regions_size, fc_regions_used, fc_regions_valid;
0150 int *fc_modified_inodes;
0151 int fc_modified_inodes_used, fc_modified_inodes_size;
0152 };
0153
0154 #define region_last(__region) (((__region)->lblk) + ((__region)->len) - 1)
0155 #endif
0156
0157 static inline const char *tag2str(__u16 tag)
0158 {
0159 switch (tag) {
0160 case EXT4_FC_TAG_LINK:
0161 return "ADD_ENTRY";
0162 case EXT4_FC_TAG_UNLINK:
0163 return "DEL_ENTRY";
0164 case EXT4_FC_TAG_ADD_RANGE:
0165 return "ADD_RANGE";
0166 case EXT4_FC_TAG_CREAT:
0167 return "CREAT_DENTRY";
0168 case EXT4_FC_TAG_DEL_RANGE:
0169 return "DEL_RANGE";
0170 case EXT4_FC_TAG_INODE:
0171 return "INODE";
0172 case EXT4_FC_TAG_PAD:
0173 return "PAD";
0174 case EXT4_FC_TAG_TAIL:
0175 return "TAIL";
0176 case EXT4_FC_TAG_HEAD:
0177 return "HEAD";
0178 default:
0179 return "ERROR";
0180 }
0181 }
0182
0183 #endif