Whamcloud - gitweb
b=10651
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext3-ino_sb_macro-2.4.21-chaos.patch
1 Index: linux-2.4.21-chaos/fs/ext3/balloc.c
2 ===================================================================
3 --- linux-2.4.21-chaos.orig/fs/ext3/balloc.c    2003-07-15 02:09:35.000000000 +0400
4 +++ linux-2.4.21-chaos/fs/ext3/balloc.c 2003-12-12 12:50:34.000000000 +0300
5 @@ -46,18 +46,18 @@
6         unsigned long desc;
7         struct ext3_group_desc * gdp;
8  
9 -       if (block_group >= sb->u.ext3_sb.s_groups_count) {
10 +       if (block_group >= EXT3_SB(sb)->s_groups_count) {
11                 ext3_error (sb, "ext3_get_group_desc",
12                             "block_group >= groups_count - "
13                             "block_group = %d, groups_count = %lu",
14 -                           block_group, sb->u.ext3_sb.s_groups_count);
15 +                           block_group, EXT3_SB(sb)->s_groups_count);
16  
17                 return NULL;
18         }
19         
20         group_desc = block_group / EXT3_DESC_PER_BLOCK(sb);
21         desc = block_group % EXT3_DESC_PER_BLOCK(sb);
22 -       if (!sb->u.ext3_sb.s_group_desc[group_desc]) {
23 +       if (!EXT3_SB(sb)->s_group_desc[group_desc]) {
24                 ext3_error (sb, "ext3_get_group_desc",
25                             "Group descriptor not loaded - "
26                             "block_group = %d, group_desc = %lu, desc = %lu",
27 @@ -66,9 +66,9 @@
28         }
29         
30         gdp = (struct ext3_group_desc *) 
31 -             sb->u.ext3_sb.s_group_desc[group_desc]->b_data;
32 +             EXT3_SB(sb)->s_group_desc[group_desc]->b_data;
33         if (bh)
34 -               *bh = sb->u.ext3_sb.s_group_desc[group_desc];
35 +               *bh = EXT3_SB(sb)->s_group_desc[group_desc];
36         return gdp + desc;
37  }
38  
39 @@ -104,8 +104,8 @@
40          * this group.  The IO will be retried next time.
41          */
42  error_out:
43 -       sb->u.ext3_sb.s_block_bitmap_number[bitmap_nr] = block_group;
44 -       sb->u.ext3_sb.s_block_bitmap[bitmap_nr] = bh;
45 +       EXT3_SB(sb)->s_block_bitmap_number[bitmap_nr] = block_group;
46 +       EXT3_SB(sb)->s_block_bitmap[bitmap_nr] = bh;
47         return retval;
48  }
49  
50 @@ -128,16 +128,17 @@
51         int i, j, retval = 0;
52         unsigned long block_bitmap_number;
53         struct buffer_head * block_bitmap;
54 +       struct ext3_sb_info *sbi = EXT3_SB(sb);
55  
56 -       if (block_group >= sb->u.ext3_sb.s_groups_count)
57 +       if (block_group >= sbi->s_groups_count)
58                 ext3_panic (sb, "load_block_bitmap",
59                             "block_group >= groups_count - "
60                             "block_group = %d, groups_count = %lu",
61 -                           block_group, sb->u.ext3_sb.s_groups_count);
62 +                           block_group, EXT3_SB(sb)->s_groups_count);
63  
64 -       if (sb->u.ext3_sb.s_groups_count <= EXT3_MAX_GROUP_LOADED) {
65 -               if (sb->u.ext3_sb.s_block_bitmap[block_group]) {
66 -                       if (sb->u.ext3_sb.s_block_bitmap_number[block_group] ==
67 +       if (sbi->s_groups_count <= EXT3_MAX_GROUP_LOADED) {
68 +               if (sbi->s_block_bitmap[block_group]) {
69 +                       if (sbi->s_block_bitmap_number[block_group] ==
70                             block_group)
71                                 return block_group;
72                         ext3_error (sb, "__load_block_bitmap",
73 @@ -149,21 +150,20 @@
74                 return block_group;
75         }
76  
77 -       for (i = 0; i < sb->u.ext3_sb.s_loaded_block_bitmaps &&
78 -                   sb->u.ext3_sb.s_block_bitmap_number[i] != block_group; i++)
79 +       for (i = 0; i < sbi->s_loaded_block_bitmaps &&
80 +                   sbi->s_block_bitmap_number[i] != block_group; i++)
81                 ;
82 -       if (i < sb->u.ext3_sb.s_loaded_block_bitmaps &&
83 -           sb->u.ext3_sb.s_block_bitmap_number[i] == block_group) {
84 -               block_bitmap_number = sb->u.ext3_sb.s_block_bitmap_number[i];
85 -               block_bitmap = sb->u.ext3_sb.s_block_bitmap[i];
86 +       if (i < sbi->s_loaded_block_bitmaps &&
87 +           sbi->s_block_bitmap_number[i] == block_group) {
88 +               block_bitmap_number = sbi->s_block_bitmap_number[i];
89 +               block_bitmap = sbi->s_block_bitmap[i];
90                 for (j = i; j > 0; j--) {
91 -                       sb->u.ext3_sb.s_block_bitmap_number[j] =
92 -                               sb->u.ext3_sb.s_block_bitmap_number[j - 1];
93 -                       sb->u.ext3_sb.s_block_bitmap[j] =
94 -                               sb->u.ext3_sb.s_block_bitmap[j - 1];
95 +                       sbi->s_block_bitmap_number[j] =
96 +                               sbi->s_block_bitmap_number[j - 1];
97 +                       sbi->s_block_bitmap[j] = sbi->s_block_bitmap[j - 1];
98                 }
99 -               sb->u.ext3_sb.s_block_bitmap_number[0] = block_bitmap_number;
100 -               sb->u.ext3_sb.s_block_bitmap[0] = block_bitmap;
101 +               sbi->s_block_bitmap_number[0] = block_bitmap_number;
102 +               sbi->s_block_bitmap[0] = block_bitmap;
103  
104                 /*
105                  * There's still one special case here --- if block_bitmap == 0
106 @@ -173,17 +173,14 @@
107                 if (!block_bitmap)
108                         retval = read_block_bitmap (sb, block_group, 0);
109         } else {
110 -               if (sb->u.ext3_sb.s_loaded_block_bitmaps<EXT3_MAX_GROUP_LOADED)
111 -                       sb->u.ext3_sb.s_loaded_block_bitmaps++;
112 +               if (sbi->s_loaded_block_bitmaps<EXT3_MAX_GROUP_LOADED)
113 +                       sbi->s_loaded_block_bitmaps++;
114                 else
115 -                       brelse (sb->u.ext3_sb.s_block_bitmap
116 -                                       [EXT3_MAX_GROUP_LOADED - 1]);
117 -               for (j = sb->u.ext3_sb.s_loaded_block_bitmaps - 1;
118 -                                       j > 0;  j--) {
119 -                       sb->u.ext3_sb.s_block_bitmap_number[j] =
120 -                               sb->u.ext3_sb.s_block_bitmap_number[j - 1];
121 -                       sb->u.ext3_sb.s_block_bitmap[j] =
122 -                               sb->u.ext3_sb.s_block_bitmap[j - 1];
123 +                       brelse(sbi->s_block_bitmap[EXT3_MAX_GROUP_LOADED - 1]);
124 +               for (j = sbi->s_loaded_block_bitmaps - 1; j > 0;  j--) {
125 +                       sbi->s_block_bitmap_number[j] =
126 +                               sbi->s_block_bitmap_number[j - 1];
127 +                       sbi->s_block_bitmap[j] = sbi->s_block_bitmap[j - 1];
128                 }
129                 retval = read_block_bitmap (sb, block_group, 0);
130         }
131 @@ -206,24 +203,25 @@
132  static inline int load_block_bitmap (struct super_block * sb,
133                                      unsigned int block_group)
134  {
135 +       struct ext3_sb_info *sbi = EXT3_SB(sb);
136         int slot;
137 -       
138 +
139         /*
140          * Do the lookup for the slot.  First of all, check if we're asking
141          * for the same slot as last time, and did we succeed that last time?
142          */
143 -       if (sb->u.ext3_sb.s_loaded_block_bitmaps > 0 &&
144 -           sb->u.ext3_sb.s_block_bitmap_number[0] == block_group &&
145 -           sb->u.ext3_sb.s_block_bitmap[0]) {
146 +       if (sbi->s_loaded_block_bitmaps > 0 &&
147 +           sbi->s_block_bitmap_number[0] == block_group &&
148 +           sbi->s_block_bitmap[0]) {
149                 return 0;
150         }
151         /*
152          * Or can we do a fast lookup based on a loaded group on a filesystem
153          * small enough to be mapped directly into the superblock?
154          */
155 -       else if (sb->u.ext3_sb.s_groups_count <= EXT3_MAX_GROUP_LOADED && 
156 -                sb->u.ext3_sb.s_block_bitmap_number[block_group]==block_group
157 -                       && sb->u.ext3_sb.s_block_bitmap[block_group]) {
158 +       else if (sbi->s_groups_count <= EXT3_MAX_GROUP_LOADED &&
159 +                sbi->s_block_bitmap_number[block_group] == block_group
160 +                       && sbi->s_block_bitmap[block_group]) {
161                 slot = block_group;
162         }
163         /*
164 @@ -243,7 +241,7 @@
165          * If it's a valid slot, we may still have cached a previous IO error,
166          * in which case the bh in the superblock cache will be zero.
167          */
168 -       if (!sb->u.ext3_sb.s_block_bitmap[slot])
169 +       if (!sbi->s_block_bitmap[slot])
170                 return -EIO;
171         
172         /*
173 @@ -275,7 +273,7 @@
174                 return;
175         }
176         lock_super (sb);
177 -       es = sb->u.ext3_sb.s_es;
178 +       es = EXT3_SB(sb)->s_es;
179         if (block < le32_to_cpu(es->s_first_data_block) ||
180             block + count < block ||
181             (block + count) > le32_to_cpu(es->s_blocks_count)) {
182 @@ -305,7 +303,7 @@
183         if (bitmap_nr < 0)
184                 goto error_return;
185         
186 -       bitmap_bh = sb->u.ext3_sb.s_block_bitmap[bitmap_nr];
187 +       bitmap_bh = EXT3_SB(sb)->s_block_bitmap[bitmap_nr];
188         gdp = ext3_get_group_desc (sb, block_group, &gd_bh);
189         if (!gdp)
190                 goto error_return;
191 @@ -330,8 +328,8 @@
192         if (err)
193                 goto error_return;
194  
195 -       BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access");
196 -       err = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh);
197 +       BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access");
198 +       err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
199         if (err)
200                 goto error_return;
201  
202 @@ -409,8 +407,8 @@
203         if (!err) err = ret;
204  
205         /* And the superblock */
206 -       BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "dirtied superblock");
207 -       ret = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh);
208 +       BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "dirtied superblock");
209 +       ret = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
210         if (!err) err = ret;
211  
212         if (overflow && !err) {
213 @@ -563,12 +561,12 @@
214         }
215  
216         lock_super (sb);
217 -       es = sb->u.ext3_sb.s_es;
218 +       es = EXT3_SB(sb)->s_es;
219         if (le32_to_cpu(es->s_free_blocks_count) <=
220                         le32_to_cpu(es->s_r_blocks_count) &&
221 -           ((sb->u.ext3_sb.s_resuid != current->fsuid) &&
222 -            (sb->u.ext3_sb.s_resgid == 0 ||
223 -             !in_group_p (sb->u.ext3_sb.s_resgid)) && 
224 +           ((EXT3_SB(sb)->s_resuid != current->fsuid) &&
225 +            (EXT3_SB(sb)->s_resgid == 0 ||
226 +             !in_group_p (EXT3_SB(sb)->s_resgid)) &&
227              !capable(CAP_SYS_RESOURCE)))
228                 goto out;
229  
230 @@ -598,7 +596,7 @@
231                 if (bitmap_nr < 0)
232                         goto io_error;
233                 
234 -               bh = sb->u.ext3_sb.s_block_bitmap[bitmap_nr];
235 +               bh = EXT3_SB(sb)->s_block_bitmap[bitmap_nr];
236  
237                 ext3_debug ("goal is at %d:%d.\n", i, j);
238  
239 @@ -621,9 +619,9 @@
240          * Now search the rest of the groups.  We assume that 
241          * i and gdp correctly point to the last group visited.
242          */
243 -       for (k = 0; k < sb->u.ext3_sb.s_groups_count; k++) {
244 +       for (k = 0; k < EXT3_SB(sb)->s_groups_count; k++) {
245                 i++;
246 -               if (i >= sb->u.ext3_sb.s_groups_count)
247 +               if (i >= EXT3_SB(sb)->s_groups_count)
248                         i = 0;
249                 gdp = ext3_get_group_desc (sb, i, &bh2);
250                 if (!gdp) {
251 @@ -635,7 +633,7 @@
252                         if (bitmap_nr < 0)
253                                 goto io_error;
254         
255 -                       bh = sb->u.ext3_sb.s_block_bitmap[bitmap_nr];
256 +                       bh = EXT3_SB(sb)->s_block_bitmap[bitmap_nr];
257                         j = find_next_usable_block(-1, bh, 
258                                                    EXT3_BLOCKS_PER_GROUP(sb));
259                         if (j >= 0) 
260 @@ -673,8 +671,8 @@
261         fatal = ext3_journal_get_write_access(handle, bh2);
262         if (fatal) goto out;
263  
264 -       BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access");
265 -       fatal = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh);
266 +       BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access");
267 +       fatal = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
268         if (fatal) goto out;
269  
270         tmp = j + i * EXT3_BLOCKS_PER_GROUP(sb)
271 @@ -807,7 +805,7 @@
272         if (!fatal) fatal = err;
273         
274         BUFFER_TRACE(bh, "journal_dirty_metadata for superblock");
275 -       err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh);
276 +       err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
277         if (!fatal) fatal = err;
278  
279         sb->s_dirt = 1;
280 @@ -845,11 +843,11 @@
281         int i;
282         
283         lock_super (sb);
284 -       es = sb->u.ext3_sb.s_es;
285 +       es = EXT3_SB(sb)->s_es;
286         desc_count = 0;
287         bitmap_count = 0;
288         gdp = NULL;
289 -       for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) {
290 +       for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
291                 gdp = ext3_get_group_desc (sb, i, NULL);
292                 if (!gdp)
293                         continue;
294 @@ -858,7 +856,7 @@
295                 if (bitmap_nr < 0)
296                         continue;
297                 
298 -               x = ext3_count_free (sb->u.ext3_sb.s_block_bitmap[bitmap_nr],
299 +               x = ext3_count_free (EXT3_SB(sb)->s_block_bitmap[bitmap_nr],
300                                      sb->s_blocksize);
301                 printk ("group %d: stored = %d, counted = %lu\n",
302                         i, le16_to_cpu(gdp->bg_free_blocks_count), x);
303 @@ -869,7 +867,7 @@
304         unlock_super (sb);
305         return bitmap_count;
306  #else
307 -       return le32_to_cpu(sb->u.ext3_sb.s_es->s_free_blocks_count);
308 +       return le32_to_cpu(EXT3_SB(sb)->s_es->s_free_blocks_count);
309  #endif
310  }
311  
312 @@ -878,7 +876,7 @@
313                                 unsigned char * map)
314  {
315         return ext3_test_bit ((block -
316 -               le32_to_cpu(sb->u.ext3_sb.s_es->s_first_data_block)) %
317 +               le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block)) %
318                          EXT3_BLOCKS_PER_GROUP(sb), map);
319  }
320  
321 @@ -946,11 +944,11 @@
322         struct ext3_group_desc * gdp;
323         int i;
324  
325 -       es = sb->u.ext3_sb.s_es;
326 +       es = EXT3_SB(sb)->s_es;
327         desc_count = 0;
328         bitmap_count = 0;
329         gdp = NULL;
330 -       for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) {
331 +       for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
332                 gdp = ext3_get_group_desc (sb, i, NULL);
333                 if (!gdp)
334                         continue;
335 @@ -984,7 +982,7 @@
336                                     "Inode bitmap for group %d is marked free",
337                                     i);
338  
339 -               for (j = 0; j < sb->u.ext3_sb.s_itb_per_group; j++)
340 +               for (j = 0; j < EXT3_SB(sb)->s_itb_per_group; j++)
341                         if (!block_in_use (le32_to_cpu(gdp->bg_inode_table) + j,
342                                                         sb, bh->b_data))
343                                 ext3_error (sb, "ext3_check_blocks_bitmap",
344 Index: linux-2.4.21-chaos/fs/ext3/dir.c
345 ===================================================================
346 --- linux-2.4.21-chaos.orig/fs/ext3/dir.c       2003-12-12 11:36:13.000000000 +0300
347 +++ linux-2.4.21-chaos/fs/ext3/dir.c    2003-12-12 12:50:34.000000000 +0300
348 @@ -67,7 +67,7 @@
349         else if (((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize)
350                 error_msg = "directory entry across blocks";
351         else if (le32_to_cpu(de->inode) >
352 -                       le32_to_cpu(dir->i_sb->u.ext3_sb.s_es->s_inodes_count))
353 +                       le32_to_cpu(EXT3_SB(dir->i_sb)->s_es->s_inodes_count))
354                 error_msg = "inode out of bounds";
355  
356         if (error_msg != NULL)
357 Index: linux-2.4.21-chaos/fs/ext3/ialloc.c
358 ===================================================================
359 --- linux-2.4.21-chaos.orig/fs/ext3/ialloc.c    2003-09-19 03:49:54.000000000 +0400
360 +++ linux-2.4.21-chaos/fs/ext3/ialloc.c 2003-12-12 12:53:11.000000000 +0300
361 @@ -75,8 +75,8 @@
362          * this group.  The IO will be retried next time.
363          */
364  error_out:
365 -       sb->u.ext3_sb.s_inode_bitmap_number[bitmap_nr] = block_group;
366 -       sb->u.ext3_sb.s_inode_bitmap[bitmap_nr] = bh;
367 +       EXT3_SB(sb)->s_inode_bitmap_number[bitmap_nr] = block_group;
368 +       EXT3_SB(sb)->s_inode_bitmap[bitmap_nr] = bh;
369         return retval;
370  }
371  
372 @@ -228,7 +228,7 @@
373         clear_inode (inode);
374  
375         lock_super (sb);
376 -       es = sb->u.ext3_sb.s_es;
377 +       es = EXT3_SB(sb)->s_es;
378         if (ino < EXT3_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) {
379                 ext3_error (sb, "ext3_free_inode",
380                             "reserved or nonexistent inode %lu", ino);
381 @@ -240,7 +240,7 @@
382         if (bitmap_nr < 0)
383                 goto error_return;
384  
385 -       bh = sb->u.ext3_sb.s_inode_bitmap[bitmap_nr];
386 +       bh = EXT3_SB(sb)->s_inode_bitmap[bitmap_nr];
387  
388         BUFFER_TRACE(bh, "get_write_access");
389         fatal = ext3_journal_get_write_access(handle, bh);
390 @@ -258,8 +258,8 @@
391                 fatal = ext3_journal_get_write_access(handle, bh2);
392                 if (fatal) goto error_return;
393  
394 -               BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get write access");
395 -               fatal = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh);
396 +               BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get write access");
397 +               fatal = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
398                 if (fatal) goto error_return;
399  
400                 if (gdp) {
401 @@ -274,9 +274,9 @@
402                 if (!fatal) fatal = err;
403                 es->s_free_inodes_count =
404                         cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) + 1);
405 -               BUFFER_TRACE(sb->u.ext3_sb.s_sbh,
406 +               BUFFER_TRACE(EXT3_SB(sb)->s_sbh,
407                                         "call ext3_journal_dirty_metadata");
408 -               err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh);
409 +               err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
410                 if (!fatal) fatal = err;
411         }
412         BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
413 @@ -307,6 +307,8 @@
414         int i, j, avefreei;
415         struct inode * inode;
416         int bitmap_nr;
417 +       struct ext3_inode_info *ei;
418 +       struct ext3_sb_info *sbi;
419         struct ext3_group_desc * gdp;
420         struct ext3_group_desc * tmp;
421         struct ext3_super_block * es;
422 @@ -320,19 +322,21 @@
423         inode = new_inode(sb);
424         if (!inode)
425                 return ERR_PTR(-ENOMEM);
426 -       init_rwsem(&inode->u.ext3_i.truncate_sem);
427 +       sbi = EXT3_SB(sb);
428 +       ei = EXT3_I(inode);
429 +       init_rwsem(&ei->truncate_sem);
430  
431         lock_super (sb);
432 -       es = sb->u.ext3_sb.s_es;
433 +       es = sbi->s_es;
434  repeat:
435         gdp = NULL;
436         i = 0;
437  
438         if (S_ISDIR(mode)) {
439                 avefreei = le32_to_cpu(es->s_free_inodes_count) /
440 -                       sb->u.ext3_sb.s_groups_count;
441 +                       sbi->s_groups_count;
442                 if (!gdp) {
443 -                       for (j = 0; j < sb->u.ext3_sb.s_groups_count; j++) {
444 +                       for (j = 0; j < sbi->s_groups_count; j++) {
445                                 struct buffer_head *temp_buffer;
446                                 tmp = ext3_get_group_desc (sb, j, &temp_buffer);
447                                 if (tmp &&
448 @@ -352,7 +356,7 @@
449                 /*
450                  * Try to place the inode in its parent directory
451                  */
452 -               i = dir->u.ext3_i.i_block_group;
453 +               i = EXT3_I(dir)->i_block_group;
454                 tmp = ext3_get_group_desc (sb, i, &bh2);
455                 if (tmp && le16_to_cpu(tmp->bg_free_inodes_count))
456                         gdp = tmp;
457 @@ -362,10 +366,10 @@
458                          * Use a quadratic hash to find a group with a
459                          * free inode
460                          */
461 -                       for (j = 1; j < sb->u.ext3_sb.s_groups_count; j <<= 1) {
462 +                       for (j = 1; j < sbi->s_groups_count; j <<= 1) {
463                                 i += j;
464 -                               if (i >= sb->u.ext3_sb.s_groups_count)
465 -                                       i -= sb->u.ext3_sb.s_groups_count;
466 +                               if (i >= sbi->s_groups_count)
467 +                                       i -= sbi->s_groups_count;
468                                 tmp = ext3_get_group_desc (sb, i, &bh2);
469                                 if (tmp &&
470                                     le16_to_cpu(tmp->bg_free_inodes_count)) {
471 @@ -378,9 +382,9 @@
472                         /*
473                          * That failed: try linear search for a free inode
474                          */
475 -                       i = dir->u.ext3_i.i_block_group + 1;
476 -                       for (j = 2; j < sb->u.ext3_sb.s_groups_count; j++) {
477 -                               if (++i >= sb->u.ext3_sb.s_groups_count)
478 +                       i = EXT3_I(dir)->i_block_group + 1;
479 +                       for (j = 2; j < sbi->s_groups_count; j++) {
480 +                               if (++i >= sbi->s_groups_count)
481                                         i = 0;
482                                 tmp = ext3_get_group_desc (sb, i, &bh2);
483                                 if (tmp &&
484 @@ -401,11 +405,11 @@
485         if (bitmap_nr < 0)
486                 goto fail;
487  
488 -       bh = sb->u.ext3_sb.s_inode_bitmap[bitmap_nr];
489 +       bh = sbi->s_inode_bitmap[bitmap_nr];
490  
491         if ((j = ext3_find_first_zero_bit ((unsigned long *) bh->b_data,
492 -                                     EXT3_INODES_PER_GROUP(sb))) <
493 -           EXT3_INODES_PER_GROUP(sb)) {
494 +                                     sbi->s_inodes_per_group)) <
495 +           sbi->s_inodes_per_group) {
496                 BUFFER_TRACE(bh, "get_write_access");
497                 err = ext3_journal_get_write_access(handle, bh);
498                 if (err) goto fail;
499 @@ -459,13 +463,13 @@
500         err = ext3_journal_dirty_metadata(handle, bh2);
501         if (err) goto fail;
502         
503 -       BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access");
504 -       err = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh);
505 +       BUFFER_TRACE(sbi->s_sbh, "get_write_access");
506 +       err = ext3_journal_get_write_access(handle, sbi->s_sbh);
507         if (err) goto fail;
508         es->s_free_inodes_count =
509                 cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) - 1);
510 -       BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "call ext3_journal_dirty_metadata");
511 -       err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh);
512 +       BUFFER_TRACE(sbi->s_sbh, "call ext3_journal_dirty_metadata");
513 +       err = ext3_journal_dirty_metadata(handle, sbi->s_sbh);
514         sb->s_dirt = 1;
515         if (err) goto fail;
516  
517 @@ -485,35 +489,35 @@
518         inode->i_blksize = PAGE_SIZE;
519         inode->i_blocks = 0;
520         inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
521 -       inode->u.ext3_i.i_flags = dir->u.ext3_i.i_flags & ~EXT3_INDEX_FL;
522 +       ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
523         if (S_ISLNK(mode))
524 -               inode->u.ext3_i.i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
525 +               ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
526  #ifdef EXT3_FRAGMENTS
527 -       inode->u.ext3_i.i_faddr = 0;
528 -       inode->u.ext3_i.i_frag_no = 0;
529 -       inode->u.ext3_i.i_frag_size = 0;
530 +       ei->i_faddr = 0;
531 +       ei->i_frag_no = 0;
532 +       ei->i_frag_size = 0;
533  #endif
534 -       inode->u.ext3_i.i_file_acl = 0;
535 -       inode->u.ext3_i.i_dir_acl = 0;
536 -       inode->u.ext3_i.i_dtime = 0;
537 -       INIT_LIST_HEAD(&inode->u.ext3_i.i_orphan);
538 +       ei->i_file_acl = 0;
539 +       ei->i_dir_acl = 0;
540 +       ei->i_dtime = 0;
541 +       INIT_LIST_HEAD(&ei->i_orphan);
542  #ifdef EXT3_PREALLOCATE
543 -       inode->u.ext3_i.i_prealloc_count = 0;
544 +       ei->i_prealloc_count = 0;
545  #endif
546 -       inode->u.ext3_i.i_block_group = i;
547 +       ei->i_block_group = i;
548         
549         ext3_set_inode_flags(inode);
550         if (IS_SYNC(inode))
551                 handle->h_sync = 1;
552         insert_inode_hash(inode);
553 -       inode->i_generation = sb->u.ext3_sb.s_next_generation++;
554 +       inode->i_generation = sbi->s_next_generation++;
555  
556 -       inode->u.ext3_i.i_state = EXT3_STATE_NEW;
557 +       ei->i_state = EXT3_STATE_NEW;
558         err = ext3_mark_inode_dirty(handle, inode);
559         if (err) goto fail;
560  
561  #ifdef CONFIG_EXT3_FS_XATTR
562 -       init_rwsem(&inode->u.ext3_i.xattr_sem);
563 +       init_rwsem(&EXT3_I(inode)->xattr_sem);
564  #endif
565         
566         unlock_super (sb);
567 @@ -600,19 +604,19 @@
568  
569  unsigned long ext3_count_free_inodes (struct super_block * sb)
570  {
571 +       struct ext3_sb_info *sbi = EXT3_SB(sb);
572 +       struct ext3_super_block *es = sbi->s_es;
573  #ifdef EXT3FS_DEBUG
574 -       struct ext3_super_block * es;
575         unsigned long desc_count, bitmap_count, x;
576         int bitmap_nr;
577         struct ext3_group_desc * gdp;
578         int i;
579  
580         lock_super (sb);
581 -       es = sb->u.ext3_sb.s_es;
582         desc_count = 0;
583         bitmap_count = 0;
584         gdp = NULL;
585 -       for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) {
586 +       for (i = 0; i < sbi->s_groups_count; i++) {
587                 gdp = ext3_get_group_desc (sb, i, NULL);
588                 if (!gdp)
589                         continue;
590 @@ -621,8 +625,8 @@
591                 if (bitmap_nr < 0)
592                         continue;
593  
594 -               x = ext3_count_free (sb->u.ext3_sb.s_inode_bitmap[bitmap_nr],
595 -                                    EXT3_INODES_PER_GROUP(sb) / 8);
596 +               x = ext3_count_free(sbi->s_inode_bitmap[bitmap_nr],
597 +                                   sbi->s_inodes_per_group / 8);
598                 printk ("group %d: stored = %d, counted = %lu\n",
599                         i, le16_to_cpu(gdp->bg_free_inodes_count), x);
600                 bitmap_count += x;
601 @@ -632,7 +636,7 @@
602         unlock_super (sb);
603         return desc_count;
604  #else
605 -       return le32_to_cpu(sb->u.ext3_sb.s_es->s_free_inodes_count);
606 +       return le32_to_cpu(es->s_free_inodes_count);
607  #endif
608  }
609  
610 @@ -641,16 +645,18 @@
611  void ext3_check_inodes_bitmap (struct super_block * sb)
612  {
613         struct ext3_super_block * es;
614 +       struct ext3_sb_info *sbi;
615         unsigned long desc_count, bitmap_count, x;
616         int bitmap_nr;
617         struct ext3_group_desc * gdp;
618         int i;
619  
620 -       es = sb->u.ext3_sb.s_es;
621 +       sbi = EXT3_SB(sb);
622 +       es = sbi->s_es;
623         desc_count = 0;
624         bitmap_count = 0;
625         gdp = NULL;
626 -       for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) {
627 +       for (i = 0; i < sbi->s_groups_count; i++) {
628                 gdp = ext3_get_group_desc (sb, i, NULL);
629                 if (!gdp)
630                         continue;
631 @@ -659,7 +665,7 @@
632                 if (bitmap_nr < 0)
633                         continue;
634  
635 -               x = ext3_count_free (sb->u.ext3_sb.s_inode_bitmap[bitmap_nr],
636 +               x = ext3_count_free (sbi->s_inode_bitmap[bitmap_nr],
637                                      EXT3_INODES_PER_GROUP(sb) / 8);
638                 if (le16_to_cpu(gdp->bg_free_inodes_count) != x)
639                         ext3_error (sb, "ext3_check_inodes_bitmap",
640 Index: linux-2.4.21-chaos/fs/ext3/inode.c
641 ===================================================================
642 --- linux-2.4.21-chaos.orig/fs/ext3/inode.c     2003-12-05 07:55:47.000000000 +0300
643 +++ linux-2.4.21-chaos/fs/ext3/inode.c  2003-12-12 12:55:41.000000000 +0300
644 @@ -47,7 +47,7 @@
645   */
646  static inline int ext3_inode_is_fast_symlink(struct inode *inode)
647  {
648 -       int ea_blocks = inode->u.ext3_i.i_file_acl ?
649 +       int ea_blocks = EXT3_I(inode)->i_file_acl ?
650                 (inode->i_sb->s_blocksize >> 9) : 0;
651  
652         return (S_ISLNK(inode->i_mode) &&
653 @@ -224,7 +224,7 @@
654          * (Well, we could do this if we need to, but heck - it works)
655          */
656         ext3_orphan_del(handle, inode);
657 -       inode->u.ext3_i.i_dtime = CURRENT_TIME;
658 +       EXT3_I(inode)->i_dtime = CURRENT_TIME;
659  
660         /* 
661          * One subtle ordering requirement: if anything has gone wrong
662 @@ -248,13 +248,14 @@
663  void ext3_discard_prealloc (struct inode * inode)
664  {
665  #ifdef EXT3_PREALLOCATE
666 +       struct ext3_inode_info *ei = EXT3_I(inode);
667         lock_kernel();
668         /* Writer: ->i_prealloc* */
669 -       if (inode->u.ext3_i.i_prealloc_count) {
670 -               unsigned short total = inode->u.ext3_i.i_prealloc_count;
671 -               unsigned long block = inode->u.ext3_i.i_prealloc_block;
672 -               inode->u.ext3_i.i_prealloc_count = 0;
673 -               inode->u.ext3_i.i_prealloc_block = 0;
674 +       if (ei->i_prealloc_count) {
675 +               unsigned short total = ei->i_prealloc_count;
676 +               unsigned long block = ei->i_prealloc_block;
677 +               ei->i_prealloc_count = 0;
678 +               ei->i_prealloc_block = 0;
679                 /* Writer: end */
680                 ext3_free_blocks (inode, block, total);
681         }
682 @@ -271,13 +272,15 @@
683         unsigned long result;
684  
685  #ifdef EXT3_PREALLOCATE
686 +       struct ext3_inode_info *ei = EXT3_I(inode);
687 +
688         /* Writer: ->i_prealloc* */
689 -       if (inode->u.ext3_i.i_prealloc_count &&
690 -           (goal == inode->u.ext3_i.i_prealloc_block ||
691 -            goal + 1 == inode->u.ext3_i.i_prealloc_block))
692 +       if (ei->i_prealloc_count &&
693 +           (goal == ei->i_prealloc_block ||
694 +            goal + 1 == ei->i_prealloc_block))
695         {
696 -               result = inode->u.ext3_i.i_prealloc_block++;
697 -               inode->u.ext3_i.i_prealloc_count--;
698 +               result = ei->i_prealloc_block++;
699 +               ei->i_prealloc_count--;
700                 /* Writer: end */
701                 ext3_debug ("preallocation hit (%lu/%lu).\n",
702                             ++alloc_hits, ++alloc_attempts);
703 @@ -287,8 +290,8 @@
704                             alloc_hits, ++alloc_attempts);
705                 if (S_ISREG(inode->i_mode))
706                         result = ext3_new_block (inode, goal, 
707 -                                &inode->u.ext3_i.i_prealloc_count,
708 -                                &inode->u.ext3_i.i_prealloc_block, err);
709 +                                &ei->i_prealloc_count,
710 +                                &ei->i_prealloc_block, err);
711                 else
712                         result = ext3_new_block (inode, goal, 0, 0, err);
713                 /*
714 @@ -422,7 +425,7 @@
715  
716         *err = 0;
717         /* i_data is not going away, no lock needed */
718 -       add_chain (chain, NULL, inode->u.ext3_i.i_data + *offsets);
719 +       add_chain (chain, NULL, EXT3_I(inode)->i_data + *offsets);
720         if (!p->key)
721                 goto no_block;
722         while (--depth) {
723 @@ -466,7 +469,8 @@
724  
725  static inline unsigned long ext3_find_near(struct inode *inode, Indirect *ind)
726  {
727 -       u32 *start = ind->bh ? (u32*) ind->bh->b_data : inode->u.ext3_i.i_data;
728 +       struct ext3_inode_info *ei = EXT3_I(inode);
729 +       u32 *start = ind->bh ? (u32*) ind->bh->b_data : ei->i_data;
730         u32 *p;
731  
732         /* Try to find previous block */
733 @@ -482,9 +486,8 @@
734          * It is going to be refered from inode itself? OK, just put it into
735          * the same cylinder group then.
736          */
737 -       return (inode->u.ext3_i.i_block_group * 
738 -               EXT3_BLOCKS_PER_GROUP(inode->i_sb)) +
739 -              le32_to_cpu(inode->i_sb->u.ext3_sb.s_es->s_first_data_block);
740 +       return (ei->i_block_group * EXT3_BLOCKS_PER_GROUP(inode->i_sb)) +
741 +              le32_to_cpu(EXT3_SB(inode->i_sb)->s_es->s_first_data_block);
742  }
743  
744  /**
745 @@ -503,14 +506,15 @@
746  static int ext3_find_goal(struct inode *inode, long block, Indirect chain[4],
747                           Indirect *partial, unsigned long *goal)
748  {
749 +       struct ext3_inode_info *ei = EXT3_I(inode);
750         /* Writer: ->i_next_alloc* */
751 -       if (block == inode->u.ext3_i.i_next_alloc_block + 1) {
752 -               inode->u.ext3_i.i_next_alloc_block++;
753 -               inode->u.ext3_i.i_next_alloc_goal++;
754 +       if (block == ei->i_next_alloc_block + 1) {
755 +               ei->i_next_alloc_block++;
756 +               ei->i_next_alloc_goal++;
757         }
758  #ifdef SEARCH_FROM_ZERO
759 -       inode->u.ext3_i.i_next_alloc_block = 0;
760 -       inode->u.ext3_i.i_next_alloc_goal = 0;
761 +       ei->i_next_alloc_block = 0;
762 +       ei->i_next_alloc_goal = 0;
763  #endif
764         /* Writer: end */
765         /* Reader: pointers, ->i_next_alloc* */
766 @@ -519,8 +523,8 @@
767                  * try the heuristic for sequential allocation,
768                  * failing that at least try to get decent locality.
769                  */
770 -               if (block == inode->u.ext3_i.i_next_alloc_block)
771 -                       *goal = inode->u.ext3_i.i_next_alloc_goal;
772 +               if (block == ei->i_next_alloc_block)
773 +                       *goal = ei->i_next_alloc_goal;
774                 if (!*goal)
775                         *goal = ext3_find_near(inode, partial);
776  #ifdef SEARCH_FROM_ZERO
777 @@ -646,6 +650,7 @@
778  {
779         int i;
780         int err = 0;
781 +       struct ext3_inode_info *ei = EXT3_I(inode);
782  
783         /*
784          * If we're splicing into a [td]indirect block (as opposed to the
785 @@ -668,11 +673,11 @@
786         /* That's it */
787  
788         *where->p = where->key;
789 -       inode->u.ext3_i.i_next_alloc_block = block;
790 -       inode->u.ext3_i.i_next_alloc_goal = le32_to_cpu(where[num-1].key);
791 +       ei->i_next_alloc_block = block;
792 +       ei->i_next_alloc_goal = le32_to_cpu(where[num-1].key);
793  #ifdef SEARCH_FROM_ZERO
794 -       inode->u.ext3_i.i_next_alloc_block = 0;
795 -       inode->u.ext3_i.i_next_alloc_goal = 0;
796 +       ei->i_next_alloc_block = 0;
797 +       ei->i_next_alloc_goal = 0;
798  #endif
799         /* Writer: end */
800  
801 @@ -756,6 +761,7 @@
802         unsigned long goal;
803         int left;
804         int depth = ext3_block_to_path(inode, iblock, offsets);
805 +       struct ext3_inode_info *ei = EXT3_I(inode);
806         loff_t new_size;
807  
808         J_ASSERT(handle != NULL || create == 0);
809 @@ -809,7 +815,7 @@
810         /*
811          * Block out ext3_truncate while we alter the tree
812          */
813 -       down_read(&inode->u.ext3_i.truncate_sem);
814 +       down_read(&ei->truncate_sem);
815         err = ext3_alloc_branch(handle, inode, left, goal,
816                                         offsets+(partial-chain), partial);
817  
818 @@ -821,7 +827,7 @@
819         if (!err)
820                 err = ext3_splice_branch(handle, inode, iblock, chain,
821                                          partial, left);
822 -       up_read(&inode->u.ext3_i.truncate_sem);
823 +       up_read(&ei->truncate_sem);
824         if (err == -EAGAIN)
825                 goto changed;
826         if (err)
827 @@ -981,7 +987,7 @@
828                 struct buffer_head *tmp_bh;
829  
830                 for (i = 1;
831 -                    inode->u.ext3_i.i_prealloc_count &&
832 +                    EXT3_I(inode)->i_prealloc_count &&
833                      i < EXT3_SB(inode->i_sb)->s_es->s_prealloc_dir_blocks;
834                      i++) {
835                         /*
836 @@ -1199,8 +1205,8 @@
837                         kunmap(page);
838                 }
839         }
840 -       if (inode->i_size > inode->u.ext3_i.i_disksize) {
841 -               inode->u.ext3_i.i_disksize = inode->i_size;
842 +       if (inode->i_size > EXT3_I(inode)->i_disksize) {
843 +               EXT3_I(inode)->i_disksize = inode->i_size;
844                 ret2 = ext3_mark_inode_dirty(handle, inode);
845                 if (!ret) 
846                         ret = ret2;
847 @@ -2011,7 +2017,8 @@
848  void ext3_truncate(struct inode * inode)
849  {
850         handle_t *handle;
851 -       u32 *i_data = inode->u.ext3_i.i_data;
852 +       struct ext3_inode_info *ei = EXT3_I(inode);
853 +       u32 *i_data = EXT3_I(inode)->i_data;
854         int addr_per_block = EXT3_ADDR_PER_BLOCK(inode->i_sb);
855         int offsets[4];
856         Indirect chain[4];
857 @@ -2072,13 +2079,13 @@
858          * on-disk inode. We do this via i_disksize, which is the value which
859          * ext3 *really* writes onto the disk inode.
860          */
861 -       inode->u.ext3_i.i_disksize = inode->i_size;
862 +       ei->i_disksize = inode->i_size;
863  
864         /*
865          * From here we block out all ext3_get_block() callers who want to
866          * modify the block allocation tree.
867          */
868 -       down_write(&inode->u.ext3_i.truncate_sem);
869 +       down_write(&ei->truncate_sem);
870  
871         if (n == 1) {           /* direct blocks */
872                 ext3_free_data(handle, inode, NULL, i_data+offsets[0],
873 @@ -2142,7 +2149,7 @@
874                 case EXT3_TIND_BLOCK:
875                         ;
876         }
877 -       up_write(&inode->u.ext3_i.truncate_sem);
878 +       up_write(&ei->truncate_sem);
879         inode->i_mtime = inode->i_ctime = CURRENT_TIME;
880         ext3_mark_inode_dirty(handle, inode);
881  
882 @@ -2179,6 +2186,8 @@
883  
884  int ext3_get_inode_loc (struct inode *inode, struct ext3_iloc *iloc)
885  {
886 +       struct super_block *sb = inode->i_sb;
887 +       struct ext3_sb_info *sbi = EXT3_SB(sb);
888         struct buffer_head *bh = 0;
889         unsigned long block;
890         unsigned long block_group;
891 @@ -2189,25 +2198,21 @@
892                 
893         if ((inode->i_ino != EXT3_ROOT_INO &&
894                 inode->i_ino != EXT3_JOURNAL_INO &&
895 -               inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) ||
896 -               inode->i_ino > le32_to_cpu(
897 -                       inode->i_sb->u.ext3_sb.s_es->s_inodes_count)) {
898 -               ext3_error (inode->i_sb, "ext3_get_inode_loc",
899 -                           "bad inode number: %lu", inode->i_ino);
900 +               inode->i_ino < EXT3_FIRST_INO(sb)) ||
901 +               inode->i_ino > le32_to_cpu(sbi->s_es->s_inodes_count)) {
902 +               ext3_error (sb, __FUNCTION__, "bad inode #%lu", inode->i_ino);
903                 goto bad_inode;
904         }
905 -       block_group = (inode->i_ino - 1) / EXT3_INODES_PER_GROUP(inode->i_sb);
906 -       if (block_group >= inode->i_sb->u.ext3_sb.s_groups_count) {
907 -               ext3_error (inode->i_sb, "ext3_get_inode_loc",
908 -                           "group >= groups count");
909 +       block_group = (inode->i_ino - 1) / sbi->s_inodes_per_group;
910 +       if (block_group >= sbi->s_groups_count) {
911 +               ext3_error(sb, __FUNCTION__, "group >= groups count");
912                 goto bad_inode;
913         }
914 -       group_desc = block_group >> EXT3_DESC_PER_BLOCK_BITS(inode->i_sb);
915 -       desc = block_group & (EXT3_DESC_PER_BLOCK(inode->i_sb) - 1);
916 -       bh = inode->i_sb->u.ext3_sb.s_group_desc[group_desc];
917 +       group_desc = block_group >> sbi->s_desc_per_block_bits;
918 +       desc = block_group & (sbi->s_desc_per_block - 1);
919 +       bh = sbi->s_group_desc[group_desc];
920         if (!bh) {
921 -               ext3_error (inode->i_sb, "ext3_get_inode_loc",
922 -                           "Descriptor not loaded");
923 +               ext3_error(sb, __FUNCTION__, "Descriptor not loaded");
924                 goto bad_inode;
925         }
926  
927 @@ -2215,17 +2220,17 @@
928         /*
929          * Figure out the offset within the block group inode table
930          */
931 -       offset = ((inode->i_ino - 1) % EXT3_INODES_PER_GROUP(inode->i_sb)) *
932 -               EXT3_INODE_SIZE(inode->i_sb);
933 +       offset = ((inode->i_ino - 1) % sbi->s_inodes_per_group) *
934 +               sbi->s_inode_size;
935         block = le32_to_cpu(gdp[desc].bg_inode_table) +
936 -               (offset >> EXT3_BLOCK_SIZE_BITS(inode->i_sb));
937 -       if (!(bh = sb_bread(inode->i_sb, block))) {
938 -               ext3_error (inode->i_sb, "ext3_get_inode_loc",
939 +               (offset >> EXT3_BLOCK_SIZE_BITS(sb));
940 +       if (!(bh = sb_bread(sb, block))) {
941 +               ext3_error (sb, __FUNCTION__,
942                             "unable to read inode block - "
943                             "inode=%lu, block=%lu", inode->i_ino, block);
944                 goto bad_inode;
945         }
946 -       offset &= (EXT3_BLOCK_SIZE(inode->i_sb) - 1);
947 +       offset &= (EXT3_BLOCK_SIZE(sb) - 1);
948  
949         iloc->bh = bh;
950         iloc->raw_inode = (struct ext3_inode *) (bh->b_data + offset);
951 @@ -2239,7 +2244,7 @@
952  
953  void ext3_set_inode_flags(struct inode *inode)
954  {
955 -       unsigned int flags = inode->u.ext3_i.i_flags;
956 +       unsigned int flags = EXT3_I(inode)->i_flags;
957  
958         inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME);
959         if (flags & EXT3_SYNC_FL)
960 @@ -2257,6 +2262,7 @@
961  {
962         struct ext3_iloc iloc;
963         struct ext3_inode *raw_inode;
964 +       struct ext3_inode_info *ei = EXT3_I(inode);
965         struct buffer_head *bh;
966         int block;
967         
968 @@ -2264,7 +2270,7 @@
969                 goto bad_inode;
970         bh = iloc.bh;
971         raw_inode = iloc.raw_inode;
972 -       init_rwsem(&inode->u.ext3_i.truncate_sem);
973 +       init_rwsem(&ei->truncate_sem);
974         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
975         inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
976         inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
977 @@ -2277,7 +2283,7 @@
978         inode->i_atime = le32_to_cpu(raw_inode->i_atime);
979         inode->i_ctime = le32_to_cpu(raw_inode->i_ctime);
980         inode->i_mtime = le32_to_cpu(raw_inode->i_mtime);
981 -       inode->u.ext3_i.i_dtime = le32_to_cpu(raw_inode->i_dtime);
982 +       ei->i_dtime = le32_to_cpu(raw_inode->i_dtime);
983         /* We now have enough fields to check if the inode was active or not.
984          * This is needed because nfsd might try to access dead inodes
985          * the test is that same one that e2fsck uses
986 @@ -2285,7 +2291,7 @@
987          */
988         if (inode->i_nlink == 0) {
989                 if (inode->i_mode == 0 ||
990 -                   !(inode->i_sb->u.ext3_sb.s_mount_state & EXT3_ORPHAN_FS)) {
991 +                   !(EXT3_SB(inode->i_sb)->s_mount_state & EXT3_ORPHAN_FS)) {
992                         /* this inode is deleted */
993                         brelse (bh);
994                         goto bad_inode;
995 @@ -2300,33 +2306,33 @@
996                                          * size */  
997         inode->i_blocks = le32_to_cpu(raw_inode->i_blocks);
998         inode->i_version = ++event;
999 -       inode->u.ext3_i.i_flags = le32_to_cpu(raw_inode->i_flags);
1000 +       ei->i_flags = le32_to_cpu(raw_inode->i_flags);
1001  #ifdef EXT3_FRAGMENTS
1002 -       inode->u.ext3_i.i_faddr = le32_to_cpu(raw_inode->i_faddr);
1003 -       inode->u.ext3_i.i_frag_no = raw_inode->i_frag;
1004 -       inode->u.ext3_i.i_frag_size = raw_inode->i_fsize;
1005 +       ei->i_faddr = le32_to_cpu(raw_inode->i_faddr);
1006 +       ei->i_frag_no = raw_inode->i_frag;
1007 +       ei->i_frag_size = raw_inode->i_fsize;
1008  #endif
1009 -       inode->u.ext3_i.i_file_acl = le32_to_cpu(raw_inode->i_file_acl);
1010 +       ei->i_file_acl = le32_to_cpu(raw_inode->i_file_acl);
1011         if (!S_ISREG(inode->i_mode)) {
1012 -               inode->u.ext3_i.i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl);
1013 +               ei->i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl);
1014         } else {
1015                 inode->i_size |=
1016                         ((__u64)le32_to_cpu(raw_inode->i_size_high)) << 32;
1017         }
1018 -       inode->u.ext3_i.i_disksize = inode->i_size;
1019 +       ei->i_disksize = inode->i_size;
1020         inode->i_generation = le32_to_cpu(raw_inode->i_generation);
1021  #ifdef EXT3_PREALLOCATE
1022 -       inode->u.ext3_i.i_prealloc_count = 0;
1023 +       ei->i_prealloc_count = 0;
1024  #endif
1025 -       inode->u.ext3_i.i_block_group = iloc.block_group;
1026 +       ei->i_block_group = iloc.block_group;
1027  
1028         /*
1029          * NOTE! The in-memory inode i_data array is in little-endian order
1030          * even on big-endian machines: we do NOT byteswap the block numbers!
1031          */
1032         for (block = 0; block < EXT3_N_BLOCKS; block++)
1033 -               inode->u.ext3_i.i_data[block] = iloc.raw_inode->i_block[block];
1034 -       INIT_LIST_HEAD(&inode->u.ext3_i.i_orphan);
1035 +               ei->i_data[block] = iloc.raw_inode->i_block[block];
1036 +       INIT_LIST_HEAD(&ei->i_orphan);
1037  
1038         if (S_ISREG(inode->i_mode)) {
1039                 inode->i_op = &ext3_file_inode_operations;
1040 @@ -2350,15 +2356,15 @@
1041         brelse (iloc.bh);
1042         ext3_set_inode_flags(inode);
1043  #ifdef CONFIG_EXT3_FS_XATTR
1044 -       init_rwsem(&inode->u.ext3_i.xattr_sem);
1045 +       init_rwsem(&ei->xattr_sem);
1046  #endif
1047  #ifdef CONFIG_EXT3_FS_POSIX_ACL
1048 -       if (inode->u.ext3_i.i_file_acl) {
1049 +       if (ei->i_file_acl) {
1050                 /* The filesystem is mounted with ACL support, and there
1051                    are extended attributes for this inode. However we do
1052                    not yet know whether there are actually any ACLs. */
1053 -               inode->u.ext3_i.i_acl = EXT3_ACL_NOT_CACHED;
1054 -               inode->u.ext3_i.i_default_acl = EXT3_ACL_NOT_CACHED;
1055 +               ei->i_acl = EXT3_ACL_NOT_CACHED;
1056 +               ei->i_default_acl = EXT3_ACL_NOT_CACHED;
1057         }
1058  #endif
1059  
1060 @@ -2380,6 +2386,7 @@
1061                                 struct ext3_iloc *iloc)
1062  {
1063         struct ext3_inode *raw_inode = iloc->raw_inode;
1064 +       struct ext3_inode_info *ei = EXT3_I(inode);
1065         struct buffer_head *bh = iloc->bh;
1066         int err = 0, rc, block;
1067  
1068 @@ -2397,7 +2404,7 @@
1069   * Fix up interoperability with old kernels. Otherwise, old inodes get
1070   * re-used with the upper 16 bits of the uid/gid intact
1071   */
1072 -               if(!inode->u.ext3_i.i_dtime) {
1073 +               if(!ei->i_dtime) {
1074                         raw_inode->i_uid_high =
1075                                 cpu_to_le16(high_16_bits(inode->i_uid));
1076                         raw_inode->i_gid_high =
1077 @@ -2415,34 +2422,33 @@
1078                 raw_inode->i_gid_high = 0;
1079         }
1080         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
1081 -       raw_inode->i_size = cpu_to_le32(inode->u.ext3_i.i_disksize);
1082 +       raw_inode->i_size = cpu_to_le32(ei->i_disksize);
1083         raw_inode->i_atime = cpu_to_le32(inode->i_atime);
1084         raw_inode->i_ctime = cpu_to_le32(inode->i_ctime);
1085         raw_inode->i_mtime = cpu_to_le32(inode->i_mtime);
1086         raw_inode->i_blocks = cpu_to_le32(inode->i_blocks);
1087 -       raw_inode->i_dtime = cpu_to_le32(inode->u.ext3_i.i_dtime);
1088 -       raw_inode->i_flags = cpu_to_le32(inode->u.ext3_i.i_flags);
1089 +       raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
1090 +       raw_inode->i_flags = cpu_to_le32(ei->i_flags);
1091  #ifdef EXT3_FRAGMENTS
1092 -       raw_inode->i_faddr = cpu_to_le32(inode->u.ext3_i.i_faddr);
1093 -       raw_inode->i_frag = inode->u.ext3_i.i_frag_no;
1094 -       raw_inode->i_fsize = inode->u.ext3_i.i_frag_size;
1095 +       raw_inode->i_faddr = cpu_to_le32(ei->i_faddr);
1096 +       raw_inode->i_frag = ei->i_frag_no;
1097 +       raw_inode->i_fsize = ei->i_frag_size;
1098  #else
1099         /* If we are not tracking these fields in the in-memory inode,
1100          * then preserve them on disk, but still initialise them to zero
1101          * for new inodes. */
1102 -       if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) {
1103 +       if (ei->i_state & EXT3_STATE_NEW) {
1104                 raw_inode->i_faddr = 0;
1105                 raw_inode->i_frag = 0;
1106                 raw_inode->i_fsize = 0;
1107         }
1108  #endif
1109 -       raw_inode->i_file_acl = cpu_to_le32(inode->u.ext3_i.i_file_acl);
1110 +       raw_inode->i_file_acl = cpu_to_le32(ei->i_file_acl);
1111         if (!S_ISREG(inode->i_mode)) {
1112 -               raw_inode->i_dir_acl = cpu_to_le32(inode->u.ext3_i.i_dir_acl);
1113 +               raw_inode->i_dir_acl = cpu_to_le32(ei->i_dir_acl);
1114         } else {
1115 -               raw_inode->i_size_high =
1116 -                       cpu_to_le32(inode->u.ext3_i.i_disksize >> 32);
1117 -               if (inode->u.ext3_i.i_disksize > 0x7fffffffULL) {
1118 +               raw_inode->i_size_high = cpu_to_le32(ei->i_disksize >> 32);
1119 +               if (ei->i_disksize > MAX_NON_LFS) {
1120                         struct super_block *sb = inode->i_sb;
1121                         if (!EXT3_HAS_RO_COMPAT_FEATURE(sb,
1122                                         EXT3_FEATURE_RO_COMPAT_LARGE_FILE) ||
1123 @@ -2452,7 +2458,7 @@
1124                                 * created, add a flag to the superblock.
1125                                 */
1126                                 err = ext3_journal_get_write_access(handle,
1127 -                                               sb->u.ext3_sb.s_sbh);
1128 +                                               EXT3_SB(sb)->s_sbh);
1129                                 if (err)
1130                                         goto out_brelse;
1131                                 ext3_update_dynamic_rev(sb);
1132 @@ -2461,7 +2467,7 @@
1133                                 sb->s_dirt = 1;
1134                                 handle->h_sync = 1;
1135                                 err = ext3_journal_dirty_metadata(handle,
1136 -                                               sb->u.ext3_sb.s_sbh);
1137 +                                               EXT3_SB(sb)->s_sbh);
1138                         }
1139                 }
1140         }
1141 @@ -2470,13 +2476,13 @@
1142                 raw_inode->i_block[0] =
1143                         cpu_to_le32(kdev_t_to_nr(inode->i_rdev));
1144         else for (block = 0; block < EXT3_N_BLOCKS; block++)
1145 -               raw_inode->i_block[block] = inode->u.ext3_i.i_data[block];
1146 +               raw_inode->i_block[block] = ei->i_data[block];
1147  
1148         BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
1149         rc = ext3_journal_dirty_metadata(handle, bh);
1150         if (!err)
1151                 err = rc;
1152 -       EXT3_I(inode)->i_state &= ~EXT3_STATE_NEW;
1153 +       ei->i_state &= ~EXT3_STATE_NEW;
1154  
1155  out_brelse:
1156         brelse (bh);
1157 @@ -2581,7 +2587,7 @@
1158                 }
1159                 
1160                 error = ext3_orphan_add(handle, inode);
1161 -               inode->u.ext3_i.i_disksize = attr->ia_size;
1162 +               EXT3_I(inode)->i_disksize = attr->ia_size;
1163                 rc = ext3_mark_inode_dirty(handle, inode);
1164                 if (!error)
1165                         error = rc;
1166 @@ -2843,9 +2849,9 @@
1167          */
1168  
1169         if (val)
1170 -               inode->u.ext3_i.i_flags |= EXT3_JOURNAL_DATA_FL;
1171 +               EXT3_I(inode)->i_flags |= EXT3_JOURNAL_DATA_FL;
1172         else
1173 -               inode->u.ext3_i.i_flags &= ~EXT3_JOURNAL_DATA_FL;
1174 +               EXT3_I(inode)->i_flags &= ~EXT3_JOURNAL_DATA_FL;
1175  
1176         journal_unlock_updates(journal);
1177  
1178 Index: linux-2.4.21-chaos/fs/ext3/ioctl.c
1179 ===================================================================
1180 --- linux-2.4.21-chaos.orig/fs/ext3/ioctl.c     2003-09-19 03:49:54.000000000 +0400
1181 +++ linux-2.4.21-chaos/fs/ext3/ioctl.c  2003-12-12 12:50:34.000000000 +0300
1182 @@ -18,13 +18,14 @@
1183  int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
1184                 unsigned long arg)
1185  {
1186 +       struct ext3_inode_info *ei = EXT3_I(inode);
1187         unsigned int flags;
1188  
1189         ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
1190  
1191         switch (cmd) {
1192         case EXT3_IOC_GETFLAGS:
1193 -               flags = inode->u.ext3_i.i_flags & EXT3_FL_USER_VISIBLE;
1194 +               flags = ei->i_flags & EXT3_FL_USER_VISIBLE;
1195                 return put_user(flags, (int *) arg);
1196         case EXT3_IOC_SETFLAGS: {
1197                 handle_t *handle = NULL;
1198 @@ -42,7 +43,7 @@
1199                 if (get_user(flags, (int *) arg))
1200                         return -EFAULT;
1201  
1202 -               oldflags = inode->u.ext3_i.i_flags;
1203 +               oldflags = ei->i_flags;
1204  
1205                 /* The JOURNAL_DATA flag is modifiable only by root */
1206                 jflag = flags & EXT3_JOURNAL_DATA_FL;
1207 @@ -79,7 +80,7 @@
1208                 
1209                 flags = flags & EXT3_FL_USER_MODIFIABLE;
1210                 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
1211 -               inode->u.ext3_i.i_flags = flags;
1212 +               ei->i_flags = flags;
1213  
1214                 ext3_set_inode_flags(inode);
1215                 inode->i_ctime = CURRENT_TIME;
1216 @@ -138,12 +139,12 @@
1217                         int ret = 0;
1218  
1219                         set_current_state(TASK_INTERRUPTIBLE);
1220 -                       add_wait_queue(&sb->u.ext3_sb.ro_wait_queue, &wait);
1221 -                       if (timer_pending(&sb->u.ext3_sb.turn_ro_timer)) {
1222 +                       add_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait);
1223 +                       if (timer_pending(&EXT3_SB(sb)->turn_ro_timer)) {
1224                                 schedule();
1225                                 ret = 1;
1226                         }
1227 -                       remove_wait_queue(&sb->u.ext3_sb.ro_wait_queue, &wait);
1228 +                       remove_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait);
1229                         return ret;
1230                 }
1231  #endif
1232 Index: linux-2.4.21-chaos/fs/ext3/namei.c
1233 ===================================================================
1234 --- linux-2.4.21-chaos.orig/fs/ext3/namei.c     2003-12-12 11:36:13.000000000 +0300
1235 +++ linux-2.4.21-chaos/fs/ext3/namei.c  2003-12-12 12:56:27.000000000 +0300
1236 @@ -343,7 +343,7 @@
1237                 goto fail;
1238         }
1239         hinfo->hash_version = root->info.hash_version;
1240 -       hinfo->seed = dir->i_sb->u.ext3_sb.s_hash_seed;
1241 +       hinfo->seed = EXT3_SB(dir->i_sb)->s_hash_seed;
1242         if (dentry)
1243                 ext3fs_dirhash(dentry->d_name.name, dentry->d_name.len, hinfo);
1244         hash = hinfo->hash;
1245 @@ -1236,7 +1236,7 @@
1246         de->rec_len = cpu_to_le16(blocksize - EXT3_DIR_REC_LEN(2));
1247         memset (&root->info, 0, sizeof(root->info));
1248         root->info.info_length = sizeof(root->info);
1249 -       root->info.hash_version = dir->i_sb->u.ext3_sb.s_def_hash_version;
1250 +       root->info.hash_version = EXT3_SB(dir->i_sb)->s_def_hash_version;
1251         entries = root->entries;
1252         dx_set_block (entries, 1);
1253         dx_set_count (entries, 1);
1254 @@ -1244,7 +1244,7 @@
1255  
1256         /* Initialize as for dx_probe */
1257         hinfo.hash_version = root->info.hash_version;
1258 -       hinfo.seed = dir->i_sb->u.ext3_sb.s_hash_seed;
1259 +       hinfo.seed = EXT3_SB(dir->i_sb)->s_hash_seed;
1260         ext3fs_dirhash(name, namelen, &hinfo);
1261         frame = frames;
1262         frame->entries = entries;
1263 @@ -1768,8 +1768,8 @@
1264         J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
1265                 S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
1266  
1267 -       BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access");
1268 -       err = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh);
1269 +       BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access");
1270 +       err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh);
1271         if (err)
1272                 goto out_unlock;
1273         
1274 @@ -1780,7 +1780,7 @@
1275         /* Insert this inode at the head of the on-disk orphan list... */
1276         NEXT_ORPHAN(inode) = le32_to_cpu(EXT3_SB(sb)->s_es->s_last_orphan);
1277         EXT3_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino);
1278 -       err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh);
1279 +       err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
1280         rc = ext3_mark_iloc_dirty(handle, inode, &iloc);
1281         if (!err)
1282                 err = rc;
1283 @@ -1854,8 +1854,7 @@
1284                 err = ext3_journal_dirty_metadata(handle, sbi->s_sbh);
1285         } else {
1286                 struct ext3_iloc iloc2;
1287 -               struct inode *i_prev =
1288 -                       list_entry(prev, struct inode, u.ext3_i.i_orphan);
1289 +               struct inode *i_prev = orphan_list_entry(prev);
1290  
1291                 jbd_debug(4, "orphan inode %lu will point to %lu\n",
1292                           i_prev->i_ino, ino_next);
1293 Index: linux-2.4.21-chaos/fs/ext3/super.c
1294 ===================================================================
1295 --- linux-2.4.21-chaos.orig/fs/ext3/super.c     2003-12-12 12:14:29.000000000 +0300
1296 +++ linux-2.4.21-chaos/fs/ext3/super.c  2003-12-12 12:50:34.000000000 +0300
1297 @@ -125,7 +125,7 @@
1298         /* If no overrides were specified on the mount, then fall back
1299          * to the default behaviour set in the filesystem's superblock
1300          * on disk. */
1301 -       switch (le16_to_cpu(sb->u.ext3_sb.s_es->s_errors)) {
1302 +       switch (le16_to_cpu(EXT3_SB(sb)->s_es->s_errors)) {
1303         case EXT3_ERRORS_PANIC:
1304                 return EXT3_ERRORS_PANIC;
1305         case EXT3_ERRORS_RO:
1306 @@ -299,9 +299,9 @@
1307                 return;
1308         
1309         printk (KERN_CRIT "Remounting filesystem read-only\n");
1310 -       sb->u.ext3_sb.s_mount_state |= EXT3_ERROR_FS;
1311 +       EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS;
1312         sb->s_flags |= MS_RDONLY;
1313 -       sb->u.ext3_sb.s_mount_opt |= EXT3_MOUNT_ABORT;
1314 +       EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT;
1315         journal_abort(EXT3_SB(sb)->s_journal, -EIO);
1316  }
1317  
1318 @@ -407,8 +407,6 @@
1319         return ret;
1320  }
1321  
1322 -#define orphan_list_entry(l) list_entry((l), struct inode, u.ext3_i.i_orphan)
1323 -
1324  static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi)
1325  {
1326         struct list_head *l;
1327 @@ -889,7 +887,7 @@
1328                 return;
1329         }
1330  
1331 -       if (sb->u.ext3_sb.s_mount_state & EXT3_ERROR_FS) {
1332 +       if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) {
1333                 if (es->s_last_orphan)
1334                         jbd_debug(1, "Errors on filesystem, "
1335                                   "clearing orphan list.\n");
1336 @@ -1571,12 +1569,14 @@
1337                                struct ext3_super_block * es,
1338                                int sync)
1339  {
1340 +       struct buffer_head *sbh = EXT3_SB(sb)->s_sbh;
1341 +
1342         es->s_wtime = cpu_to_le32(CURRENT_TIME);
1343 -       BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "marking dirty");
1344 -       mark_buffer_dirty(sb->u.ext3_sb.s_sbh);
1345 +       BUFFER_TRACE(sbh, "marking dirty");
1346 +       mark_buffer_dirty(sbh);
1347         if (sync) {
1348 -               ll_rw_block(WRITE, 1, &sb->u.ext3_sb.s_sbh);
1349 -               wait_on_buffer(sb->u.ext3_sb.s_sbh);
1350 +               ll_rw_block(WRITE, 1, &sbh);
1351 +               wait_on_buffer(sbh);
1352         }
1353  }
1354  
1355 @@ -1627,7 +1627,7 @@
1356                 ext3_warning(sb, __FUNCTION__, "Marking fs in need of "
1357                              "filesystem check.");
1358                 
1359 -               sb->u.ext3_sb.s_mount_state |= EXT3_ERROR_FS;
1360 +               EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS;
1361                 es->s_state |= cpu_to_le16(EXT3_ERROR_FS);
1362                 ext3_commit_super (sb, es, 1);
1363  
1364 Index: linux-2.4.21-chaos/fs/ext3/symlink.c
1365 ===================================================================
1366 --- linux-2.4.21-chaos.orig/fs/ext3/symlink.c   2003-07-15 04:41:01.000000000 +0400
1367 +++ linux-2.4.21-chaos/fs/ext3/symlink.c        2003-12-12 12:50:34.000000000 +0300
1368 @@ -24,14 +24,14 @@
1369  
1370  static int ext3_readlink(struct dentry *dentry, char *buffer, int buflen)
1371  {
1372 -       char *s = (char *)dentry->d_inode->u.ext3_i.i_data;
1373 -       return vfs_readlink(dentry, buffer, buflen, s);
1374 +       struct ext3_inode_info *ei = EXT3_I(dentry->d_inode);
1375 +       return vfs_readlink(dentry, buffer, buflen, (char *)ei->i_data);
1376  }
1377  
1378  static int ext3_follow_link(struct dentry *dentry, struct nameidata *nd)
1379  {
1380 -       char *s = (char *)dentry->d_inode->u.ext3_i.i_data;
1381 -       return vfs_follow_link(nd, s);
1382 +       struct ext3_inode_info *ei = EXT3_I(dentry->d_inode);
1383 +       return vfs_follow_link(nd, (char*)ei->i_data);
1384  }
1385  
1386  struct inode_operations ext3_symlink_inode_operations = {
1387 Index: linux-2.4.21-chaos/include/linux/ext3_fs.h
1388 ===================================================================
1389 --- linux-2.4.21-chaos.orig/include/linux/ext3_fs.h     2003-12-12 11:36:14.000000000 +0300
1390 +++ linux-2.4.21-chaos/include/linux/ext3_fs.h  2003-12-12 12:50:34.000000000 +0300
1391 @@ -87,22 +87,25 @@
1392  #define EXT3_MIN_BLOCK_SIZE            1024
1393  #define        EXT3_MAX_BLOCK_SIZE             4096
1394  #define EXT3_MIN_BLOCK_LOG_SIZE                  10
1395 +
1396  #ifdef __KERNEL__
1397 -# define EXT3_BLOCK_SIZE(s)            ((s)->s_blocksize)
1398 -#else
1399 -# define EXT3_BLOCK_SIZE(s)            (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
1400 -#endif
1401 -#define        EXT3_ADDR_PER_BLOCK(s)          (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
1402 -#ifdef __KERNEL__
1403 -# define EXT3_BLOCK_SIZE_BITS(s)       ((s)->s_blocksize_bits)
1404 -#else
1405 -# define EXT3_BLOCK_SIZE_BITS(s)       ((s)->s_log_block_size + 10)
1406 -#endif
1407 -#ifdef __KERNEL__
1408 -#define        EXT3_ADDR_PER_BLOCK_BITS(s)     ((s)->u.ext3_sb.s_addr_per_block_bits)
1409 -#define EXT3_INODE_SIZE(s)             ((s)->u.ext3_sb.s_inode_size)
1410 -#define EXT3_FIRST_INO(s)              ((s)->u.ext3_sb.s_first_ino)
1411 +#define EXT3_SB(sb)    (&((sb)->u.ext3_sb))
1412 +#define EXT3_I(inode)  (&((inode)->u.ext3_i))
1413 +
1414 +#define EXT3_BLOCK_SIZE(s)             ((s)->s_blocksize)
1415 +#define EXT3_BLOCK_SIZE_BITS(s)                ((s)->s_blocksize_bits)
1416 +#define        EXT3_ADDR_PER_BLOCK_BITS(s)     (EXT3_SB(s)->s_addr_per_block_bits)
1417 +#define EXT3_INODE_SIZE(s)             (EXT3_SB(s)->s_inode_size)
1418 +#define EXT3_FIRST_INO(s)              (EXT3_SB(s)->s_first_ino)
1419  #else
1420 +
1421 +/* Assume that user mode programs are passing in an ext3fs superblock, not
1422 + * a kernel struct super_block.  This will allow us to call the feature-test
1423 + * macros from user land. */
1424 +#define EXT3_SB(sb)    (sb)
1425 +
1426 +#define EXT3_BLOCK_SIZE(s)     (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
1427 +#define EXT3_BLOCK_SIZE_BITS(s)        ((s)->s_log_block_size + 10)
1428  #define EXT3_INODE_SIZE(s)     (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \
1429                                  EXT3_GOOD_OLD_INODE_SIZE : \
1430                                  (s)->s_inode_size)
1431 @@ -110,6 +113,7 @@
1432                                  EXT3_GOOD_OLD_FIRST_INO : \
1433                                  (s)->s_first_ino)
1434  #endif
1435 +#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
1436  
1437  /*
1438   * Macro-instructions used to manage fragments
1439 @@ -118,8 +122,8 @@
1440  #define        EXT3_MAX_FRAG_SIZE              4096
1441  #define EXT3_MIN_FRAG_LOG_SIZE           10
1442  #ifdef __KERNEL__
1443 -# define EXT3_FRAG_SIZE(s)             ((s)->u.ext3_sb.s_frag_size)
1444 -# define EXT3_FRAGS_PER_BLOCK(s)       ((s)->u.ext3_sb.s_frags_per_block)
1445 +# define EXT3_FRAG_SIZE(s)             (EXT3_SB(s)->s_frag_size)
1446 +# define EXT3_FRAGS_PER_BLOCK(s)       (EXT3_SB(s)->s_frags_per_block)
1447  #else
1448  # define EXT3_FRAG_SIZE(s)             (EXT3_MIN_FRAG_SIZE << (s)->s_log_frag_size)
1449  # define EXT3_FRAGS_PER_BLOCK(s)       (EXT3_BLOCK_SIZE(s) / EXT3_FRAG_SIZE(s))
1450 @@ -143,15 +147,13 @@
1451  /*
1452   * Macro-instructions used to manage group descriptors
1453   */
1454 +# define EXT3_BLOCKS_PER_GROUP(s)      (EXT3_SB(s)->s_blocks_per_group)
1455 +# define EXT3_INODES_PER_GROUP(s)      (EXT3_SB(s)->s_inodes_per_group)
1456  #ifdef __KERNEL__
1457 -# define EXT3_BLOCKS_PER_GROUP(s)      ((s)->u.ext3_sb.s_blocks_per_group)
1458 -# define EXT3_DESC_PER_BLOCK(s)                ((s)->u.ext3_sb.s_desc_per_block)
1459 -# define EXT3_INODES_PER_GROUP(s)      ((s)->u.ext3_sb.s_inodes_per_group)
1460 -# define EXT3_DESC_PER_BLOCK_BITS(s)   ((s)->u.ext3_sb.s_desc_per_block_bits)
1461 +# define EXT3_DESC_PER_BLOCK(s)                (EXT3_SB(s)->s_desc_per_block)
1462 +# define EXT3_DESC_PER_BLOCK_BITS(s)   (EXT3_SB(s)->s_desc_per_block_bits)
1463  #else
1464 -# define EXT3_BLOCKS_PER_GROUP(s)      ((s)->s_blocks_per_group)
1465  # define EXT3_DESC_PER_BLOCK(s)                (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc))
1466 -# define EXT3_INODES_PER_GROUP(s)      ((s)->s_inodes_per_group)
1467  #endif
1468  
1469  /*
1470 @@ -326,7 +328,7 @@
1471  #ifndef _LINUX_EXT2_FS_H
1472  #define clear_opt(o, opt)              o &= ~EXT3_MOUNT_##opt
1473  #define set_opt(o, opt)                        o |= EXT3_MOUNT_##opt
1474 -#define test_opt(sb, opt)              ((sb)->u.ext3_sb.s_mount_opt & \
1475 +#define test_opt(sb, opt)              (EXT3_SB(sb)->s_mount_opt & \
1476                                          EXT3_MOUNT_##opt)
1477  #else
1478  #define EXT2_MOUNT_NOLOAD              EXT3_MOUNT_NOLOAD
1479 @@ -427,17 +429,11 @@
1480         __u32   s_reserved[192];        /* Padding to the end of the block */
1481  };
1482  
1483 -#ifdef __KERNEL__
1484 -#define EXT3_SB(sb)    (&((sb)->u.ext3_sb))
1485 -#define EXT3_I(inode)  (&((inode)->u.ext3_i))
1486 -#else
1487 -/* Assume that user mode programs are passing in an ext3fs superblock, not
1488 - * a kernel struct super_block.  This will allow us to call the feature-test
1489 - * macros from user land. */
1490 -#define EXT3_SB(sb)    (sb)
1491 -#endif
1492 -
1493 -#define NEXT_ORPHAN(inode) (inode)->u.ext3_i.i_dtime
1494 +#define NEXT_ORPHAN(inode) EXT3_I(inode)->i_dtime
1495 +static inline struct inode *orphan_list_entry(struct list_head *l)
1496 +{
1497 +       return list_entry(l, struct inode, u.ext3_i.i_orphan);
1498 +}
1499  
1500  /*
1501   * Codes for operating systems
1502 Index: linux-2.4.21-chaos/include/linux/ext3_jbd.h
1503 ===================================================================
1504 --- linux-2.4.21-chaos.orig/include/linux/ext3_jbd.h    2003-12-12 11:36:14.000000000 +0300
1505 +++ linux-2.4.21-chaos/include/linux/ext3_jbd.h 2003-12-12 12:50:34.000000000 +0300
1506 @@ -285,7 +285,7 @@
1507                 return 1;
1508         if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA)
1509                 return 1;
1510 -       if (inode->u.ext3_i.i_flags & EXT3_JOURNAL_DATA_FL)
1511 +       if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
1512                 return 1;
1513         return 0;
1514  }