Skip to content

Commit 941ba12

Browse files
harshadjstytso
authored andcommitted
ext4: make fast_commit.h byte identical with e2fsprogs/fast_commit.h
This patch makes fast_commit.h byte by byte identical with e2fsprogs/fast_commit.h. This will help us ensure that there are no on-disk format inconsistencies between e2fsck and kernel ext4. Signed-off-by: Harshad Shirwadkar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 5a150bd commit 941ba12

File tree

2 files changed

+61
-55
lines changed

2 files changed

+61
-55
lines changed

fs/ext4/fast_commit.c

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,18 +1281,6 @@ static void ext4_fc_cleanup(journal_t *journal, int full)
12811281

12821282
/* Ext4 Replay Path Routines */
12831283

1284-
/* Get length of a particular tlv */
1285-
static inline int ext4_fc_tag_len(struct ext4_fc_tl *tl)
1286-
{
1287-
return le16_to_cpu(tl->fc_len);
1288-
}
1289-
1290-
/* Get a pointer to "value" of a tlv */
1291-
static inline u8 *ext4_fc_tag_val(struct ext4_fc_tl *tl)
1292-
{
1293-
return (u8 *)tl + sizeof(*tl);
1294-
}
1295-
12961284
/* Helper struct for dentry replay routines */
12971285
struct dentry_info_args {
12981286
int parent_ino, dname_len, ino, inode_len;
@@ -1831,32 +1819,6 @@ ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl)
18311819
return 0;
18321820
}
18331821

1834-
static inline const char *tag2str(u16 tag)
1835-
{
1836-
switch (tag) {
1837-
case EXT4_FC_TAG_LINK:
1838-
return "TAG_ADD_ENTRY";
1839-
case EXT4_FC_TAG_UNLINK:
1840-
return "TAG_DEL_ENTRY";
1841-
case EXT4_FC_TAG_ADD_RANGE:
1842-
return "TAG_ADD_RANGE";
1843-
case EXT4_FC_TAG_CREAT:
1844-
return "TAG_CREAT_DENTRY";
1845-
case EXT4_FC_TAG_DEL_RANGE:
1846-
return "TAG_DEL_RANGE";
1847-
case EXT4_FC_TAG_INODE:
1848-
return "TAG_INODE";
1849-
case EXT4_FC_TAG_PAD:
1850-
return "TAG_PAD";
1851-
case EXT4_FC_TAG_TAIL:
1852-
return "TAG_TAIL";
1853-
case EXT4_FC_TAG_HEAD:
1854-
return "TAG_HEAD";
1855-
default:
1856-
return "TAG_ERROR";
1857-
}
1858-
}
1859-
18601822
static void ext4_fc_set_bitmaps_and_counters(struct super_block *sb)
18611823
{
18621824
struct ext4_fc_replay_state *state;

fs/ext4/fast_commit.h

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
#ifndef __FAST_COMMIT_H__
44
#define __FAST_COMMIT_H__
55

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+
611
/* Fast commit tags */
712
#define EXT4_FC_TAG_ADD_RANGE 0x0001
813
#define EXT4_FC_TAG_DEL_RANGE 0x0002
@@ -50,7 +55,7 @@ struct ext4_fc_del_range {
5055
struct ext4_fc_dentry_info {
5156
__le32 fc_parent_ino;
5257
__le32 fc_ino;
53-
u8 fc_dname[0];
58+
__u8 fc_dname[0];
5459
};
5560

5661
/* Value structure for EXT4_FC_TAG_INODE and EXT4_FC_TAG_INODE_PARTIAL. */
@@ -65,19 +70,6 @@ struct ext4_fc_tail {
6570
__le32 fc_crc;
6671
};
6772

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-
8173
/*
8274
* Fast commit reason codes
8375
*/
@@ -107,6 +99,20 @@ enum {
10799
EXT4_FC_REASON_MAX
108100
};
109101

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+
110116
struct ext4_fc_stats {
111117
unsigned int fc_ineligible_reason_count[EXT4_FC_REASON_MAX];
112118
unsigned long fc_num_commits;
@@ -145,13 +151,51 @@ struct ext4_fc_replay_state {
145151
};
146152

147153
#define region_last(__region) (((__region)->lblk) + ((__region)->len) - 1)
154+
#endif
148155

149156
#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 + \
153160
sizeof(struct ext4_fc_tl) + \
154161
+ le16_to_cpu(tl->fc_len)))
155162

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+
}
156200

157201
#endif /* __FAST_COMMIT_H__ */

0 commit comments

Comments
 (0)