Index: linux-2.4.21-chaos/fs/ext3/balloc.c =================================================================== --- linux-2.4.21-chaos.orig/fs/ext3/balloc.c 2003-07-15 02:09:35.000000000 +0400 +++ linux-2.4.21-chaos/fs/ext3/balloc.c 2003-12-12 12:50:34.000000000 +0300 @@ -46,18 +46,18 @@ unsigned long desc; struct ext3_group_desc * gdp; - if (block_group >= sb->u.ext3_sb.s_groups_count) { + if (block_group >= EXT3_SB(sb)->s_groups_count) { ext3_error (sb, "ext3_get_group_desc", "block_group >= groups_count - " "block_group = %d, groups_count = %lu", - block_group, sb->u.ext3_sb.s_groups_count); + block_group, EXT3_SB(sb)->s_groups_count); return NULL; } group_desc = block_group / EXT3_DESC_PER_BLOCK(sb); desc = block_group % EXT3_DESC_PER_BLOCK(sb); - if (!sb->u.ext3_sb.s_group_desc[group_desc]) { + if (!EXT3_SB(sb)->s_group_desc[group_desc]) { ext3_error (sb, "ext3_get_group_desc", "Group descriptor not loaded - " "block_group = %d, group_desc = %lu, desc = %lu", @@ -66,9 +66,9 @@ } gdp = (struct ext3_group_desc *) - sb->u.ext3_sb.s_group_desc[group_desc]->b_data; + EXT3_SB(sb)->s_group_desc[group_desc]->b_data; if (bh) - *bh = sb->u.ext3_sb.s_group_desc[group_desc]; + *bh = EXT3_SB(sb)->s_group_desc[group_desc]; return gdp + desc; } @@ -104,8 +104,8 @@ * this group. The IO will be retried next time. */ error_out: - sb->u.ext3_sb.s_block_bitmap_number[bitmap_nr] = block_group; - sb->u.ext3_sb.s_block_bitmap[bitmap_nr] = bh; + EXT3_SB(sb)->s_block_bitmap_number[bitmap_nr] = block_group; + EXT3_SB(sb)->s_block_bitmap[bitmap_nr] = bh; return retval; } @@ -128,16 +128,17 @@ int i, j, retval = 0; unsigned long block_bitmap_number; struct buffer_head * block_bitmap; + struct ext3_sb_info *sbi = EXT3_SB(sb); - if (block_group >= sb->u.ext3_sb.s_groups_count) + if (block_group >= sbi->s_groups_count) ext3_panic (sb, "load_block_bitmap", "block_group >= groups_count - " "block_group = %d, groups_count = %lu", - block_group, sb->u.ext3_sb.s_groups_count); + block_group, EXT3_SB(sb)->s_groups_count); - if (sb->u.ext3_sb.s_groups_count <= EXT3_MAX_GROUP_LOADED) { - if (sb->u.ext3_sb.s_block_bitmap[block_group]) { - if (sb->u.ext3_sb.s_block_bitmap_number[block_group] == + if (sbi->s_groups_count <= EXT3_MAX_GROUP_LOADED) { + if (sbi->s_block_bitmap[block_group]) { + if (sbi->s_block_bitmap_number[block_group] == block_group) return block_group; ext3_error (sb, "__load_block_bitmap", @@ -149,21 +150,20 @@ return block_group; } - for (i = 0; i < sb->u.ext3_sb.s_loaded_block_bitmaps && - sb->u.ext3_sb.s_block_bitmap_number[i] != block_group; i++) + for (i = 0; i < sbi->s_loaded_block_bitmaps && + sbi->s_block_bitmap_number[i] != block_group; i++) ; - if (i < sb->u.ext3_sb.s_loaded_block_bitmaps && - sb->u.ext3_sb.s_block_bitmap_number[i] == block_group) { - block_bitmap_number = sb->u.ext3_sb.s_block_bitmap_number[i]; - block_bitmap = sb->u.ext3_sb.s_block_bitmap[i]; + if (i < sbi->s_loaded_block_bitmaps && + sbi->s_block_bitmap_number[i] == block_group) { + block_bitmap_number = sbi->s_block_bitmap_number[i]; + block_bitmap = sbi->s_block_bitmap[i]; for (j = i; j > 0; j--) { - sb->u.ext3_sb.s_block_bitmap_number[j] = - sb->u.ext3_sb.s_block_bitmap_number[j - 1]; - sb->u.ext3_sb.s_block_bitmap[j] = - sb->u.ext3_sb.s_block_bitmap[j - 1]; + sbi->s_block_bitmap_number[j] = + sbi->s_block_bitmap_number[j - 1]; + sbi->s_block_bitmap[j] = sbi->s_block_bitmap[j - 1]; } - sb->u.ext3_sb.s_block_bitmap_number[0] = block_bitmap_number; - sb->u.ext3_sb.s_block_bitmap[0] = block_bitmap; + sbi->s_block_bitmap_number[0] = block_bitmap_number; + sbi->s_block_bitmap[0] = block_bitmap; /* * There's still one special case here --- if block_bitmap == 0 @@ -173,17 +173,14 @@ if (!block_bitmap) retval = read_block_bitmap (sb, block_group, 0); } else { - if (sb->u.ext3_sb.s_loaded_block_bitmapsu.ext3_sb.s_loaded_block_bitmaps++; + if (sbi->s_loaded_block_bitmapss_loaded_block_bitmaps++; else - brelse (sb->u.ext3_sb.s_block_bitmap - [EXT3_MAX_GROUP_LOADED - 1]); - for (j = sb->u.ext3_sb.s_loaded_block_bitmaps - 1; - j > 0; j--) { - sb->u.ext3_sb.s_block_bitmap_number[j] = - sb->u.ext3_sb.s_block_bitmap_number[j - 1]; - sb->u.ext3_sb.s_block_bitmap[j] = - sb->u.ext3_sb.s_block_bitmap[j - 1]; + brelse(sbi->s_block_bitmap[EXT3_MAX_GROUP_LOADED - 1]); + for (j = sbi->s_loaded_block_bitmaps - 1; j > 0; j--) { + sbi->s_block_bitmap_number[j] = + sbi->s_block_bitmap_number[j - 1]; + sbi->s_block_bitmap[j] = sbi->s_block_bitmap[j - 1]; } retval = read_block_bitmap (sb, block_group, 0); } @@ -206,24 +203,25 @@ static inline int load_block_bitmap (struct super_block * sb, unsigned int block_group) { + struct ext3_sb_info *sbi = EXT3_SB(sb); int slot; - + /* * Do the lookup for the slot. First of all, check if we're asking * for the same slot as last time, and did we succeed that last time? */ - if (sb->u.ext3_sb.s_loaded_block_bitmaps > 0 && - sb->u.ext3_sb.s_block_bitmap_number[0] == block_group && - sb->u.ext3_sb.s_block_bitmap[0]) { + if (sbi->s_loaded_block_bitmaps > 0 && + sbi->s_block_bitmap_number[0] == block_group && + sbi->s_block_bitmap[0]) { return 0; } /* * Or can we do a fast lookup based on a loaded group on a filesystem * small enough to be mapped directly into the superblock? */ - else if (sb->u.ext3_sb.s_groups_count <= EXT3_MAX_GROUP_LOADED && - sb->u.ext3_sb.s_block_bitmap_number[block_group]==block_group - && sb->u.ext3_sb.s_block_bitmap[block_group]) { + else if (sbi->s_groups_count <= EXT3_MAX_GROUP_LOADED && + sbi->s_block_bitmap_number[block_group] == block_group + && sbi->s_block_bitmap[block_group]) { slot = block_group; } /* @@ -243,7 +241,7 @@ * If it's a valid slot, we may still have cached a previous IO error, * in which case the bh in the superblock cache will be zero. */ - if (!sb->u.ext3_sb.s_block_bitmap[slot]) + if (!sbi->s_block_bitmap[slot]) return -EIO; /* @@ -275,7 +273,7 @@ return; } lock_super (sb); - es = sb->u.ext3_sb.s_es; + es = EXT3_SB(sb)->s_es; if (block < le32_to_cpu(es->s_first_data_block) || block + count < block || (block + count) > le32_to_cpu(es->s_blocks_count)) { @@ -305,7 +303,7 @@ if (bitmap_nr < 0) goto error_return; - bitmap_bh = sb->u.ext3_sb.s_block_bitmap[bitmap_nr]; + bitmap_bh = EXT3_SB(sb)->s_block_bitmap[bitmap_nr]; gdp = ext3_get_group_desc (sb, block_group, &gd_bh); if (!gdp) goto error_return; @@ -330,8 +328,8 @@ if (err) goto error_return; - BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access"); - err = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); + BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access"); + err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh); if (err) goto error_return; @@ -409,8 +407,8 @@ if (!err) err = ret; /* And the superblock */ - BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "dirtied superblock"); - ret = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); + BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "dirtied superblock"); + ret = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); if (!err) err = ret; if (overflow && !err) { @@ -563,12 +561,12 @@ } lock_super (sb); - es = sb->u.ext3_sb.s_es; + es = EXT3_SB(sb)->s_es; if (le32_to_cpu(es->s_free_blocks_count) <= le32_to_cpu(es->s_r_blocks_count) && - ((sb->u.ext3_sb.s_resuid != current->fsuid) && - (sb->u.ext3_sb.s_resgid == 0 || - !in_group_p (sb->u.ext3_sb.s_resgid)) && + ((EXT3_SB(sb)->s_resuid != current->fsuid) && + (EXT3_SB(sb)->s_resgid == 0 || + !in_group_p (EXT3_SB(sb)->s_resgid)) && !capable(CAP_SYS_RESOURCE))) goto out; @@ -598,7 +596,7 @@ if (bitmap_nr < 0) goto io_error; - bh = sb->u.ext3_sb.s_block_bitmap[bitmap_nr]; + bh = EXT3_SB(sb)->s_block_bitmap[bitmap_nr]; ext3_debug ("goal is at %d:%d.\n", i, j); @@ -621,9 +619,9 @@ * Now search the rest of the groups. We assume that * i and gdp correctly point to the last group visited. */ - for (k = 0; k < sb->u.ext3_sb.s_groups_count; k++) { + for (k = 0; k < EXT3_SB(sb)->s_groups_count; k++) { i++; - if (i >= sb->u.ext3_sb.s_groups_count) + if (i >= EXT3_SB(sb)->s_groups_count) i = 0; gdp = ext3_get_group_desc (sb, i, &bh2); if (!gdp) { @@ -635,7 +633,7 @@ if (bitmap_nr < 0) goto io_error; - bh = sb->u.ext3_sb.s_block_bitmap[bitmap_nr]; + bh = EXT3_SB(sb)->s_block_bitmap[bitmap_nr]; j = find_next_usable_block(-1, bh, EXT3_BLOCKS_PER_GROUP(sb)); if (j >= 0) @@ -673,8 +671,8 @@ fatal = ext3_journal_get_write_access(handle, bh2); if (fatal) goto out; - BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access"); - fatal = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); + BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access"); + fatal = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh); if (fatal) goto out; tmp = j + i * EXT3_BLOCKS_PER_GROUP(sb) @@ -807,7 +805,7 @@ if (!fatal) fatal = err; BUFFER_TRACE(bh, "journal_dirty_metadata for superblock"); - err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); + err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); if (!fatal) fatal = err; sb->s_dirt = 1; @@ -845,11 +843,11 @@ int i; lock_super (sb); - es = sb->u.ext3_sb.s_es; + es = EXT3_SB(sb)->s_es; desc_count = 0; bitmap_count = 0; gdp = NULL; - for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) { + for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) { gdp = ext3_get_group_desc (sb, i, NULL); if (!gdp) continue; @@ -858,7 +856,7 @@ if (bitmap_nr < 0) continue; - x = ext3_count_free (sb->u.ext3_sb.s_block_bitmap[bitmap_nr], + x = ext3_count_free (EXT3_SB(sb)->s_block_bitmap[bitmap_nr], sb->s_blocksize); printk ("group %d: stored = %d, counted = %lu\n", i, le16_to_cpu(gdp->bg_free_blocks_count), x); @@ -869,7 +867,7 @@ unlock_super (sb); return bitmap_count; #else - return le32_to_cpu(sb->u.ext3_sb.s_es->s_free_blocks_count); + return le32_to_cpu(EXT3_SB(sb)->s_es->s_free_blocks_count); #endif } @@ -878,7 +876,7 @@ unsigned char * map) { return ext3_test_bit ((block - - le32_to_cpu(sb->u.ext3_sb.s_es->s_first_data_block)) % + le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block)) % EXT3_BLOCKS_PER_GROUP(sb), map); } @@ -946,11 +944,11 @@ struct ext3_group_desc * gdp; int i; - es = sb->u.ext3_sb.s_es; + es = EXT3_SB(sb)->s_es; desc_count = 0; bitmap_count = 0; gdp = NULL; - for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) { + for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) { gdp = ext3_get_group_desc (sb, i, NULL); if (!gdp) continue; @@ -984,7 +982,7 @@ "Inode bitmap for group %d is marked free", i); - for (j = 0; j < sb->u.ext3_sb.s_itb_per_group; j++) + for (j = 0; j < EXT3_SB(sb)->s_itb_per_group; j++) if (!block_in_use (le32_to_cpu(gdp->bg_inode_table) + j, sb, bh->b_data)) ext3_error (sb, "ext3_check_blocks_bitmap", Index: linux-2.4.21-chaos/fs/ext3/dir.c =================================================================== --- linux-2.4.21-chaos.orig/fs/ext3/dir.c 2003-12-12 11:36:13.000000000 +0300 +++ linux-2.4.21-chaos/fs/ext3/dir.c 2003-12-12 12:50:34.000000000 +0300 @@ -67,7 +67,7 @@ else if (((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize) error_msg = "directory entry across blocks"; else if (le32_to_cpu(de->inode) > - le32_to_cpu(dir->i_sb->u.ext3_sb.s_es->s_inodes_count)) + le32_to_cpu(EXT3_SB(dir->i_sb)->s_es->s_inodes_count)) error_msg = "inode out of bounds"; if (error_msg != NULL) Index: linux-2.4.21-chaos/fs/ext3/ialloc.c =================================================================== --- linux-2.4.21-chaos.orig/fs/ext3/ialloc.c 2003-09-19 03:49:54.000000000 +0400 +++ linux-2.4.21-chaos/fs/ext3/ialloc.c 2003-12-12 12:53:11.000000000 +0300 @@ -75,8 +75,8 @@ * this group. The IO will be retried next time. */ error_out: - sb->u.ext3_sb.s_inode_bitmap_number[bitmap_nr] = block_group; - sb->u.ext3_sb.s_inode_bitmap[bitmap_nr] = bh; + EXT3_SB(sb)->s_inode_bitmap_number[bitmap_nr] = block_group; + EXT3_SB(sb)->s_inode_bitmap[bitmap_nr] = bh; return retval; } @@ -228,7 +228,7 @@ clear_inode (inode); lock_super (sb); - es = sb->u.ext3_sb.s_es; + es = EXT3_SB(sb)->s_es; if (ino < EXT3_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) { ext3_error (sb, "ext3_free_inode", "reserved or nonexistent inode %lu", ino); @@ -240,7 +240,7 @@ if (bitmap_nr < 0) goto error_return; - bh = sb->u.ext3_sb.s_inode_bitmap[bitmap_nr]; + bh = EXT3_SB(sb)->s_inode_bitmap[bitmap_nr]; BUFFER_TRACE(bh, "get_write_access"); fatal = ext3_journal_get_write_access(handle, bh); @@ -258,8 +258,8 @@ fatal = ext3_journal_get_write_access(handle, bh2); if (fatal) goto error_return; - BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get write access"); - fatal = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); + BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get write access"); + fatal = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh); if (fatal) goto error_return; if (gdp) { @@ -274,9 +274,9 @@ if (!fatal) fatal = err; es->s_free_inodes_count = cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) + 1); - BUFFER_TRACE(sb->u.ext3_sb.s_sbh, + BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "call ext3_journal_dirty_metadata"); - err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); + err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); if (!fatal) fatal = err; } BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata"); @@ -307,6 +307,8 @@ int i, j, avefreei; struct inode * inode; int bitmap_nr; + struct ext3_inode_info *ei; + struct ext3_sb_info *sbi; struct ext3_group_desc * gdp; struct ext3_group_desc * tmp; struct ext3_super_block * es; @@ -320,19 +322,21 @@ inode = new_inode(sb); if (!inode) return ERR_PTR(-ENOMEM); - init_rwsem(&inode->u.ext3_i.truncate_sem); + sbi = EXT3_SB(sb); + ei = EXT3_I(inode); + init_rwsem(&ei->truncate_sem); lock_super (sb); - es = sb->u.ext3_sb.s_es; + es = sbi->s_es; repeat: gdp = NULL; i = 0; if (S_ISDIR(mode)) { avefreei = le32_to_cpu(es->s_free_inodes_count) / - sb->u.ext3_sb.s_groups_count; + sbi->s_groups_count; if (!gdp) { - for (j = 0; j < sb->u.ext3_sb.s_groups_count; j++) { + for (j = 0; j < sbi->s_groups_count; j++) { struct buffer_head *temp_buffer; tmp = ext3_get_group_desc (sb, j, &temp_buffer); if (tmp && @@ -352,7 +356,7 @@ /* * Try to place the inode in its parent directory */ - i = dir->u.ext3_i.i_block_group; + i = EXT3_I(dir)->i_block_group; tmp = ext3_get_group_desc (sb, i, &bh2); if (tmp && le16_to_cpu(tmp->bg_free_inodes_count)) gdp = tmp; @@ -362,10 +366,10 @@ * Use a quadratic hash to find a group with a * free inode */ - for (j = 1; j < sb->u.ext3_sb.s_groups_count; j <<= 1) { + for (j = 1; j < sbi->s_groups_count; j <<= 1) { i += j; - if (i >= sb->u.ext3_sb.s_groups_count) - i -= sb->u.ext3_sb.s_groups_count; + if (i >= sbi->s_groups_count) + i -= sbi->s_groups_count; tmp = ext3_get_group_desc (sb, i, &bh2); if (tmp && le16_to_cpu(tmp->bg_free_inodes_count)) { @@ -378,9 +382,9 @@ /* * That failed: try linear search for a free inode */ - i = dir->u.ext3_i.i_block_group + 1; - for (j = 2; j < sb->u.ext3_sb.s_groups_count; j++) { - if (++i >= sb->u.ext3_sb.s_groups_count) + i = EXT3_I(dir)->i_block_group + 1; + for (j = 2; j < sbi->s_groups_count; j++) { + if (++i >= sbi->s_groups_count) i = 0; tmp = ext3_get_group_desc (sb, i, &bh2); if (tmp && @@ -401,11 +405,11 @@ if (bitmap_nr < 0) goto fail; - bh = sb->u.ext3_sb.s_inode_bitmap[bitmap_nr]; + bh = sbi->s_inode_bitmap[bitmap_nr]; if ((j = ext3_find_first_zero_bit ((unsigned long *) bh->b_data, - EXT3_INODES_PER_GROUP(sb))) < - EXT3_INODES_PER_GROUP(sb)) { + sbi->s_inodes_per_group)) < + sbi->s_inodes_per_group) { BUFFER_TRACE(bh, "get_write_access"); err = ext3_journal_get_write_access(handle, bh); if (err) goto fail; @@ -459,13 +463,13 @@ err = ext3_journal_dirty_metadata(handle, bh2); if (err) goto fail; - BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access"); - err = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); + BUFFER_TRACE(sbi->s_sbh, "get_write_access"); + err = ext3_journal_get_write_access(handle, sbi->s_sbh); if (err) goto fail; es->s_free_inodes_count = cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) - 1); - BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "call ext3_journal_dirty_metadata"); - err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); + BUFFER_TRACE(sbi->s_sbh, "call ext3_journal_dirty_metadata"); + err = ext3_journal_dirty_metadata(handle, sbi->s_sbh); sb->s_dirt = 1; if (err) goto fail; @@ -485,35 +489,35 @@ inode->i_blksize = PAGE_SIZE; inode->i_blocks = 0; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; - inode->u.ext3_i.i_flags = dir->u.ext3_i.i_flags & ~EXT3_INDEX_FL; + ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL; if (S_ISLNK(mode)) - inode->u.ext3_i.i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL); + ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL); #ifdef EXT3_FRAGMENTS - inode->u.ext3_i.i_faddr = 0; - inode->u.ext3_i.i_frag_no = 0; - inode->u.ext3_i.i_frag_size = 0; + ei->i_faddr = 0; + ei->i_frag_no = 0; + ei->i_frag_size = 0; #endif - inode->u.ext3_i.i_file_acl = 0; - inode->u.ext3_i.i_dir_acl = 0; - inode->u.ext3_i.i_dtime = 0; - INIT_LIST_HEAD(&inode->u.ext3_i.i_orphan); + ei->i_file_acl = 0; + ei->i_dir_acl = 0; + ei->i_dtime = 0; + INIT_LIST_HEAD(&ei->i_orphan); #ifdef EXT3_PREALLOCATE - inode->u.ext3_i.i_prealloc_count = 0; + ei->i_prealloc_count = 0; #endif - inode->u.ext3_i.i_block_group = i; + ei->i_block_group = i; ext3_set_inode_flags(inode); if (IS_SYNC(inode)) handle->h_sync = 1; insert_inode_hash(inode); - inode->i_generation = sb->u.ext3_sb.s_next_generation++; + inode->i_generation = sbi->s_next_generation++; - inode->u.ext3_i.i_state = EXT3_STATE_NEW; + ei->i_state = EXT3_STATE_NEW; err = ext3_mark_inode_dirty(handle, inode); if (err) goto fail; #ifdef CONFIG_EXT3_FS_XATTR - init_rwsem(&inode->u.ext3_i.xattr_sem); + init_rwsem(&EXT3_I(inode)->xattr_sem); #endif unlock_super (sb); @@ -600,19 +604,19 @@ unsigned long ext3_count_free_inodes (struct super_block * sb) { + struct ext3_sb_info *sbi = EXT3_SB(sb); + struct ext3_super_block *es = sbi->s_es; #ifdef EXT3FS_DEBUG - struct ext3_super_block * es; unsigned long desc_count, bitmap_count, x; int bitmap_nr; struct ext3_group_desc * gdp; int i; lock_super (sb); - es = sb->u.ext3_sb.s_es; desc_count = 0; bitmap_count = 0; gdp = NULL; - for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) { + for (i = 0; i < sbi->s_groups_count; i++) { gdp = ext3_get_group_desc (sb, i, NULL); if (!gdp) continue; @@ -621,8 +625,8 @@ if (bitmap_nr < 0) continue; - x = ext3_count_free (sb->u.ext3_sb.s_inode_bitmap[bitmap_nr], - EXT3_INODES_PER_GROUP(sb) / 8); + x = ext3_count_free(sbi->s_inode_bitmap[bitmap_nr], + sbi->s_inodes_per_group / 8); printk ("group %d: stored = %d, counted = %lu\n", i, le16_to_cpu(gdp->bg_free_inodes_count), x); bitmap_count += x; @@ -632,7 +636,7 @@ unlock_super (sb); return desc_count; #else - return le32_to_cpu(sb->u.ext3_sb.s_es->s_free_inodes_count); + return le32_to_cpu(es->s_free_inodes_count); #endif } @@ -641,16 +645,18 @@ void ext3_check_inodes_bitmap (struct super_block * sb) { struct ext3_super_block * es; + struct ext3_sb_info *sbi; unsigned long desc_count, bitmap_count, x; int bitmap_nr; struct ext3_group_desc * gdp; int i; - es = sb->u.ext3_sb.s_es; + sbi = EXT3_SB(sb); + es = sbi->s_es; desc_count = 0; bitmap_count = 0; gdp = NULL; - for (i = 0; i < sb->u.ext3_sb.s_groups_count; i++) { + for (i = 0; i < sbi->s_groups_count; i++) { gdp = ext3_get_group_desc (sb, i, NULL); if (!gdp) continue; @@ -659,7 +665,7 @@ if (bitmap_nr < 0) continue; - x = ext3_count_free (sb->u.ext3_sb.s_inode_bitmap[bitmap_nr], + x = ext3_count_free (sbi->s_inode_bitmap[bitmap_nr], EXT3_INODES_PER_GROUP(sb) / 8); if (le16_to_cpu(gdp->bg_free_inodes_count) != x) ext3_error (sb, "ext3_check_inodes_bitmap", Index: linux-2.4.21-chaos/fs/ext3/inode.c =================================================================== --- linux-2.4.21-chaos.orig/fs/ext3/inode.c 2003-12-05 07:55:47.000000000 +0300 +++ linux-2.4.21-chaos/fs/ext3/inode.c 2003-12-12 12:55:41.000000000 +0300 @@ -47,7 +47,7 @@ */ static inline int ext3_inode_is_fast_symlink(struct inode *inode) { - int ea_blocks = inode->u.ext3_i.i_file_acl ? + int ea_blocks = EXT3_I(inode)->i_file_acl ? (inode->i_sb->s_blocksize >> 9) : 0; return (S_ISLNK(inode->i_mode) && @@ -224,7 +224,7 @@ * (Well, we could do this if we need to, but heck - it works) */ ext3_orphan_del(handle, inode); - inode->u.ext3_i.i_dtime = CURRENT_TIME; + EXT3_I(inode)->i_dtime = CURRENT_TIME; /* * One subtle ordering requirement: if anything has gone wrong @@ -248,13 +248,14 @@ void ext3_discard_prealloc (struct inode * inode) { #ifdef EXT3_PREALLOCATE + struct ext3_inode_info *ei = EXT3_I(inode); lock_kernel(); /* Writer: ->i_prealloc* */ - if (inode->u.ext3_i.i_prealloc_count) { - unsigned short total = inode->u.ext3_i.i_prealloc_count; - unsigned long block = inode->u.ext3_i.i_prealloc_block; - inode->u.ext3_i.i_prealloc_count = 0; - inode->u.ext3_i.i_prealloc_block = 0; + if (ei->i_prealloc_count) { + unsigned short total = ei->i_prealloc_count; + unsigned long block = ei->i_prealloc_block; + ei->i_prealloc_count = 0; + ei->i_prealloc_block = 0; /* Writer: end */ ext3_free_blocks (inode, block, total); } @@ -271,13 +272,15 @@ unsigned long result; #ifdef EXT3_PREALLOCATE + struct ext3_inode_info *ei = EXT3_I(inode); + /* Writer: ->i_prealloc* */ - if (inode->u.ext3_i.i_prealloc_count && - (goal == inode->u.ext3_i.i_prealloc_block || - goal + 1 == inode->u.ext3_i.i_prealloc_block)) + if (ei->i_prealloc_count && + (goal == ei->i_prealloc_block || + goal + 1 == ei->i_prealloc_block)) { - result = inode->u.ext3_i.i_prealloc_block++; - inode->u.ext3_i.i_prealloc_count--; + result = ei->i_prealloc_block++; + ei->i_prealloc_count--; /* Writer: end */ ext3_debug ("preallocation hit (%lu/%lu).\n", ++alloc_hits, ++alloc_attempts); @@ -287,8 +290,8 @@ alloc_hits, ++alloc_attempts); if (S_ISREG(inode->i_mode)) result = ext3_new_block (inode, goal, - &inode->u.ext3_i.i_prealloc_count, - &inode->u.ext3_i.i_prealloc_block, err); + &ei->i_prealloc_count, + &ei->i_prealloc_block, err); else result = ext3_new_block (inode, goal, 0, 0, err); /* @@ -422,7 +425,7 @@ *err = 0; /* i_data is not going away, no lock needed */ - add_chain (chain, NULL, inode->u.ext3_i.i_data + *offsets); + add_chain (chain, NULL, EXT3_I(inode)->i_data + *offsets); if (!p->key) goto no_block; while (--depth) { @@ -466,7 +469,8 @@ static inline unsigned long ext3_find_near(struct inode *inode, Indirect *ind) { - u32 *start = ind->bh ? (u32*) ind->bh->b_data : inode->u.ext3_i.i_data; + struct ext3_inode_info *ei = EXT3_I(inode); + u32 *start = ind->bh ? (u32*) ind->bh->b_data : ei->i_data; u32 *p; /* Try to find previous block */ @@ -482,9 +486,8 @@ * It is going to be refered from inode itself? OK, just put it into * the same cylinder group then. */ - return (inode->u.ext3_i.i_block_group * - EXT3_BLOCKS_PER_GROUP(inode->i_sb)) + - le32_to_cpu(inode->i_sb->u.ext3_sb.s_es->s_first_data_block); + return (ei->i_block_group * EXT3_BLOCKS_PER_GROUP(inode->i_sb)) + + le32_to_cpu(EXT3_SB(inode->i_sb)->s_es->s_first_data_block); } /** @@ -503,14 +506,15 @@ static int ext3_find_goal(struct inode *inode, long block, Indirect chain[4], Indirect *partial, unsigned long *goal) { + struct ext3_inode_info *ei = EXT3_I(inode); /* Writer: ->i_next_alloc* */ - if (block == inode->u.ext3_i.i_next_alloc_block + 1) { - inode->u.ext3_i.i_next_alloc_block++; - inode->u.ext3_i.i_next_alloc_goal++; + if (block == ei->i_next_alloc_block + 1) { + ei->i_next_alloc_block++; + ei->i_next_alloc_goal++; } #ifdef SEARCH_FROM_ZERO - inode->u.ext3_i.i_next_alloc_block = 0; - inode->u.ext3_i.i_next_alloc_goal = 0; + ei->i_next_alloc_block = 0; + ei->i_next_alloc_goal = 0; #endif /* Writer: end */ /* Reader: pointers, ->i_next_alloc* */ @@ -519,8 +523,8 @@ * try the heuristic for sequential allocation, * failing that at least try to get decent locality. */ - if (block == inode->u.ext3_i.i_next_alloc_block) - *goal = inode->u.ext3_i.i_next_alloc_goal; + if (block == ei->i_next_alloc_block) + *goal = ei->i_next_alloc_goal; if (!*goal) *goal = ext3_find_near(inode, partial); #ifdef SEARCH_FROM_ZERO @@ -646,6 +650,7 @@ { int i; int err = 0; + struct ext3_inode_info *ei = EXT3_I(inode); /* * If we're splicing into a [td]indirect block (as opposed to the @@ -668,11 +673,11 @@ /* That's it */ *where->p = where->key; - inode->u.ext3_i.i_next_alloc_block = block; - inode->u.ext3_i.i_next_alloc_goal = le32_to_cpu(where[num-1].key); + ei->i_next_alloc_block = block; + ei->i_next_alloc_goal = le32_to_cpu(where[num-1].key); #ifdef SEARCH_FROM_ZERO - inode->u.ext3_i.i_next_alloc_block = 0; - inode->u.ext3_i.i_next_alloc_goal = 0; + ei->i_next_alloc_block = 0; + ei->i_next_alloc_goal = 0; #endif /* Writer: end */ @@ -756,6 +761,7 @@ unsigned long goal; int left; int depth = ext3_block_to_path(inode, iblock, offsets); + struct ext3_inode_info *ei = EXT3_I(inode); loff_t new_size; J_ASSERT(handle != NULL || create == 0); @@ -809,7 +815,7 @@ /* * Block out ext3_truncate while we alter the tree */ - down_read(&inode->u.ext3_i.truncate_sem); + down_read(&ei->truncate_sem); err = ext3_alloc_branch(handle, inode, left, goal, offsets+(partial-chain), partial); @@ -821,7 +827,7 @@ if (!err) err = ext3_splice_branch(handle, inode, iblock, chain, partial, left); - up_read(&inode->u.ext3_i.truncate_sem); + up_read(&ei->truncate_sem); if (err == -EAGAIN) goto changed; if (err) @@ -981,7 +987,7 @@ struct buffer_head *tmp_bh; for (i = 1; - inode->u.ext3_i.i_prealloc_count && + EXT3_I(inode)->i_prealloc_count && i < EXT3_SB(inode->i_sb)->s_es->s_prealloc_dir_blocks; i++) { /* @@ -1199,8 +1205,8 @@ kunmap(page); } } - if (inode->i_size > inode->u.ext3_i.i_disksize) { - inode->u.ext3_i.i_disksize = inode->i_size; + if (inode->i_size > EXT3_I(inode)->i_disksize) { + EXT3_I(inode)->i_disksize = inode->i_size; ret2 = ext3_mark_inode_dirty(handle, inode); if (!ret) ret = ret2; @@ -2011,7 +2017,8 @@ void ext3_truncate(struct inode * inode) { handle_t *handle; - u32 *i_data = inode->u.ext3_i.i_data; + struct ext3_inode_info *ei = EXT3_I(inode); + u32 *i_data = EXT3_I(inode)->i_data; int addr_per_block = EXT3_ADDR_PER_BLOCK(inode->i_sb); int offsets[4]; Indirect chain[4]; @@ -2072,13 +2079,13 @@ * on-disk inode. We do this via i_disksize, which is the value which * ext3 *really* writes onto the disk inode. */ - inode->u.ext3_i.i_disksize = inode->i_size; + ei->i_disksize = inode->i_size; /* * From here we block out all ext3_get_block() callers who want to * modify the block allocation tree. */ - down_write(&inode->u.ext3_i.truncate_sem); + down_write(&ei->truncate_sem); if (n == 1) { /* direct blocks */ ext3_free_data(handle, inode, NULL, i_data+offsets[0], @@ -2142,7 +2149,7 @@ case EXT3_TIND_BLOCK: ; } - up_write(&inode->u.ext3_i.truncate_sem); + up_write(&ei->truncate_sem); inode->i_mtime = inode->i_ctime = CURRENT_TIME; ext3_mark_inode_dirty(handle, inode); @@ -2179,6 +2186,8 @@ int ext3_get_inode_loc (struct inode *inode, struct ext3_iloc *iloc) { + struct super_block *sb = inode->i_sb; + struct ext3_sb_info *sbi = EXT3_SB(sb); struct buffer_head *bh = 0; unsigned long block; unsigned long block_group; @@ -2189,25 +2198,21 @@ if ((inode->i_ino != EXT3_ROOT_INO && inode->i_ino != EXT3_JOURNAL_INO && - inode->i_ino < EXT3_FIRST_INO(inode->i_sb)) || - inode->i_ino > le32_to_cpu( - inode->i_sb->u.ext3_sb.s_es->s_inodes_count)) { - ext3_error (inode->i_sb, "ext3_get_inode_loc", - "bad inode number: %lu", inode->i_ino); + inode->i_ino < EXT3_FIRST_INO(sb)) || + inode->i_ino > le32_to_cpu(sbi->s_es->s_inodes_count)) { + ext3_error (sb, __FUNCTION__, "bad inode #%lu", inode->i_ino); goto bad_inode; } - block_group = (inode->i_ino - 1) / EXT3_INODES_PER_GROUP(inode->i_sb); - if (block_group >= inode->i_sb->u.ext3_sb.s_groups_count) { - ext3_error (inode->i_sb, "ext3_get_inode_loc", - "group >= groups count"); + block_group = (inode->i_ino - 1) / sbi->s_inodes_per_group; + if (block_group >= sbi->s_groups_count) { + ext3_error(sb, __FUNCTION__, "group >= groups count"); goto bad_inode; } - group_desc = block_group >> EXT3_DESC_PER_BLOCK_BITS(inode->i_sb); - desc = block_group & (EXT3_DESC_PER_BLOCK(inode->i_sb) - 1); - bh = inode->i_sb->u.ext3_sb.s_group_desc[group_desc]; + group_desc = block_group >> sbi->s_desc_per_block_bits; + desc = block_group & (sbi->s_desc_per_block - 1); + bh = sbi->s_group_desc[group_desc]; if (!bh) { - ext3_error (inode->i_sb, "ext3_get_inode_loc", - "Descriptor not loaded"); + ext3_error(sb, __FUNCTION__, "Descriptor not loaded"); goto bad_inode; } @@ -2215,17 +2220,17 @@ /* * Figure out the offset within the block group inode table */ - offset = ((inode->i_ino - 1) % EXT3_INODES_PER_GROUP(inode->i_sb)) * - EXT3_INODE_SIZE(inode->i_sb); + offset = ((inode->i_ino - 1) % sbi->s_inodes_per_group) * + sbi->s_inode_size; block = le32_to_cpu(gdp[desc].bg_inode_table) + - (offset >> EXT3_BLOCK_SIZE_BITS(inode->i_sb)); - if (!(bh = sb_bread(inode->i_sb, block))) { - ext3_error (inode->i_sb, "ext3_get_inode_loc", + (offset >> EXT3_BLOCK_SIZE_BITS(sb)); + if (!(bh = sb_bread(sb, block))) { + ext3_error (sb, __FUNCTION__, "unable to read inode block - " "inode=%lu, block=%lu", inode->i_ino, block); goto bad_inode; } - offset &= (EXT3_BLOCK_SIZE(inode->i_sb) - 1); + offset &= (EXT3_BLOCK_SIZE(sb) - 1); iloc->bh = bh; iloc->raw_inode = (struct ext3_inode *) (bh->b_data + offset); @@ -2239,7 +2244,7 @@ void ext3_set_inode_flags(struct inode *inode) { - unsigned int flags = inode->u.ext3_i.i_flags; + unsigned int flags = EXT3_I(inode)->i_flags; inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME); if (flags & EXT3_SYNC_FL) @@ -2257,6 +2262,7 @@ { struct ext3_iloc iloc; struct ext3_inode *raw_inode; + struct ext3_inode_info *ei = EXT3_I(inode); struct buffer_head *bh; int block; @@ -2264,7 +2270,7 @@ goto bad_inode; bh = iloc.bh; raw_inode = iloc.raw_inode; - init_rwsem(&inode->u.ext3_i.truncate_sem); + init_rwsem(&ei->truncate_sem); inode->i_mode = le16_to_cpu(raw_inode->i_mode); inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low); inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low); @@ -2277,7 +2283,7 @@ inode->i_atime = le32_to_cpu(raw_inode->i_atime); inode->i_ctime = le32_to_cpu(raw_inode->i_ctime); inode->i_mtime = le32_to_cpu(raw_inode->i_mtime); - inode->u.ext3_i.i_dtime = le32_to_cpu(raw_inode->i_dtime); + ei->i_dtime = le32_to_cpu(raw_inode->i_dtime); /* We now have enough fields to check if the inode was active or not. * This is needed because nfsd might try to access dead inodes * the test is that same one that e2fsck uses @@ -2285,7 +2291,7 @@ */ if (inode->i_nlink == 0) { if (inode->i_mode == 0 || - !(inode->i_sb->u.ext3_sb.s_mount_state & EXT3_ORPHAN_FS)) { + !(EXT3_SB(inode->i_sb)->s_mount_state & EXT3_ORPHAN_FS)) { /* this inode is deleted */ brelse (bh); goto bad_inode; @@ -2300,33 +2306,33 @@ * size */ inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); inode->i_version = ++event; - inode->u.ext3_i.i_flags = le32_to_cpu(raw_inode->i_flags); + ei->i_flags = le32_to_cpu(raw_inode->i_flags); #ifdef EXT3_FRAGMENTS - inode->u.ext3_i.i_faddr = le32_to_cpu(raw_inode->i_faddr); - inode->u.ext3_i.i_frag_no = raw_inode->i_frag; - inode->u.ext3_i.i_frag_size = raw_inode->i_fsize; + ei->i_faddr = le32_to_cpu(raw_inode->i_faddr); + ei->i_frag_no = raw_inode->i_frag; + ei->i_frag_size = raw_inode->i_fsize; #endif - inode->u.ext3_i.i_file_acl = le32_to_cpu(raw_inode->i_file_acl); + ei->i_file_acl = le32_to_cpu(raw_inode->i_file_acl); if (!S_ISREG(inode->i_mode)) { - inode->u.ext3_i.i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl); + ei->i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl); } else { inode->i_size |= ((__u64)le32_to_cpu(raw_inode->i_size_high)) << 32; } - inode->u.ext3_i.i_disksize = inode->i_size; + ei->i_disksize = inode->i_size; inode->i_generation = le32_to_cpu(raw_inode->i_generation); #ifdef EXT3_PREALLOCATE - inode->u.ext3_i.i_prealloc_count = 0; + ei->i_prealloc_count = 0; #endif - inode->u.ext3_i.i_block_group = iloc.block_group; + ei->i_block_group = iloc.block_group; /* * NOTE! The in-memory inode i_data array is in little-endian order * even on big-endian machines: we do NOT byteswap the block numbers! */ for (block = 0; block < EXT3_N_BLOCKS; block++) - inode->u.ext3_i.i_data[block] = iloc.raw_inode->i_block[block]; - INIT_LIST_HEAD(&inode->u.ext3_i.i_orphan); + ei->i_data[block] = iloc.raw_inode->i_block[block]; + INIT_LIST_HEAD(&ei->i_orphan); if (S_ISREG(inode->i_mode)) { inode->i_op = &ext3_file_inode_operations; @@ -2350,15 +2356,15 @@ brelse (iloc.bh); ext3_set_inode_flags(inode); #ifdef CONFIG_EXT3_FS_XATTR - init_rwsem(&inode->u.ext3_i.xattr_sem); + init_rwsem(&ei->xattr_sem); #endif #ifdef CONFIG_EXT3_FS_POSIX_ACL - if (inode->u.ext3_i.i_file_acl) { + if (ei->i_file_acl) { /* The filesystem is mounted with ACL support, and there are extended attributes for this inode. However we do not yet know whether there are actually any ACLs. */ - inode->u.ext3_i.i_acl = EXT3_ACL_NOT_CACHED; - inode->u.ext3_i.i_default_acl = EXT3_ACL_NOT_CACHED; + ei->i_acl = EXT3_ACL_NOT_CACHED; + ei->i_default_acl = EXT3_ACL_NOT_CACHED; } #endif @@ -2380,6 +2386,7 @@ struct ext3_iloc *iloc) { struct ext3_inode *raw_inode = iloc->raw_inode; + struct ext3_inode_info *ei = EXT3_I(inode); struct buffer_head *bh = iloc->bh; int err = 0, rc, block; @@ -2397,7 +2404,7 @@ * Fix up interoperability with old kernels. Otherwise, old inodes get * re-used with the upper 16 bits of the uid/gid intact */ - if(!inode->u.ext3_i.i_dtime) { + if(!ei->i_dtime) { raw_inode->i_uid_high = cpu_to_le16(high_16_bits(inode->i_uid)); raw_inode->i_gid_high = @@ -2415,34 +2422,33 @@ raw_inode->i_gid_high = 0; } raw_inode->i_links_count = cpu_to_le16(inode->i_nlink); - raw_inode->i_size = cpu_to_le32(inode->u.ext3_i.i_disksize); + raw_inode->i_size = cpu_to_le32(ei->i_disksize); raw_inode->i_atime = cpu_to_le32(inode->i_atime); raw_inode->i_ctime = cpu_to_le32(inode->i_ctime); raw_inode->i_mtime = cpu_to_le32(inode->i_mtime); raw_inode->i_blocks = cpu_to_le32(inode->i_blocks); - raw_inode->i_dtime = cpu_to_le32(inode->u.ext3_i.i_dtime); - raw_inode->i_flags = cpu_to_le32(inode->u.ext3_i.i_flags); + raw_inode->i_dtime = cpu_to_le32(ei->i_dtime); + raw_inode->i_flags = cpu_to_le32(ei->i_flags); #ifdef EXT3_FRAGMENTS - raw_inode->i_faddr = cpu_to_le32(inode->u.ext3_i.i_faddr); - raw_inode->i_frag = inode->u.ext3_i.i_frag_no; - raw_inode->i_fsize = inode->u.ext3_i.i_frag_size; + raw_inode->i_faddr = cpu_to_le32(ei->i_faddr); + raw_inode->i_frag = ei->i_frag_no; + raw_inode->i_fsize = ei->i_frag_size; #else /* If we are not tracking these fields in the in-memory inode, * then preserve them on disk, but still initialise them to zero * for new inodes. */ - if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) { + if (ei->i_state & EXT3_STATE_NEW) { raw_inode->i_faddr = 0; raw_inode->i_frag = 0; raw_inode->i_fsize = 0; } #endif - raw_inode->i_file_acl = cpu_to_le32(inode->u.ext3_i.i_file_acl); + raw_inode->i_file_acl = cpu_to_le32(ei->i_file_acl); if (!S_ISREG(inode->i_mode)) { - raw_inode->i_dir_acl = cpu_to_le32(inode->u.ext3_i.i_dir_acl); + raw_inode->i_dir_acl = cpu_to_le32(ei->i_dir_acl); } else { - raw_inode->i_size_high = - cpu_to_le32(inode->u.ext3_i.i_disksize >> 32); - if (inode->u.ext3_i.i_disksize > 0x7fffffffULL) { + raw_inode->i_size_high = cpu_to_le32(ei->i_disksize >> 32); + if (ei->i_disksize > MAX_NON_LFS) { struct super_block *sb = inode->i_sb; if (!EXT3_HAS_RO_COMPAT_FEATURE(sb, EXT3_FEATURE_RO_COMPAT_LARGE_FILE) || @@ -2452,7 +2458,7 @@ * created, add a flag to the superblock. */ err = ext3_journal_get_write_access(handle, - sb->u.ext3_sb.s_sbh); + EXT3_SB(sb)->s_sbh); if (err) goto out_brelse; ext3_update_dynamic_rev(sb); @@ -2461,7 +2467,7 @@ sb->s_dirt = 1; handle->h_sync = 1; err = ext3_journal_dirty_metadata(handle, - sb->u.ext3_sb.s_sbh); + EXT3_SB(sb)->s_sbh); } } } @@ -2470,13 +2476,13 @@ raw_inode->i_block[0] = cpu_to_le32(kdev_t_to_nr(inode->i_rdev)); else for (block = 0; block < EXT3_N_BLOCKS; block++) - raw_inode->i_block[block] = inode->u.ext3_i.i_data[block]; + raw_inode->i_block[block] = ei->i_data[block]; BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata"); rc = ext3_journal_dirty_metadata(handle, bh); if (!err) err = rc; - EXT3_I(inode)->i_state &= ~EXT3_STATE_NEW; + ei->i_state &= ~EXT3_STATE_NEW; out_brelse: brelse (bh); @@ -2581,7 +2587,7 @@ } error = ext3_orphan_add(handle, inode); - inode->u.ext3_i.i_disksize = attr->ia_size; + EXT3_I(inode)->i_disksize = attr->ia_size; rc = ext3_mark_inode_dirty(handle, inode); if (!error) error = rc; @@ -2843,9 +2849,9 @@ */ if (val) - inode->u.ext3_i.i_flags |= EXT3_JOURNAL_DATA_FL; + EXT3_I(inode)->i_flags |= EXT3_JOURNAL_DATA_FL; else - inode->u.ext3_i.i_flags &= ~EXT3_JOURNAL_DATA_FL; + EXT3_I(inode)->i_flags &= ~EXT3_JOURNAL_DATA_FL; journal_unlock_updates(journal); Index: linux-2.4.21-chaos/fs/ext3/ioctl.c =================================================================== --- linux-2.4.21-chaos.orig/fs/ext3/ioctl.c 2003-09-19 03:49:54.000000000 +0400 +++ linux-2.4.21-chaos/fs/ext3/ioctl.c 2003-12-12 12:50:34.000000000 +0300 @@ -18,13 +18,14 @@ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, unsigned long arg) { + struct ext3_inode_info *ei = EXT3_I(inode); unsigned int flags; ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg); switch (cmd) { case EXT3_IOC_GETFLAGS: - flags = inode->u.ext3_i.i_flags & EXT3_FL_USER_VISIBLE; + flags = ei->i_flags & EXT3_FL_USER_VISIBLE; return put_user(flags, (int *) arg); case EXT3_IOC_SETFLAGS: { handle_t *handle = NULL; @@ -42,7 +43,7 @@ if (get_user(flags, (int *) arg)) return -EFAULT; - oldflags = inode->u.ext3_i.i_flags; + oldflags = ei->i_flags; /* The JOURNAL_DATA flag is modifiable only by root */ jflag = flags & EXT3_JOURNAL_DATA_FL; @@ -79,7 +80,7 @@ flags = flags & EXT3_FL_USER_MODIFIABLE; flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE; - inode->u.ext3_i.i_flags = flags; + ei->i_flags = flags; ext3_set_inode_flags(inode); inode->i_ctime = CURRENT_TIME; @@ -138,12 +139,12 @@ int ret = 0; set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&sb->u.ext3_sb.ro_wait_queue, &wait); - if (timer_pending(&sb->u.ext3_sb.turn_ro_timer)) { + add_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait); + if (timer_pending(&EXT3_SB(sb)->turn_ro_timer)) { schedule(); ret = 1; } - remove_wait_queue(&sb->u.ext3_sb.ro_wait_queue, &wait); + remove_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait); return ret; } #endif Index: linux-2.4.21-chaos/fs/ext3/namei.c =================================================================== --- linux-2.4.21-chaos.orig/fs/ext3/namei.c 2003-12-12 11:36:13.000000000 +0300 +++ linux-2.4.21-chaos/fs/ext3/namei.c 2003-12-12 12:56:27.000000000 +0300 @@ -343,7 +343,7 @@ goto fail; } hinfo->hash_version = root->info.hash_version; - hinfo->seed = dir->i_sb->u.ext3_sb.s_hash_seed; + hinfo->seed = EXT3_SB(dir->i_sb)->s_hash_seed; if (dentry) ext3fs_dirhash(dentry->d_name.name, dentry->d_name.len, hinfo); hash = hinfo->hash; @@ -1236,7 +1236,7 @@ de->rec_len = cpu_to_le16(blocksize - EXT3_DIR_REC_LEN(2)); memset (&root->info, 0, sizeof(root->info)); root->info.info_length = sizeof(root->info); - root->info.hash_version = dir->i_sb->u.ext3_sb.s_def_hash_version; + root->info.hash_version = EXT3_SB(dir->i_sb)->s_def_hash_version; entries = root->entries; dx_set_block (entries, 1); dx_set_count (entries, 1); @@ -1244,7 +1244,7 @@ /* Initialize as for dx_probe */ hinfo.hash_version = root->info.hash_version; - hinfo.seed = dir->i_sb->u.ext3_sb.s_hash_seed; + hinfo.seed = EXT3_SB(dir->i_sb)->s_hash_seed; ext3fs_dirhash(name, namelen, &hinfo); frame = frames; frame->entries = entries; @@ -1768,8 +1768,8 @@ J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) || inode->i_nlink == 0); - BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "get_write_access"); - err = ext3_journal_get_write_access(handle, sb->u.ext3_sb.s_sbh); + BUFFER_TRACE(EXT3_SB(sb)->s_sbh, "get_write_access"); + err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh); if (err) goto out_unlock; @@ -1780,7 +1780,7 @@ /* Insert this inode at the head of the on-disk orphan list... */ NEXT_ORPHAN(inode) = le32_to_cpu(EXT3_SB(sb)->s_es->s_last_orphan); EXT3_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino); - err = ext3_journal_dirty_metadata(handle, sb->u.ext3_sb.s_sbh); + err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); rc = ext3_mark_iloc_dirty(handle, inode, &iloc); if (!err) err = rc; @@ -1854,8 +1854,7 @@ err = ext3_journal_dirty_metadata(handle, sbi->s_sbh); } else { struct ext3_iloc iloc2; - struct inode *i_prev = - list_entry(prev, struct inode, u.ext3_i.i_orphan); + struct inode *i_prev = orphan_list_entry(prev); jbd_debug(4, "orphan inode %lu will point to %lu\n", i_prev->i_ino, ino_next); Index: linux-2.4.21-chaos/fs/ext3/super.c =================================================================== --- linux-2.4.21-chaos.orig/fs/ext3/super.c 2003-12-12 12:14:29.000000000 +0300 +++ linux-2.4.21-chaos/fs/ext3/super.c 2003-12-12 12:50:34.000000000 +0300 @@ -125,7 +125,7 @@ /* If no overrides were specified on the mount, then fall back * to the default behaviour set in the filesystem's superblock * on disk. */ - switch (le16_to_cpu(sb->u.ext3_sb.s_es->s_errors)) { + switch (le16_to_cpu(EXT3_SB(sb)->s_es->s_errors)) { case EXT3_ERRORS_PANIC: return EXT3_ERRORS_PANIC; case EXT3_ERRORS_RO: @@ -299,9 +299,9 @@ return; printk (KERN_CRIT "Remounting filesystem read-only\n"); - sb->u.ext3_sb.s_mount_state |= EXT3_ERROR_FS; + EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; sb->s_flags |= MS_RDONLY; - sb->u.ext3_sb.s_mount_opt |= EXT3_MOUNT_ABORT; + EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; journal_abort(EXT3_SB(sb)->s_journal, -EIO); } @@ -407,8 +407,6 @@ return ret; } -#define orphan_list_entry(l) list_entry((l), struct inode, u.ext3_i.i_orphan) - static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi) { struct list_head *l; @@ -889,7 +887,7 @@ return; } - if (sb->u.ext3_sb.s_mount_state & EXT3_ERROR_FS) { + if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) { if (es->s_last_orphan) jbd_debug(1, "Errors on filesystem, " "clearing orphan list.\n"); @@ -1571,12 +1569,14 @@ struct ext3_super_block * es, int sync) { + struct buffer_head *sbh = EXT3_SB(sb)->s_sbh; + es->s_wtime = cpu_to_le32(CURRENT_TIME); - BUFFER_TRACE(sb->u.ext3_sb.s_sbh, "marking dirty"); - mark_buffer_dirty(sb->u.ext3_sb.s_sbh); + BUFFER_TRACE(sbh, "marking dirty"); + mark_buffer_dirty(sbh); if (sync) { - ll_rw_block(WRITE, 1, &sb->u.ext3_sb.s_sbh); - wait_on_buffer(sb->u.ext3_sb.s_sbh); + ll_rw_block(WRITE, 1, &sbh); + wait_on_buffer(sbh); } } @@ -1627,7 +1627,7 @@ ext3_warning(sb, __FUNCTION__, "Marking fs in need of " "filesystem check."); - sb->u.ext3_sb.s_mount_state |= EXT3_ERROR_FS; + EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; es->s_state |= cpu_to_le16(EXT3_ERROR_FS); ext3_commit_super (sb, es, 1); Index: linux-2.4.21-chaos/fs/ext3/symlink.c =================================================================== --- linux-2.4.21-chaos.orig/fs/ext3/symlink.c 2003-07-15 04:41:01.000000000 +0400 +++ linux-2.4.21-chaos/fs/ext3/symlink.c 2003-12-12 12:50:34.000000000 +0300 @@ -24,14 +24,14 @@ static int ext3_readlink(struct dentry *dentry, char *buffer, int buflen) { - char *s = (char *)dentry->d_inode->u.ext3_i.i_data; - return vfs_readlink(dentry, buffer, buflen, s); + struct ext3_inode_info *ei = EXT3_I(dentry->d_inode); + return vfs_readlink(dentry, buffer, buflen, (char *)ei->i_data); } static int ext3_follow_link(struct dentry *dentry, struct nameidata *nd) { - char *s = (char *)dentry->d_inode->u.ext3_i.i_data; - return vfs_follow_link(nd, s); + struct ext3_inode_info *ei = EXT3_I(dentry->d_inode); + return vfs_follow_link(nd, (char*)ei->i_data); } struct inode_operations ext3_symlink_inode_operations = { Index: linux-2.4.21-chaos/include/linux/ext3_fs.h =================================================================== --- linux-2.4.21-chaos.orig/include/linux/ext3_fs.h 2003-12-12 11:36:14.000000000 +0300 +++ linux-2.4.21-chaos/include/linux/ext3_fs.h 2003-12-12 12:50:34.000000000 +0300 @@ -87,22 +87,25 @@ #define EXT3_MIN_BLOCK_SIZE 1024 #define EXT3_MAX_BLOCK_SIZE 4096 #define EXT3_MIN_BLOCK_LOG_SIZE 10 + #ifdef __KERNEL__ -# define EXT3_BLOCK_SIZE(s) ((s)->s_blocksize) -#else -# define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size) -#endif -#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32)) -#ifdef __KERNEL__ -# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) -#else -# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) -#endif -#ifdef __KERNEL__ -#define EXT3_ADDR_PER_BLOCK_BITS(s) ((s)->u.ext3_sb.s_addr_per_block_bits) -#define EXT3_INODE_SIZE(s) ((s)->u.ext3_sb.s_inode_size) -#define EXT3_FIRST_INO(s) ((s)->u.ext3_sb.s_first_ino) +#define EXT3_SB(sb) (&((sb)->u.ext3_sb)) +#define EXT3_I(inode) (&((inode)->u.ext3_i)) + +#define EXT3_BLOCK_SIZE(s) ((s)->s_blocksize) +#define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) +#define EXT3_ADDR_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_addr_per_block_bits) +#define EXT3_INODE_SIZE(s) (EXT3_SB(s)->s_inode_size) +#define EXT3_FIRST_INO(s) (EXT3_SB(s)->s_first_ino) #else + +/* Assume that user mode programs are passing in an ext3fs superblock, not + * a kernel struct super_block. This will allow us to call the feature-test + * macros from user land. */ +#define EXT3_SB(sb) (sb) + +#define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size) +#define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) #define EXT3_INODE_SIZE(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \ EXT3_GOOD_OLD_INODE_SIZE : \ (s)->s_inode_size) @@ -110,6 +113,7 @@ EXT3_GOOD_OLD_FIRST_INO : \ (s)->s_first_ino) #endif +#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32)) /* * Macro-instructions used to manage fragments @@ -118,8 +122,8 @@ #define EXT3_MAX_FRAG_SIZE 4096 #define EXT3_MIN_FRAG_LOG_SIZE 10 #ifdef __KERNEL__ -# define EXT3_FRAG_SIZE(s) ((s)->u.ext3_sb.s_frag_size) -# define EXT3_FRAGS_PER_BLOCK(s) ((s)->u.ext3_sb.s_frags_per_block) +# define EXT3_FRAG_SIZE(s) (EXT3_SB(s)->s_frag_size) +# define EXT3_FRAGS_PER_BLOCK(s) (EXT3_SB(s)->s_frags_per_block) #else # define EXT3_FRAG_SIZE(s) (EXT3_MIN_FRAG_SIZE << (s)->s_log_frag_size) # define EXT3_FRAGS_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / EXT3_FRAG_SIZE(s)) @@ -143,15 +147,13 @@ /* * Macro-instructions used to manage group descriptors */ +# define EXT3_BLOCKS_PER_GROUP(s) (EXT3_SB(s)->s_blocks_per_group) +# define EXT3_INODES_PER_GROUP(s) (EXT3_SB(s)->s_inodes_per_group) #ifdef __KERNEL__ -# define EXT3_BLOCKS_PER_GROUP(s) ((s)->u.ext3_sb.s_blocks_per_group) -# define EXT3_DESC_PER_BLOCK(s) ((s)->u.ext3_sb.s_desc_per_block) -# define EXT3_INODES_PER_GROUP(s) ((s)->u.ext3_sb.s_inodes_per_group) -# define EXT3_DESC_PER_BLOCK_BITS(s) ((s)->u.ext3_sb.s_desc_per_block_bits) +# define EXT3_DESC_PER_BLOCK(s) (EXT3_SB(s)->s_desc_per_block) +# define EXT3_DESC_PER_BLOCK_BITS(s) (EXT3_SB(s)->s_desc_per_block_bits) #else -# define EXT3_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) # define EXT3_DESC_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc)) -# define EXT3_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) #endif /* @@ -326,7 +328,7 @@ #ifndef _LINUX_EXT2_FS_H #define clear_opt(o, opt) o &= ~EXT3_MOUNT_##opt #define set_opt(o, opt) o |= EXT3_MOUNT_##opt -#define test_opt(sb, opt) ((sb)->u.ext3_sb.s_mount_opt & \ +#define test_opt(sb, opt) (EXT3_SB(sb)->s_mount_opt & \ EXT3_MOUNT_##opt) #else #define EXT2_MOUNT_NOLOAD EXT3_MOUNT_NOLOAD @@ -427,17 +429,11 @@ __u32 s_reserved[192]; /* Padding to the end of the block */ }; -#ifdef __KERNEL__ -#define EXT3_SB(sb) (&((sb)->u.ext3_sb)) -#define EXT3_I(inode) (&((inode)->u.ext3_i)) -#else -/* Assume that user mode programs are passing in an ext3fs superblock, not - * a kernel struct super_block. This will allow us to call the feature-test - * macros from user land. */ -#define EXT3_SB(sb) (sb) -#endif - -#define NEXT_ORPHAN(inode) (inode)->u.ext3_i.i_dtime +#define NEXT_ORPHAN(inode) EXT3_I(inode)->i_dtime +static inline struct inode *orphan_list_entry(struct list_head *l) +{ + return list_entry(l, struct inode, u.ext3_i.i_orphan); +} /* * Codes for operating systems Index: linux-2.4.21-chaos/include/linux/ext3_jbd.h =================================================================== --- linux-2.4.21-chaos.orig/include/linux/ext3_jbd.h 2003-12-12 11:36:14.000000000 +0300 +++ linux-2.4.21-chaos/include/linux/ext3_jbd.h 2003-12-12 12:50:34.000000000 +0300 @@ -285,7 +285,7 @@ return 1; if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA) return 1; - if (inode->u.ext3_i.i_flags & EXT3_JOURNAL_DATA_FL) + if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL) return 1; return 0; }