1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef __FAST_COMMIT_H__
4 #define __FAST_COMMIT_H__
7 * Note this file is present in e2fsprogs/lib/ext2fs/fast_commit.h and
8 * linux/fs/ext4/fast_commit.h. These file should always be byte identical.
11 /* Fast commit tags */
12 #define EXT4_FC_TAG_ADD_RANGE 0x0001
13 #define EXT4_FC_TAG_DEL_RANGE 0x0002
14 #define EXT4_FC_TAG_CREAT 0x0003
15 #define EXT4_FC_TAG_LINK 0x0004
16 #define EXT4_FC_TAG_UNLINK 0x0005
17 #define EXT4_FC_TAG_INODE 0x0006
18 #define EXT4_FC_TAG_PAD 0x0007
19 #define EXT4_FC_TAG_TAIL 0x0008
20 #define EXT4_FC_TAG_HEAD 0x0009
22 #define EXT4_FC_SUPPORTED_FEATURES 0x0
24 /* On disk fast commit tlv value structures */
26 /* Fast commit on disk tag length structure */
32 /* Value structure for tag EXT4_FC_TAG_HEAD. */
38 /* Value structure for EXT4_FC_TAG_ADD_RANGE. */
39 struct ext4_fc_add_range {
44 /* Value structure for tag EXT4_FC_TAG_DEL_RANGE. */
45 struct ext4_fc_del_range {
52 * This is the value structure for tags EXT4_FC_TAG_CREAT, EXT4_FC_TAG_LINK
53 * and EXT4_FC_TAG_UNLINK.
55 struct ext4_fc_dentry_info {
61 /* Value structure for EXT4_FC_TAG_INODE and EXT4_FC_TAG_INODE_PARTIAL. */
62 struct ext4_fc_inode {
67 /* Value structure for tag EXT4_FC_TAG_TAIL. */
74 * Fast commit reason codes
78 * Commit status codes:
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,
87 * Fast commit ineligiblity reasons:
89 EXT4_FC_REASON_XATTR = 0,
90 EXT4_FC_REASON_CROSS_RENAME,
91 EXT4_FC_REASON_JOURNAL_FLAG_CHANGE,
93 EXT4_FC_REASON_SWAP_BOOT,
94 EXT4_FC_REASON_RESIZE,
95 EXT4_FC_REASON_RENAME_DIR,
96 EXT4_FC_REASON_FALLOC_RANGE,
97 EXT4_FC_REASON_INODE_JOURNAL_DATA,
98 EXT4_FC_COMMIT_FAILED,
104 * In memory list of dentry updates that are performed on the file
105 * system used by fast commit code.
107 struct ext4_fc_dentry_update {
108 int fcd_op; /* Type of update create / unlink / link */
109 int fcd_parent; /* Parent inode number */
110 int fcd_ino; /* Inode number */
111 struct qstr fcd_name; /* Dirent name */
112 unsigned char fcd_iname[DNAME_INLINE_LEN]; /* Dirent name string */
113 struct list_head fcd_list;
116 struct ext4_fc_stats {
117 unsigned int fc_ineligible_reason_count[EXT4_FC_REASON_MAX];
118 unsigned long fc_num_commits;
119 unsigned long fc_ineligible_commits;
120 unsigned long fc_numblks;
123 #define EXT4_FC_REPLAY_REALLOC_INCREMENT 4
126 * Physical block regions added to different inodes due to fast commit
127 * recovery. These are set during the SCAN phase. During the replay phase,
128 * our allocator excludes these from its allocation. This ensures that
129 * we don't accidentally allocating a block that is going to be used by
132 struct ext4_fc_alloc_region {
139 * Fast commit replay state.
141 struct ext4_fc_replay_state {
142 int fc_replay_num_tags;
143 int fc_replay_expected_off;
147 struct ext4_fc_alloc_region *fc_regions;
148 int fc_regions_size, fc_regions_used, fc_regions_valid;
149 int *fc_modified_inodes;
150 int fc_modified_inodes_used, fc_modified_inodes_size;
153 #define region_last(__region) (((__region)->lblk) + ((__region)->len) - 1)
156 static inline const char *tag2str(__u16 tag)
159 case EXT4_FC_TAG_LINK:
161 case EXT4_FC_TAG_UNLINK:
163 case EXT4_FC_TAG_ADD_RANGE:
165 case EXT4_FC_TAG_CREAT:
166 return "CREAT_DENTRY";
167 case EXT4_FC_TAG_DEL_RANGE:
169 case EXT4_FC_TAG_INODE:
171 case EXT4_FC_TAG_PAD:
173 case EXT4_FC_TAG_TAIL:
175 case EXT4_FC_TAG_HEAD:
182 #endif /* __FAST_COMMIT_H__ */