Whamcloud - gitweb
LU-136 change "force_over_16tb" mount option to "force_over_128tb"
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext4-kill-dx_root-rhel6.patch
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.
4  
5 Index: linux-2.6.32.i386/fs/ext4/namei.c
6 ===================================================================
7 --- linux-2.6.32.i386.orig/fs/ext4/namei.c      2010-04-16 05:35:06.000000000 +0530
8 +++ linux-2.6.32.i386/fs/ext4/namei.c   2010-04-16 05:47:41.000000000 +0530
9 @@ -115,22 +115,13 @@
10   * hash version mod 4 should never be 0.  Sincerely, the paranoia department.
11   */
12  
13 -struct dx_root
14 +struct dx_root_info
15  {
16 -       struct fake_dirent dot;
17 -       char dot_name[4];
18 -       struct fake_dirent dotdot;
19 -       char dotdot_name[4];
20 -       struct dx_root_info
21 -       {
22 -               __le32 reserved_zero;
23 -               u8 hash_version;
24 -               u8 info_length; /* 8 */
25 -               u8 indirect_levels;
26 -               u8 unused_flags;
27 -       }
28 -       info;
29 -       struct dx_entry entries[0];
30 +       __le32 reserved_zero;
31 +       u8 hash_version;
32 +       u8 info_length; /* 8 */
33 +       u8 indirect_levels;
34 +       u8 unused_flags;
35  };
36  
37  struct dx_node
38 @@ -244,6 +235,16 @@
39   * Future: use high four bits of block for coalesce-on-delete flags
40   * Mask them off for now.
41   */
42 +struct dx_root_info * dx_get_dx_info(struct ext4_dir_entry_2 *de)
43 +{
44 +       /* get dotdot first */
45 +       de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(1));
46 +
47 +       /* dx root info is after dotdot entry */
48 +       de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(2));
49 +
50 +       return (struct dx_root_info *) de;
51 +}
52  
53  static inline ext4_lblk_t dx_get_block(struct dx_entry *entry)
54  {
55 @@ -398,7 +399,7 @@
56  {
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;
63         u32 hash;
64 @@ -406,17 +407,18 @@
65         frame->bh = NULL;
66         if (!(bh = ext4_bread (NULL,dir, 0, 0, err)))
67                 goto fail;
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) {
72 +
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 for directory "
78 -                             "#%lu", root->info.hash_version, dir->i_ino);
79 +                             "#%lu", info->hash_version, dir->i_ino);
80                 brelse(bh);
81                 *err = ERR_BAD_DX_DIR;
82                 goto fail;
83         }
84 -       hinfo->hash_version = root->info.hash_version;
85 +       hinfo->hash_version = info->hash_version;
86         if (hinfo->hash_version <= DX_HASH_TEA)
87                 hinfo->hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned;
88         hinfo->seed = EXT4_SB(dir->i_sb)->s_hash_seed;
89 @@ -425,27 +427,26 @@
90                 ext4fs_dirhash(d_name->name, d_name->len, hinfo);
91         hash = hinfo->hash;
92  
93 -       if (root->info.unused_flags & 1) {
94 +       if (info->unused_flags & 1) {
95                 ext4_warning(dir->i_sb, "Unimplemented inode hash flags: %#06x",
96 -                            root->info.unused_flags);
97 +                            info->unused_flags);
98                 brelse(bh);
99                 *err = ERR_BAD_DX_DIR;
100                 goto fail;
101         }
102  
103 -       if ((indirect = root->info.indirect_levels) > 1) {
104 +       if ((indirect = info->indirect_levels) > 1) {
105                 ext4_warning(dir->i_sb, "Unimplemented inode hash depth: %#06x",
106 -                            root->info.indirect_levels);
107 +                            info->indirect_levels);
108                 brelse(bh);
109                 *err = ERR_BAD_DX_DIR;
110                 goto fail;
111         }
112  
113 -       entries = (struct dx_entry *) (((char *)&root->info) +
114 -                                      root->info.info_length);
115 +       entries = (struct dx_entry *) (((char *)info) + info->info_length);
116  
117         if (dx_get_limit(entries) != dx_root_limit(dir,
118 -                                                  root->info.info_length)) {
119 +                                                  info->info_length)) {
120                 ext4_warning(dir->i_sb, "dx entry: limit != root limit");
121                 brelse(bh);
122                 *err = ERR_BAD_DX_DIR;
123 @@ -525,10 +526,12 @@ fail:
124  
125  static void dx_release (struct dx_frame *frames)
126  {
127 +       struct dx_root_info *info;
128         if (frames[0].bh == NULL)
129                 return;
130  
131 -       if (((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels)
132 +       info = dx_get_dx_info((struct ext4_dir_entry_2*)frames[0].bh->b_data);
133 +       if (info->indirect_levels)
134                 brelse(frames[1].bh);
135         brelse(frames[0].bh);
136  }
137 @@ -1447,17 +1450,16 @@
138         const char      *name = dentry->d_name.name;
139         int             namelen = dentry->d_name.len;
140         struct buffer_head *bh2;
141 -       struct dx_root  *root;
142         struct dx_frame frames[2], *frame;
143         struct dx_entry *entries;
144 -       struct ext4_dir_entry_2 *de, *de2;
145 +       struct ext4_dir_entry_2 *de, *de2, *dot_de, *dotdot_de;
146         char            *data1, *top;
147         unsigned        len;
148         int             retval;
149         unsigned        blocksize;
150         struct dx_hash_info hinfo;
151         ext4_lblk_t  block;
152 -       struct fake_dirent *fde;
153 +       struct dx_root_info *dx_info;
154  
155         blocksize =  dir->i_sb->s_blocksize;
156         dxtrace(printk(KERN_DEBUG "Creating index: inode %lu\n", dir->i_ino));
157 @@ -1467,20 +1469,21 @@
158                 brelse(bh);
159                 return retval;
160         }
161 -       root = (struct dx_root *) bh->b_data;
162 +
163 +       dot_de = (struct ext4_dir_entry_2 *) bh->b_data;
164 +       dotdot_de = ext4_next_entry(dot_de, blocksize);
165  
166         /* The 0th block becomes the root, move the dirents out */
167 -       fde = &root->dotdot;
168 -       de = (struct ext4_dir_entry_2 *)((char *)fde +
169 -               ext4_rec_len_from_disk(fde->rec_len, blocksize));
170 -       if ((char *) de >= (((char *) root) + blocksize)) {
171 +       de = (struct ext4_dir_entry_2 *)((char *)dotdot_de +
172 +               ext4_rec_len_from_disk(dotdot_de->rec_len, blocksize));
173 +       if ((char *) de >= (((char *) dot_de) + blocksize)) {
174                 ext4_error(dir->i_sb,
175                            "invalid rec_len for '..' in inode %lu",
176                            dir->i_ino);
177                 brelse(bh);
178                 return -EIO;
179         }
180 -       len = ((char *) root) + blocksize - (char *) de;
181 +       len = ((char *) dot_de) + blocksize - (char *) de;
182  
183         /* Allocate new block for the 0th block's dirents */
184         bh2 = ext4_append(handle, dir, &block, &retval);
185 @@ -1499,19 +1502,23 @@
186         de->rec_len = ext4_rec_len_to_disk(data1 + blocksize - (char *) de,
187                                            blocksize);
188         /* Initialize the root; the dot dirents already exist */
189 -       de = (struct ext4_dir_entry_2 *) (&root->dotdot);
190 -       de->rec_len = ext4_rec_len_to_disk(blocksize - EXT4_DIR_REC_LEN(2),
191 -                                          blocksize);
192 -       memset (&root->info, 0, sizeof(root->info));
193 -       root->info.info_length = sizeof(root->info);
194 -       root->info.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
195 -       entries = root->entries;
196 +       dotdot_de->rec_len = ext4_rec_len_to_disk(blocksize -
197 +                       le16_to_cpu(dot_de->rec_len), blocksize);
198 +
199 +       /* initialize hashing info */
200 +       dx_info = dx_get_dx_info(dot_de);
201 +       memset (dx_info, 0, sizeof(*dx_info));
202 +       dx_info->info_length = sizeof(*dx_info);
203 +       dx_info->hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version;
204 +
205 +       entries = (void *)dx_info + sizeof(*dx_info);
206 +
207         dx_set_block(entries, 1);
208         dx_set_count(entries, 1);
209 -       dx_set_limit(entries, dx_root_limit(dir, sizeof(root->info)));
210 +       dx_set_limit(entries, dx_root_limit(dir, sizeof(*dx_info)));
211  
212         /* Initialize as for dx_probe */
213 -       hinfo.hash_version = root->info.hash_version;
214 +       hinfo.hash_version = dx_info->hash_version;
215         if (hinfo.hash_version <= DX_HASH_TEA)
216                 hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned;
217         hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;
218 @@ -1759,6 +1766,7 @@
219                                 goto journal_error;
220                         brelse (bh2);
221                 } else {
222 +                       struct dx_root_info * info;
223                         dxtrace(printk(KERN_DEBUG
224                                        "Creating second level index...\n"));
225                         memcpy((char *) entries2, (char *) entries,
226 @@ -1768,7 +1776,9 @@
227                         /* Set up root */
228                         dx_set_count(entries, 1);
229                         dx_set_block(entries + 0, newblock);
230 -                       ((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels = 1;
231 +                       info = dx_get_dx_info((struct ext4_dir_entry_2*)
232 +                                       frames[0].bh->b_data);
233 +                       info->indirect_levels = 1;
234  
235                         /* Add new access path frame */
236                         frame = frames + 1;