1
2
3#ifndef __FAST_COMMIT_H__
4#define __FAST_COMMIT_H__
5
6
7
8
9
10
11
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
21
22#define EXT4_FC_SUPPORTED_FEATURES 0x0
23
24
25
26
27struct ext4_fc_tl {
28 __le16 fc_tag;
29 __le16 fc_len;
30};
31
32
33struct ext4_fc_head {
34 __le32 fc_features;
35 __le32 fc_tid;
36};
37
38
39struct ext4_fc_add_range {
40 __le32 fc_ino;
41 __u8 fc_ex[12];
42};
43
44
45struct ext4_fc_del_range {
46 __le32 fc_ino;
47 __le32 fc_lblk;
48 __le32 fc_len;
49};
50
51
52
53
54
55struct ext4_fc_dentry_info {
56 __le32 fc_parent_ino;
57 __le32 fc_ino;
58 __u8 fc_dname[0];
59};
60
61
62struct ext4_fc_inode {
63 __le32 fc_ino;
64 __u8 fc_raw_inode[0];
65};
66
67
68struct ext4_fc_tail {
69 __le32 fc_tid;
70 __le32 fc_crc;
71};
72
73
74
75
76enum {
77
78
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
88
89 EXT4_FC_REASON_XATTR = 0,
90 EXT4_FC_REASON_CROSS_RENAME,
91 EXT4_FC_REASON_JOURNAL_FLAG_CHANGE,
92 EXT4_FC_REASON_NOMEM,
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,
99 EXT4_FC_REASON_MAX
100};
101
102#ifdef __KERNEL__
103
104
105
106
107struct ext4_fc_dentry_update {
108 int fcd_op;
109 int fcd_parent;
110 int fcd_ino;
111 struct qstr fcd_name;
112 unsigned char fcd_iname[DNAME_INLINE_LEN];
113 struct list_head fcd_list;
114};
115
116struct 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;
121};
122
123#define EXT4_FC_REPLAY_REALLOC_INCREMENT 4
124
125
126
127
128
129
130
131
132struct ext4_fc_alloc_region {
133 ext4_lblk_t lblk;
134 ext4_fsblk_t pblk;
135 int ino, len;
136};
137
138
139
140
141struct ext4_fc_replay_state {
142 int fc_replay_num_tags;
143 int fc_replay_expected_off;
144 int fc_current_pass;
145 int fc_cur_tag;
146 int fc_crc;
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;
151};
152
153#define region_last(__region) (((__region)->lblk) + ((__region)->len) - 1)
154#endif
155
156#define fc_for_each_tl(__start, __end, __tl) \
157 for (tl = (struct ext4_fc_tl *)(__start); \
158 (__u8 *)tl < (__u8 *)(__end); \
159 tl = (struct ext4_fc_tl *)((__u8 *)tl + \
160 sizeof(struct ext4_fc_tl) + \
161 + le16_to_cpu(tl->fc_len)))
162
163static inline const char *tag2str(__u16 tag)
164{
165 switch (tag) {
166 case EXT4_FC_TAG_LINK:
167 return "ADD_ENTRY";
168 case EXT4_FC_TAG_UNLINK:
169 return "DEL_ENTRY";
170 case EXT4_FC_TAG_ADD_RANGE:
171 return "ADD_RANGE";
172 case EXT4_FC_TAG_CREAT:
173 return "CREAT_DENTRY";
174 case EXT4_FC_TAG_DEL_RANGE:
175 return "DEL_RANGE";
176 case EXT4_FC_TAG_INODE:
177 return "INODE";
178 case EXT4_FC_TAG_PAD:
179 return "PAD";
180 case EXT4_FC_TAG_TAIL:
181 return "TAIL";
182 case EXT4_FC_TAG_HEAD:
183 return "HEAD";
184 default:
185 return "ERROR";
186 }
187}
188
189
190static inline int ext4_fc_tag_len(struct ext4_fc_tl *tl)
191{
192 return le16_to_cpu(tl->fc_len);
193}
194
195
196static inline __u8 *ext4_fc_tag_val(struct ext4_fc_tl *tl)
197{
198 return (__u8 *)tl + sizeof(*tl);
199}
200
201#endif
202