1 removes static definition of dx_root struct. so that "." and ".." dirent can
2 have extra data. This patch does not change any functionality but is required for
3 ext4_data_in_dirent patch.
5 Index: b/fs/ext4/namei.c
6 ===================================================================
9 @@ -121,22 +121,13 @@ struct dx_entry
10 * hash version mod 4 should never be 0. Sincerely, the paranoia department.
16 - struct fake_dirent dot;
18 - struct fake_dirent dotdot;
19 - char dotdot_name[4];
22 - __le32 reserved_zero;
24 - u8 info_length; /* 8 */
29 - struct dx_entry entries[0];
30 + __le32 reserved_zero;
32 + u8 info_length; /* 8 */
38 @@ -225,6 +216,16 @@ ext4_next_entry(struct ext4_dir_entry_2
39 * Future: use high four bits of block for coalesce-on-delete flags
40 * Mask them off for now.
42 +struct dx_root_info * dx_get_dx_info(struct ext4_dir_entry_2 *de)
44 + /* get dotdot first */
45 + de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(1));
47 + /* dx root info is after dotdot entry */
48 + de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(2));
50 + return (struct dx_root_info *) de;
53 static inline ext4_lblk_t dx_get_block(struct dx_entry *entry)
55 @@ -378,7 +379,7 @@ dx_probe(struct dentry *dentry, struct i
57 unsigned count, indirect;
58 struct dx_entry *at, *entries, *p, *q, *m;
59 - struct dx_root *root;
60 + struct dx_root_info * info;
61 struct buffer_head *bh;
62 struct dx_frame *frame = frame_in;
64 @@ -388,18 +389,19 @@ dx_probe(struct dentry *dentry, struct i
65 dir = dentry->d_parent->d_inode;
66 if (!(bh = ext4_bread (NULL,dir, 0, 0, err)))
68 - root = (struct dx_root *) bh->b_data;
69 - if (root->info.hash_version != DX_HASH_TEA &&
70 - root->info.hash_version != DX_HASH_HALF_MD4 &&
71 - root->info.hash_version != DX_HASH_LEGACY) {
73 + info = dx_get_dx_info((struct ext4_dir_entry_2*)bh->b_data);
74 + if (info->hash_version != DX_HASH_TEA &&
75 + info->hash_version != DX_HASH_HALF_MD4 &&
76 + info->hash_version != DX_HASH_LEGACY) {
77 ext4_warning(dir->i_sb, "Unrecognised inode hash code %d"
79 - root->info.hash_version, dir->i_ino);
80 + info->hash_version, dir->i_ino);
82 *err = ERR_BAD_DX_DIR;
85 - hinfo->hash_version = root->info.hash_version;
86 + hinfo->hash_version = info->hash_version;
87 if (hinfo->hash_version <= DX_HASH_TEA)
88 hinfo->hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned;
89 hinfo->seed = EXT4_SB(dir->i_sb)->s_hash_seed;
90 @@ -398,27 +399,26 @@ dx_probe(struct dentry *dentry, struct i
91 ext4fs_dirhash(dentry->d_name.name, dentry->d_name.len, hinfo);
94 - if (root->info.unused_flags & 1) {
95 + if (info->unused_flags & 1) {
96 ext4_warning(dir->i_sb, "Unimplemented inode hash flags: %#06x",
97 - root->info.unused_flags);
98 + info->unused_flags);
100 *err = ERR_BAD_DX_DIR;
104 - if ((indirect = root->info.indirect_levels) > 1) {
105 + if ((indirect = info->indirect_levels) > 1) {
106 ext4_warning(dir->i_sb, "Unimplemented inode hash depth: %#06x",
107 - root->info.indirect_levels);
108 + info->indirect_levels);
110 *err = ERR_BAD_DX_DIR;
114 - entries = (struct dx_entry *) (((char *)&root->info) +
115 - root->info.info_length);
116 + entries = (struct dx_entry *) (((char *)info) + info->info_length);
118 if (dx_get_limit(entries) != dx_root_limit(dir,
119 - root->info.info_length)) {
120 + info->info_length)) {
121 ext4_warning(dir->i_sb, "dx entry: limit != root limit");
124 @@ -509,10 +510,12 @@ fail:
126 static void dx_release (struct dx_frame *frames)
128 + struct dx_root_info *info;
129 if (frames[0].bh == NULL)
132 - if (((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels)
133 + info = dx_get_dx_info((struct ext4_dir_entry_2*)frames[0].bh->b_data);
134 + if (info->indirect_levels)
135 brelse(frames[1].bh);
136 brelse(frames[0].bh);
138 @@ -1430,17 +1433,16 @@ static int make_indexed_dir(handle_t *ha
139 const char *name = dentry->d_name.name;
140 int namelen = dentry->d_name.len;
141 struct buffer_head *bh2;
142 - struct dx_root *root;
143 struct dx_frame frames[2], *frame;
144 struct dx_entry *entries;
145 - struct ext4_dir_entry_2 *de, *de2;
146 + struct ext4_dir_entry_2 *de, *de2, *dot_de, *dotdot_de;
151 struct dx_hash_info hinfo;
153 - struct fake_dirent *fde;
154 + struct dx_root_info *dx_info;
156 blocksize = dir->i_sb->s_blocksize;
157 dxtrace(printk("Creating index\n"));
158 @@ -1450,7 +1452,6 @@ static int make_indexed_dir(handle_t *ha
162 - root = (struct dx_root *) bh->b_data;
164 bh2 = ext4_append (handle, dir, &block, &retval);
166 @@ -1460,18 +1461,20 @@ static int make_indexed_dir(handle_t *ha
168 root = (struct dx_root *) bh->b_data;
170 + dot_de = (struct ext4_dir_entry_2 *) bh->b_data;
171 + dotdot_de = ext4_next_entry(dot_de, blocksize);
173 /* The 0th block becomes the root, move the dirents out */
174 - fde = &root->dotdot;
175 - de = (struct ext4_dir_entry_2 *)((char *)fde +
176 - ext4_rec_len_from_disk(fde->rec_len, blocksize));
177 + de = (struct ext4_dir_entry_2 *)((char *)dotdot_de +
178 + ext4_rec_len_from_disk(dotdot_de->rec_len, blocksize));
179 - if ((char *) de >= (((char *) root) + blocksize)) {
180 + if ((char *) de >= (((char *) dot_de) + blocksize)) {
181 ext4_error(dir->i_sb,
182 "invalid rec_len for '..' in inode %lu",
187 - len = ((char *) root) + blocksize - (char *) de;
188 + len = ((char *) dot_de) + blocksize - (char *) de;
190 /* Allocate new block for the 0th block's dirents */
191 bh2 = ext4_append(handle, dir, &block, &retval);
192 @@ -1472,19 +1475,23 @@ static int make_indexed_dir(handle_t *ha
193 de->rec_len = ext4_rec_len_to_disk(data1 + blocksize - (char *) de);
195 /* Initialize the root; the dot dirents already exist */
196 - de = (struct ext4_dir_entry_2 *) (&root->dotdot);
197 - de->rec_len = ext4_rec_len_to_disk(blocksize - EXT4_DIR_REC_LEN(2),
199 - memset (&root->info, 0, sizeof(root->info));
200 - root->info.info_length = sizeof(root->info);
201 - root->info.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
202 - entries = root->entries;
203 - dx_set_block(entries, 1);
204 - dx_set_count(entries, 1);
205 - dx_set_limit(entries, dx_root_limit(dir, sizeof(root->info)));
206 + dotdot_de->rec_len = ext4_rec_len_to_disk(blocksize -
207 + le16_to_cpu(dot_de->rec_len), blocksize);
209 + /* initialize hashing info */
210 + dx_info = dx_get_dx_info(dot_de);
211 + memset (dx_info, 0, sizeof(*dx_info));
212 + dx_info->info_length = sizeof(*dx_info);
213 + dx_info->hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
215 + entries = (void *)dx_info + sizeof(*dx_info);
217 + dx_set_block(entries, 1);
218 + dx_set_count(entries, 1);
219 + dx_set_limit(entries, dx_root_limit(dir, sizeof(*dx_info)));
221 /* Initialize as for dx_probe */
222 - hinfo.hash_version = root->info.hash_version;
223 + hinfo.hash_version = dx_info->hash_version;
224 if (hinfo.hash_version <= DX_HASH_TEA)
225 hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned;
226 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;
227 @@ -1724,6 +1733,7 @@ static int ext4_dx_add_entry(handle_t *h
231 + struct dx_root_info * info;
232 dxtrace(printk(KERN_DEBUG
233 "Creating second level index...\n"));
234 memcpy((char *) entries2, (char *) entries,
235 @@ -1732,7 +1742,9 @@ static int ext4_dx_add_entry(handle_t *h
237 dx_set_count(entries, 1);
238 dx_set_block(entries + 0, newblock);
239 - ((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels = 1;
240 + info = dx_get_dx_info((struct ext4_dir_entry_2*)
241 + frames[0].bh->b_data);
242 + info->indirect_levels = 1;
244 /* Add new access path frame */