# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # # fs/ext2/ialloc.c | 2 +- # fs/ext2/inode.c | 7 +++++++ # fs/ext2/super.c | 14 ++++++++------ # fs/ext3/inode.c | 14 +++++--------- # fs/ext3/super.c | 4 +++- # include/linux/ext2_fs_i.h | 7 ++++++- # 6 files changed, 30 insertions(+), 18 deletions(-) # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/11/07 tytso@snap.thunk.org 1.782 # Ext2/3 forward compatibility: inode size # # This patch allows filesystems with expanded inodes to be mounted. # (compatibility feature flags will be used to control whether or not the # filesystem should be mounted in case the new inode fields will result in # compatibility issues). This allows for future compatibility with newer # versions of ext2fs. # -------------------------------------------- # --- linux-2.4-ext3merge/fs/ext2/ialloc.c.=K0011=.orig 2003-03-13 16:22:45.000000000 +0000 +++ linux-2.4-ext3merge/fs/ext2/ialloc.c 2003-03-13 16:22:45.000000000 +0000 @@ -385,7 +385,7 @@ repeat: inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat), not the fs block size */ inode->i_blocks = 0; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; - inode->u.ext2_i.i_new_inode = 1; + inode->u.ext2_i.i_state = EXT2_STATE_NEW; inode->u.ext2_i.i_flags = dir->u.ext2_i.i_flags & ~EXT2_BTREE_FL; if (S_ISLNK(mode)) inode->u.ext2_i.i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL); --- linux-2.4-ext3merge/fs/ext2/inode.c.=K0011=.orig 2003-03-13 16:22:45.000000000 +0000 +++ linux-2.4-ext3merge/fs/ext2/inode.c 2003-03-13 16:22:52.000000000 +0000 @@ -964,6 +964,7 @@ void ext2_read_inode (struct inode * ino else inode->u.ext2_i.i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl); inode->i_generation = le32_to_cpu(raw_inode->i_generation); + inode->u.ext2_i.i_state = 0; inode->u.ext2_i.i_prealloc_count = 0; inode->u.ext2_i.i_block_group = block_group; @@ -1070,6 +1071,11 @@ static int ext2_update_inode(struct inod offset &= EXT2_BLOCK_SIZE(inode->i_sb) - 1; raw_inode = (struct ext2_inode *) (bh->b_data + offset); + /* For fields not tracked in the in-memory inode, + * initialise them to zero for new inodes. */ + if (inode->u.ext2_i.i_state & EXT2_STATE_NEW) + memset(raw_inode, 0, EXT2_SB(inode->i_sb)->s_inode_size); + raw_inode->i_mode = cpu_to_le16(inode->i_mode); if(!(test_opt(inode->i_sb, NO_UID32))) { raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid)); @@ -1142,6 +1148,7 @@ static int ext2_update_inode(struct inod err = -EIO; } } + inode->u.ext2_i.i_state &= ~EXT2_STATE_NEW; brelse (bh); return err; } --- linux-2.4-ext3merge/fs/ext2/super.c.=K0011=.orig 2003-03-13 16:22:45.000000000 +0000 +++ linux-2.4-ext3merge/fs/ext2/super.c 2003-03-13 16:22:45.000000000 +0000 @@ -572,14 +572,16 @@ struct super_block * ext2_read_super (st } if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) { - sb->u.ext2_sb.s_inode_size = EXT2_GOOD_OLD_INODE_SIZE; - sb->u.ext2_sb.s_first_ino = EXT2_GOOD_OLD_FIRST_INO; + sbi->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE; + sbi->s_first_ino = EXT2_GOOD_OLD_FIRST_INO; } else { - sb->u.ext2_sb.s_inode_size = le16_to_cpu(es->s_inode_size); - sb->u.ext2_sb.s_first_ino = le32_to_cpu(es->s_first_ino); - if (sb->u.ext2_sb.s_inode_size != EXT2_GOOD_OLD_INODE_SIZE) { + sbi->s_inode_size = le16_to_cpu(es->s_inode_size); + sbi->s_first_ino = le32_to_cpu(es->s_first_ino); + if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) || + (sbi->s_inode_size & (sbi->s_inode_size - 1)) || + (sbi->s_inode_size > blocksize)) { printk ("EXT2-fs: unsupported inode size: %d\n", - sb->u.ext2_sb.s_inode_size); + sbi->s_inode_size); goto failed_mount; } } --- linux-2.4-ext3merge/fs/ext3/inode.c.=K0011=.orig 2003-03-13 16:22:45.000000000 +0000 +++ linux-2.4-ext3merge/fs/ext3/inode.c 2003-03-13 16:22:45.000000000 +0000 @@ -2209,6 +2209,11 @@ static int ext3_do_update_inode(handle_t if (err) goto out_brelse; } + /* For fields not not tracking in the in-memory inode, + * initialise them to zero for new inodes. */ + if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) + memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size); + raw_inode->i_mode = cpu_to_le16(inode->i_mode); if(!(test_opt(inode->i_sb, NO_UID32))) { raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid)); @@ -2246,15 +2251,6 @@ static int ext3_do_update_inode(handle_t 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; -#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) { - 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); if (!S_ISREG(inode->i_mode)) { --- linux-2.4-ext3merge/fs/ext3/super.c.=K0011=.orig 2003-03-13 16:22:45.000000000 +0000 +++ linux-2.4-ext3merge/fs/ext3/super.c 2003-03-13 16:22:45.000000000 +0000 @@ -1063,7 +1063,9 @@ struct super_block * ext3_read_super (st } else { sbi->s_inode_size = le16_to_cpu(es->s_inode_size); sbi->s_first_ino = le32_to_cpu(es->s_first_ino); - if (sbi->s_inode_size != EXT3_GOOD_OLD_INODE_SIZE) { + if ((sbi->s_inode_size < EXT3_GOOD_OLD_INODE_SIZE) || + (sbi->s_inode_size & (sbi->s_inode_size - 1)) || + (sbi->s_inode_size > blocksize)) { printk (KERN_ERR "EXT3-fs: unsupported inode size: %d\n", sbi->s_inode_size); --- linux-2.4-ext3merge/include/linux/ext2_fs_i.h.=K0011=.orig 2003-03-13 16:22:45.000000000 +0000 +++ linux-2.4-ext3merge/include/linux/ext2_fs_i.h 2003-03-13 16:22:45.000000000 +0000 @@ -25,6 +25,7 @@ struct ext2_inode_info { __u32 i_faddr; __u8 i_frag_no; __u8 i_frag_size; + __u16 i_state; __u32 i_file_acl; __u32 i_dir_acl; __u32 i_dtime; @@ -34,7 +35,11 @@ struct ext2_inode_info { __u32 i_prealloc_block; __u32 i_prealloc_count; __u32 i_dir_start_lookup; - int i_new_inode:1; /* Is a freshly allocated inode */ }; +/* + * Inode dynamic state flags + */ +#define EXT2_STATE_NEW 0x00000001 /* inode is newly created */ + #endif /* _LINUX_EXT2_FS_I */