1 /* SPDX-License-Identifier: GPL-2.0 */ 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 3 #ifndef __FAST_COMMIT_H__ 3 #ifndef __FAST_COMMIT_H__ 4 #define __FAST_COMMIT_H__ 4 #define __FAST_COMMIT_H__ 5 5 6 /* 6 /* 7 * Note this file is present in e2fsprogs/lib/ 7 * Note this file is present in e2fsprogs/lib/ext2fs/fast_commit.h and 8 * linux/fs/ext4/fast_commit.h. These file sho 8 * linux/fs/ext4/fast_commit.h. These file should always be byte identical. 9 */ 9 */ 10 10 11 /* Fast commit tags */ 11 /* Fast commit tags */ 12 #define EXT4_FC_TAG_ADD_RANGE 0x0001 12 #define EXT4_FC_TAG_ADD_RANGE 0x0001 13 #define EXT4_FC_TAG_DEL_RANGE 0x0002 13 #define EXT4_FC_TAG_DEL_RANGE 0x0002 14 #define EXT4_FC_TAG_CREAT 0x0003 14 #define EXT4_FC_TAG_CREAT 0x0003 15 #define EXT4_FC_TAG_LINK 0x0004 15 #define EXT4_FC_TAG_LINK 0x0004 16 #define EXT4_FC_TAG_UNLINK 0x0005 16 #define EXT4_FC_TAG_UNLINK 0x0005 17 #define EXT4_FC_TAG_INODE 0x0006 17 #define EXT4_FC_TAG_INODE 0x0006 18 #define EXT4_FC_TAG_PAD 0x0007 18 #define EXT4_FC_TAG_PAD 0x0007 19 #define EXT4_FC_TAG_TAIL 0x0008 19 #define EXT4_FC_TAG_TAIL 0x0008 20 #define EXT4_FC_TAG_HEAD 0x0009 20 #define EXT4_FC_TAG_HEAD 0x0009 21 21 22 #define EXT4_FC_SUPPORTED_FEATURES 0x0 22 #define EXT4_FC_SUPPORTED_FEATURES 0x0 23 23 24 /* On disk fast commit tlv value structures */ 24 /* On disk fast commit tlv value structures */ 25 25 26 /* Fast commit on disk tag length structure */ 26 /* Fast commit on disk tag length structure */ 27 struct ext4_fc_tl { 27 struct ext4_fc_tl { 28 __le16 fc_tag; 28 __le16 fc_tag; 29 __le16 fc_len; 29 __le16 fc_len; 30 }; 30 }; 31 31 32 /* Value structure for tag EXT4_FC_TAG_HEAD. * 32 /* Value structure for tag EXT4_FC_TAG_HEAD. */ 33 struct ext4_fc_head { 33 struct ext4_fc_head { 34 __le32 fc_features; 34 __le32 fc_features; 35 __le32 fc_tid; 35 __le32 fc_tid; 36 }; 36 }; 37 37 38 /* Value structure for EXT4_FC_TAG_ADD_RANGE. 38 /* Value structure for EXT4_FC_TAG_ADD_RANGE. */ 39 struct ext4_fc_add_range { 39 struct ext4_fc_add_range { 40 __le32 fc_ino; 40 __le32 fc_ino; 41 __u8 fc_ex[12]; 41 __u8 fc_ex[12]; 42 }; 42 }; 43 43 44 /* Value structure for tag EXT4_FC_TAG_DEL_RAN 44 /* Value structure for tag EXT4_FC_TAG_DEL_RANGE. */ 45 struct ext4_fc_del_range { 45 struct ext4_fc_del_range { 46 __le32 fc_ino; 46 __le32 fc_ino; 47 __le32 fc_lblk; 47 __le32 fc_lblk; 48 __le32 fc_len; 48 __le32 fc_len; 49 }; 49 }; 50 50 51 /* 51 /* 52 * This is the value structure for tags EXT4_F 52 * This is the value structure for tags EXT4_FC_TAG_CREAT, EXT4_FC_TAG_LINK 53 * and EXT4_FC_TAG_UNLINK. 53 * and EXT4_FC_TAG_UNLINK. 54 */ 54 */ 55 struct ext4_fc_dentry_info { 55 struct ext4_fc_dentry_info { 56 __le32 fc_parent_ino; 56 __le32 fc_parent_ino; 57 __le32 fc_ino; 57 __le32 fc_ino; 58 __u8 fc_dname[]; !! 58 __u8 fc_dname[0]; 59 }; 59 }; 60 60 61 /* Value structure for EXT4_FC_TAG_INODE. */ !! 61 /* Value structure for EXT4_FC_TAG_INODE and EXT4_FC_TAG_INODE_PARTIAL. */ 62 struct ext4_fc_inode { 62 struct ext4_fc_inode { 63 __le32 fc_ino; 63 __le32 fc_ino; 64 __u8 fc_raw_inode[]; !! 64 __u8 fc_raw_inode[0]; 65 }; 65 }; 66 66 67 /* Value structure for tag EXT4_FC_TAG_TAIL. * 67 /* Value structure for tag EXT4_FC_TAG_TAIL. */ 68 struct ext4_fc_tail { 68 struct ext4_fc_tail { 69 __le32 fc_tid; 69 __le32 fc_tid; 70 __le32 fc_crc; 70 __le32 fc_crc; 71 }; 71 }; 72 72 73 /* Tag base length */ << 74 #define EXT4_FC_TAG_BASE_LEN (sizeof(struct ex << 75 << 76 /* << 77 * Fast commit status codes << 78 */ << 79 enum { << 80 EXT4_FC_STATUS_OK = 0, << 81 EXT4_FC_STATUS_INELIGIBLE, << 82 EXT4_FC_STATUS_SKIPPED, << 83 EXT4_FC_STATUS_FAILED, << 84 }; << 85 << 86 /* 73 /* 87 * Fast commit ineligiblity reasons: !! 74 * Fast commit reason codes 88 */ 75 */ 89 enum { 76 enum { >> 77 /* >> 78 * Commit status codes: >> 79 */ >> 80 EXT4_FC_REASON_OK = 0, >> 81 EXT4_FC_REASON_INELIGIBLE, >> 82 EXT4_FC_REASON_ALREADY_COMMITTED, >> 83 EXT4_FC_REASON_FC_START_FAILED, >> 84 EXT4_FC_REASON_FC_FAILED, >> 85 >> 86 /* >> 87 * Fast commit ineligiblity reasons: >> 88 */ 90 EXT4_FC_REASON_XATTR = 0, 89 EXT4_FC_REASON_XATTR = 0, 91 EXT4_FC_REASON_CROSS_RENAME, 90 EXT4_FC_REASON_CROSS_RENAME, 92 EXT4_FC_REASON_JOURNAL_FLAG_CHANGE, 91 EXT4_FC_REASON_JOURNAL_FLAG_CHANGE, 93 EXT4_FC_REASON_NOMEM, 92 EXT4_FC_REASON_NOMEM, 94 EXT4_FC_REASON_SWAP_BOOT, 93 EXT4_FC_REASON_SWAP_BOOT, 95 EXT4_FC_REASON_RESIZE, 94 EXT4_FC_REASON_RESIZE, 96 EXT4_FC_REASON_RENAME_DIR, 95 EXT4_FC_REASON_RENAME_DIR, 97 EXT4_FC_REASON_FALLOC_RANGE, 96 EXT4_FC_REASON_FALLOC_RANGE, 98 EXT4_FC_REASON_INODE_JOURNAL_DATA, 97 EXT4_FC_REASON_INODE_JOURNAL_DATA, 99 EXT4_FC_REASON_ENCRYPTED_FILENAME, !! 98 EXT4_FC_COMMIT_FAILED, 100 EXT4_FC_REASON_MAX 99 EXT4_FC_REASON_MAX 101 }; 100 }; 102 101 103 #ifdef __KERNEL__ 102 #ifdef __KERNEL__ 104 /* 103 /* 105 * In memory list of dentry updates that are p 104 * In memory list of dentry updates that are performed on the file 106 * system used by fast commit code. 105 * system used by fast commit code. 107 */ 106 */ 108 struct ext4_fc_dentry_update { 107 struct ext4_fc_dentry_update { 109 int fcd_op; /* Type of upd 108 int fcd_op; /* Type of update create / unlink / link */ 110 int fcd_parent; /* Parent inod 109 int fcd_parent; /* Parent inode number */ 111 int fcd_ino; /* Inode numbe 110 int fcd_ino; /* Inode number */ 112 struct qstr fcd_name; /* Dirent name 111 struct qstr fcd_name; /* Dirent name */ 113 unsigned char fcd_iname[DNAME_INLINE_L 112 unsigned char fcd_iname[DNAME_INLINE_LEN]; /* Dirent name string */ 114 struct list_head fcd_list; 113 struct list_head fcd_list; 115 struct list_head fcd_dilist; << 116 }; 114 }; 117 115 118 struct ext4_fc_stats { 116 struct ext4_fc_stats { 119 unsigned int fc_ineligible_reason_coun 117 unsigned int fc_ineligible_reason_count[EXT4_FC_REASON_MAX]; 120 unsigned long fc_num_commits; 118 unsigned long fc_num_commits; 121 unsigned long fc_ineligible_commits; 119 unsigned long fc_ineligible_commits; 122 unsigned long fc_failed_commits; << 123 unsigned long fc_skipped_commits; << 124 unsigned long fc_numblks; 120 unsigned long fc_numblks; 125 u64 s_fc_avg_commit_time; << 126 }; 121 }; 127 122 128 #define EXT4_FC_REPLAY_REALLOC_INCREMENT 123 #define EXT4_FC_REPLAY_REALLOC_INCREMENT 4 129 124 130 /* 125 /* 131 * Physical block regions added to different i 126 * Physical block regions added to different inodes due to fast commit 132 * recovery. These are set during the SCAN pha 127 * recovery. These are set during the SCAN phase. During the replay phase, 133 * our allocator excludes these from its alloc 128 * our allocator excludes these from its allocation. This ensures that 134 * we don't accidentally allocating a block th 129 * we don't accidentally allocating a block that is going to be used by 135 * another inode. 130 * another inode. 136 */ 131 */ 137 struct ext4_fc_alloc_region { 132 struct ext4_fc_alloc_region { 138 ext4_lblk_t lblk; 133 ext4_lblk_t lblk; 139 ext4_fsblk_t pblk; 134 ext4_fsblk_t pblk; 140 int ino, len; 135 int ino, len; 141 }; 136 }; 142 137 143 /* 138 /* 144 * Fast commit replay state. 139 * Fast commit replay state. 145 */ 140 */ 146 struct ext4_fc_replay_state { 141 struct ext4_fc_replay_state { 147 int fc_replay_num_tags; 142 int fc_replay_num_tags; 148 int fc_replay_expected_off; 143 int fc_replay_expected_off; 149 int fc_current_pass; 144 int fc_current_pass; 150 int fc_cur_tag; 145 int fc_cur_tag; 151 int fc_crc; 146 int fc_crc; 152 struct ext4_fc_alloc_region *fc_region 147 struct ext4_fc_alloc_region *fc_regions; 153 int fc_regions_size, fc_regions_used, 148 int fc_regions_size, fc_regions_used, fc_regions_valid; 154 int *fc_modified_inodes; 149 int *fc_modified_inodes; 155 int fc_modified_inodes_used, fc_modifi 150 int fc_modified_inodes_used, fc_modified_inodes_size; 156 }; 151 }; 157 152 158 #define region_last(__region) (((__region)->lb 153 #define region_last(__region) (((__region)->lblk) + ((__region)->len) - 1) 159 #endif 154 #endif 160 155 161 static inline const char *tag2str(__u16 tag) 156 static inline const char *tag2str(__u16 tag) 162 { 157 { 163 switch (tag) { 158 switch (tag) { 164 case EXT4_FC_TAG_LINK: 159 case EXT4_FC_TAG_LINK: 165 return "ADD_ENTRY"; 160 return "ADD_ENTRY"; 166 case EXT4_FC_TAG_UNLINK: 161 case EXT4_FC_TAG_UNLINK: 167 return "DEL_ENTRY"; 162 return "DEL_ENTRY"; 168 case EXT4_FC_TAG_ADD_RANGE: 163 case EXT4_FC_TAG_ADD_RANGE: 169 return "ADD_RANGE"; 164 return "ADD_RANGE"; 170 case EXT4_FC_TAG_CREAT: 165 case EXT4_FC_TAG_CREAT: 171 return "CREAT_DENTRY"; 166 return "CREAT_DENTRY"; 172 case EXT4_FC_TAG_DEL_RANGE: 167 case EXT4_FC_TAG_DEL_RANGE: 173 return "DEL_RANGE"; 168 return "DEL_RANGE"; 174 case EXT4_FC_TAG_INODE: 169 case EXT4_FC_TAG_INODE: 175 return "INODE"; 170 return "INODE"; 176 case EXT4_FC_TAG_PAD: 171 case EXT4_FC_TAG_PAD: 177 return "PAD"; 172 return "PAD"; 178 case EXT4_FC_TAG_TAIL: 173 case EXT4_FC_TAG_TAIL: 179 return "TAIL"; 174 return "TAIL"; 180 case EXT4_FC_TAG_HEAD: 175 case EXT4_FC_TAG_HEAD: 181 return "HEAD"; 176 return "HEAD"; 182 default: 177 default: 183 return "ERROR"; 178 return "ERROR"; 184 } 179 } 185 } 180 } 186 181 187 #endif /* __FAST_COMMIT_H__ */ 182 #endif /* __FAST_COMMIT_H__ */ 188 183
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.