3
3
#ifndef __FAST_COMMIT_H__
4
4
#define __FAST_COMMIT_H__
5
5
6
+ /*
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.
9
+ */
10
+
6
11
/* Fast commit tags */
7
12
#define EXT4_FC_TAG_ADD_RANGE 0x0001
8
13
#define EXT4_FC_TAG_DEL_RANGE 0x0002
@@ -50,7 +55,7 @@ struct ext4_fc_del_range {
50
55
struct ext4_fc_dentry_info {
51
56
__le32 fc_parent_ino ;
52
57
__le32 fc_ino ;
53
- u8 fc_dname [0 ];
58
+ __u8 fc_dname [0 ];
54
59
};
55
60
56
61
/* Value structure for EXT4_FC_TAG_INODE and EXT4_FC_TAG_INODE_PARTIAL. */
@@ -65,19 +70,6 @@ struct ext4_fc_tail {
65
70
__le32 fc_crc ;
66
71
};
67
72
68
- /*
69
- * In memory list of dentry updates that are performed on the file
70
- * system used by fast commit code.
71
- */
72
- struct ext4_fc_dentry_update {
73
- int fcd_op ; /* Type of update create / unlink / link */
74
- int fcd_parent ; /* Parent inode number */
75
- int fcd_ino ; /* Inode number */
76
- struct qstr fcd_name ; /* Dirent name */
77
- unsigned char fcd_iname [DNAME_INLINE_LEN ]; /* Dirent name string */
78
- struct list_head fcd_list ;
79
- };
80
-
81
73
/*
82
74
* Fast commit reason codes
83
75
*/
@@ -107,6 +99,20 @@ enum {
107
99
EXT4_FC_REASON_MAX
108
100
};
109
101
102
+ #ifdef __KERNEL__
103
+ /*
104
+ * In memory list of dentry updates that are performed on the file
105
+ * system used by fast commit code.
106
+ */
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 ;
114
+ };
115
+
110
116
struct ext4_fc_stats {
111
117
unsigned int fc_ineligible_reason_count [EXT4_FC_REASON_MAX ];
112
118
unsigned long fc_num_commits ;
@@ -145,13 +151,51 @@ struct ext4_fc_replay_state {
145
151
};
146
152
147
153
#define region_last (__region ) (((__region)->lblk) + ((__region)->len) - 1)
154
+ #endif
148
155
149
156
#define fc_for_each_tl (__start , __end , __tl ) \
150
- for (tl = (struct ext4_fc_tl *)start; \
151
- (u8 *)tl < (u8 *)end; \
152
- tl = (struct ext4_fc_tl *)((u8 *)tl + \
157
+ for (tl = (struct ext4_fc_tl *)(__start); \
158
+ (__u8 *)tl < (__u8 *)(__end); \
159
+ tl = (struct ext4_fc_tl *)((__u8 *)tl + \
153
160
sizeof(struct ext4_fc_tl) + \
154
161
+ le16_to_cpu(tl->fc_len)))
155
162
163
+ static 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
+ /* Get length of a particular tlv */
190
+ static inline int ext4_fc_tag_len (struct ext4_fc_tl * tl )
191
+ {
192
+ return le16_to_cpu (tl -> fc_len );
193
+ }
194
+
195
+ /* Get a pointer to "value" of a tlv */
196
+ static inline __u8 * ext4_fc_tag_val (struct ext4_fc_tl * tl )
197
+ {
198
+ return (__u8 * )tl + sizeof (* tl );
199
+ }
156
200
157
201
#endif /* __FAST_COMMIT_H__ */
0 commit comments