# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # # fs/ext2/super.c | 31 ++++++++++++++++++++++++++----- # fs/ext3/super.c | 25 +++++++++++++++++++++++-- # include/linux/ext2_fs.h | 7 +++++-- # include/linux/ext3_fs.h | 7 +++++-- # 4 files changed, 59 insertions(+), 11 deletions(-) # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/11/07 tytso@snap.thunk.org 1.781 # Ext2/3 forward compatibility: on-line resizing # # This patch allows forward compatibility with future filesystems which # are dynamically grown by using an alternate algorithm for storing the # block group descriptors. It's also a bit more efficient, in that it # uses just a little bit less disk space. Currently, the ext2 filesystem # format requires either relocating the inode table, or reserving space in # before doing the on-line resize. The new scheme, which is documented in # "Planned Extensions to the Ext2/3 Filesystem", by Stephen Tweedie and I # (see: http://e2fsprogs.sourceforge.net/extensions-ext23) # -------------------------------------------- # --- linux-2.4-ext3merge/fs/ext2/super.c.=K0010=.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 @@ -415,6 +415,26 @@ static loff_t ext2_max_size(int bits) return res; } +static unsigned long descriptor_loc(struct super_block *sb, + unsigned long logic_sb_block, + int nr) +{ + struct ext2_sb_info *sbi = EXT2_SB(sb); + unsigned long bg, first_data_block, first_meta_bg; + int has_super = 0; + + first_data_block = le32_to_cpu(sbi->s_es->s_first_data_block); + first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg); + + if (!EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_META_BG) || + nr < first_meta_bg) + return (logic_sb_block + nr + 1); + bg = sbi->s_desc_per_block * nr; + if (ext2_bg_has_super(sb, bg)) + has_super = 1; + return (first_data_block + has_super + (bg * sbi->s_blocks_per_group)); +} + struct super_block * ext2_read_super (struct super_block * sb, void * data, int silent) { @@ -422,7 +442,7 @@ struct super_block * ext2_read_super (st struct ext2_sb_info * sbi = EXT2_SB(sb); struct ext2_super_block * es; unsigned long sb_block = get_sb_block(&data); - unsigned long logic_sb_block; + unsigned long block, logic_sb_block; unsigned long offset; kdev_t dev = sb->s_dev; unsigned long def_mount_opts; @@ -633,11 +653,12 @@ struct super_block * ext2_read_super (st goto failed_mount; } for (i = 0; i < db_count; i++) { - sb->u.ext2_sb.s_group_desc[i] = sb_bread(sb, logic_sb_block + i + 1); - if (!sb->u.ext2_sb.s_group_desc[i]) { + block = descriptor_loc(sb, logic_sb_block, i); + sbi->s_group_desc[i] = sb_bread(sb, block); + if (!sbi->s_group_desc[i]) { for (j = 0; j < i; j++) - brelse (sb->u.ext2_sb.s_group_desc[j]); - kfree(sb->u.ext2_sb.s_group_desc); + brelse (sbi->s_group_desc[j]); + kfree(sbi->s_group_desc); printk ("EXT2-fs: unable to read group descriptors\n"); goto failed_mount; } --- linux-2.4-ext3merge/fs/ext3/super.c.=K0010=.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 @@ -877,6 +877,26 @@ static loff_t ext3_max_size(int bits) return res; } +static unsigned long descriptor_loc(struct super_block *sb, + unsigned long logic_sb_block, + int nr) +{ + struct ext3_sb_info *sbi = EXT3_SB(sb); + unsigned long bg, first_data_block, first_meta_bg; + int has_super = 0; + + first_data_block = le32_to_cpu(sbi->s_es->s_first_data_block); + first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg); + + if (!EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_META_BG) || + nr < first_meta_bg) + return (logic_sb_block + nr + 1); + bg = sbi->s_desc_per_block * nr; + if (ext3_bg_has_super(sb, bg)) + has_super = 1; + return (first_data_block + has_super + (bg * sbi->s_blocks_per_group)); +} + struct super_block * ext3_read_super (struct super_block * sb, void * data, int silent) @@ -885,7 +905,7 @@ struct super_block * ext3_read_super (st struct ext3_super_block *es = 0; struct ext3_sb_info *sbi = EXT3_SB(sb); unsigned long sb_block = get_sb_block(&data); - unsigned long logic_sb_block; + unsigned long block, logic_sb_block; unsigned long offset; unsigned long journal_inum = 0; kdev_t dev = sb->s_dev; @@ -1105,7 +1125,8 @@ struct super_block * ext3_read_super (st goto failed_mount; } for (i = 0; i < db_count; i++) { - sbi->s_group_desc[i] = sb_bread(sb, logic_sb_block + i + 1); + block = descriptor_loc(sb, logic_sb_block, i); + sbi->s_group_desc[i] = sb_bread(sb, block); if (!sbi->s_group_desc[i]) { printk (KERN_ERR "EXT3-fs: " "can't read group descriptor %d\n", i); --- linux-2.4-ext3merge/include/linux/ext2_fs.h.=K0010=.orig 2003-03-13 16:22:45.000000000 +0000 +++ linux-2.4-ext3merge/include/linux/ext2_fs.h 2003-03-13 16:22:45.000000000 +0000 @@ -404,7 +404,8 @@ struct ext2_super_block { __u8 s_reserved_char_pad; __u16 s_reserved_word_pad; __u32 s_default_mount_opts; - __u32 s_reserved[191]; /* Padding to the end of the block */ + __u32 s_first_meta_bg; /* First metablock block group */ + __u32 s_reserved[190]; /* Padding to the end of the block */ }; #ifdef __KERNEL__ @@ -476,10 +477,12 @@ struct ext2_super_block { #define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002 #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 +#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010 #define EXT2_FEATURE_INCOMPAT_ANY 0xffffffff #define EXT2_FEATURE_COMPAT_SUPP 0 -#define EXT2_FEATURE_INCOMPAT_SUPP EXT2_FEATURE_INCOMPAT_FILETYPE +#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \ + EXT2_FEATURE_INCOMPAT_META_BG) #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \ EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \ EXT2_FEATURE_RO_COMPAT_BTREE_DIR) --- linux-2.4-ext3merge/include/linux/ext3_fs.h.=K0010=.orig 2003-03-13 16:22:45.000000000 +0000 +++ linux-2.4-ext3merge/include/linux/ext3_fs.h 2003-03-13 16:22:45.000000000 +0000 @@ -448,7 +448,8 @@ struct ext3_super_block { __u8 s_reserved_char_pad; __u16 s_reserved_word_pad; __u32 s_default_mount_opts; - __u32 s_reserved[191]; /* Padding to the end of the block */ + __u32 s_first_meta_bg; /* First metablock block group */ + __u32 s_reserved[190]; /* Padding to the end of the block */ }; #ifdef __KERNEL__ @@ -521,10 +522,12 @@ struct ext3_super_block { #define EXT3_FEATURE_INCOMPAT_FILETYPE 0x0002 #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */ #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */ +#define EXT3_FEATURE_INCOMPAT_META_BG 0x0010 #define EXT3_FEATURE_COMPAT_SUPP 0 #define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \ - EXT3_FEATURE_INCOMPAT_RECOVER) + EXT3_FEATURE_INCOMPAT_RECOVER| \ + EXT3_FEATURE_INCOMPAT_META_BG) #define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \ EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \ EXT3_FEATURE_RO_COMPAT_BTREE_DIR)