aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2014-05-12 10:16:06 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-05-12 10:16:06 -0400
commit1beeef1b5643a16a07a465632a2cf984a4ef2119 (patch)
tree5acce4c5f364d8479af7519af04a8689d31b7a18
parentbd63f6b0cd577e94846869db0c86a7b2bee79b26 (diff)
ext4: fix block bitmap initialization under sparse_super2
The ext4_bg_has_super() function doesn't know about the new rules for where backup superblocks go on a sparse_super2 filesystem. Therefore, block bitmap initialization doesn't know that it shouldn't reserve space for backups in groups that are never going to contain backups. The result of this is e2fsck complaining about the block bitmap being incorrect (fortunately not in a way that results in cross-linked files), so fix the whole thing. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--fs/ext4/balloc.c33
-rw-r--r--fs/ext4/ext4.h4
2 files changed, 22 insertions, 15 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 5c56785007e0..a4950e91f61c 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -708,16 +708,6 @@ static inline int test_root(ext4_group_t a, int b)
708 } 708 }
709} 709}
710 710
711static int ext4_group_sparse(ext4_group_t group)
712{
713 if (group <= 1)
714 return 1;
715 if (!(group & 1))
716 return 0;
717 return (test_root(group, 7) || test_root(group, 5) ||
718 test_root(group, 3));
719}
720
721/** 711/**
722 * ext4_bg_has_super - number of blocks used by the superblock in group 712 * ext4_bg_has_super - number of blocks used by the superblock in group
723 * @sb: superblock for filesystem 713 * @sb: superblock for filesystem
@@ -728,11 +718,26 @@ static int ext4_group_sparse(ext4_group_t group)
728 */ 718 */
729int ext4_bg_has_super(struct super_block *sb, ext4_group_t group) 719int ext4_bg_has_super(struct super_block *sb, ext4_group_t group)
730{ 720{
731 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 721 struct ext4_super_block *es = EXT4_SB(sb)->s_es;
732 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER) && 722
733 !ext4_group_sparse(group)) 723 if (group == 0)
724 return 1;
725 if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_SPARSE_SUPER2)) {
726 if (group == le32_to_cpu(es->s_backup_bgs[0]) ||
727 group == le32_to_cpu(es->s_backup_bgs[1]))
728 return 1;
729 return 0;
730 }
731 if ((group <= 1) || !EXT4_HAS_RO_COMPAT_FEATURE(sb,
732 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER))
733 return 1;
734 if (!(group & 1))
734 return 0; 735 return 0;
735 return 1; 736 if (test_root(group, 3) || (test_root(group, 5)) ||
737 test_root(group, 7))
738 return 1;
739
740 return 0;
736} 741}
737 742
738static unsigned long ext4_bg_num_gdb_meta(struct super_block *sb, 743static unsigned long ext4_bg_num_gdb_meta(struct super_block *sb,
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index aeda5061a59a..4feb2d5819ae 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1160,7 +1160,8 @@ struct ext4_super_block {
1160 __le32 s_usr_quota_inum; /* inode for tracking user quota */ 1160 __le32 s_usr_quota_inum; /* inode for tracking user quota */
1161 __le32 s_grp_quota_inum; /* inode for tracking group quota */ 1161 __le32 s_grp_quota_inum; /* inode for tracking group quota */
1162 __le32 s_overhead_clusters; /* overhead blocks/clusters in fs */ 1162 __le32 s_overhead_clusters; /* overhead blocks/clusters in fs */
1163 __le32 s_reserved[108]; /* Padding to the end of the block */ 1163 __le32 s_backup_bgs[2]; /* groups with sparse_super2 SBs */
1164 __le32 s_reserved[106]; /* Padding to the end of the block */
1164 __le32 s_checksum; /* crc32c(superblock) */ 1165 __le32 s_checksum; /* crc32c(superblock) */
1165}; 1166};
1166 1167
@@ -1506,6 +1507,7 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
1506#define EXT4_FEATURE_COMPAT_EXT_ATTR 0x0008 1507#define EXT4_FEATURE_COMPAT_EXT_ATTR 0x0008
1507#define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010 1508#define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010
1508#define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020 1509#define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020
1510#define EXT4_FEATURE_COMPAT_SPARSE_SUPER2 0x0200
1509 1511
1510#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 1512#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
1511#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 1513#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002