Commit 7c4e5b98 authored by Theodore Y. Ts'o's avatar Theodore Y. Ts'o Committed by Linus Torvalds

Fix meta_bg compatibility with e2fsprogs 1.30.

The algorithm for finding the block group descriptor blocks for the 
future on-line resizable ext2/3 format change got out of sync with 
what was actually shipped in e2fsprogs 1.30.  (And what is in e2fsprogs
1.30 is better since it avoids a free block fragmentation at the
beginning of the block group.)  This change is safe, since no one is 
actually using the new meta_bg block group layout just yet.
parent cbc490a4
...@@ -529,6 +529,7 @@ static unsigned long descriptor_loc(struct super_block *sb, ...@@ -529,6 +529,7 @@ static unsigned long descriptor_loc(struct super_block *sb,
{ {
struct ext2_sb_info *sbi = EXT2_SB(sb); struct ext2_sb_info *sbi = EXT2_SB(sb);
unsigned long bg, first_data_block, first_meta_bg; 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_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); first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
...@@ -537,7 +538,9 @@ static unsigned long descriptor_loc(struct super_block *sb, ...@@ -537,7 +538,9 @@ static unsigned long descriptor_loc(struct super_block *sb,
nr < first_meta_bg) nr < first_meta_bg)
return (logic_sb_block + nr + 1); return (logic_sb_block + nr + 1);
bg = sbi->s_desc_per_block * nr; bg = sbi->s_desc_per_block * nr;
return (first_data_block + 1 + (bg * sbi->s_blocks_per_group)); if (ext2_bg_has_super(sb, bg))
has_super = 1;
return (first_data_block + has_super + (bg * sbi->s_blocks_per_group));
} }
static int ext2_fill_super(struct super_block *sb, void *data, int silent) static int ext2_fill_super(struct super_block *sb, void *data, int silent)
......
...@@ -979,6 +979,7 @@ static unsigned long descriptor_loc(struct super_block *sb, ...@@ -979,6 +979,7 @@ static unsigned long descriptor_loc(struct super_block *sb,
{ {
struct ext3_sb_info *sbi = EXT3_SB(sb); struct ext3_sb_info *sbi = EXT3_SB(sb);
unsigned long bg, first_data_block, first_meta_bg; 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_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); first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
...@@ -987,7 +988,9 @@ static unsigned long descriptor_loc(struct super_block *sb, ...@@ -987,7 +988,9 @@ static unsigned long descriptor_loc(struct super_block *sb,
nr < first_meta_bg) nr < first_meta_bg)
return (logic_sb_block + nr + 1); return (logic_sb_block + nr + 1);
bg = sbi->s_desc_per_block * nr; bg = sbi->s_desc_per_block * nr;
return (first_data_block + 1 + (bg * sbi->s_blocks_per_group)); if (ext3_bg_has_super(sb, bg))
has_super = 1;
return (first_data_block + has_super + (bg * sbi->s_blocks_per_group));
} }
......
...@@ -513,10 +513,9 @@ static inline struct ext3_inode_info *EXT3_I(struct inode *inode) ...@@ -513,10 +513,9 @@ static inline struct ext3_inode_info *EXT3_I(struct inode *inode)
#define EXT3_FEATURE_INCOMPAT_META_BG 0x0010 #define EXT3_FEATURE_INCOMPAT_META_BG 0x0010
#define EXT3_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR #define EXT3_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
EXT2_FEATURE_INCOMPAT_META_BG)
#define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \ #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| \ #define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \ EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
EXT3_FEATURE_RO_COMPAT_BTREE_DIR) EXT3_FEATURE_RO_COMPAT_BTREE_DIR)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment