1 Index: linux-2.6.12/fs/ext3/super.c
2 ===================================================================
3 --- linux-2.6.12.orig/fs/ext3/super.c 2005-06-17 13:48:29.000000000 -0600
4 +++ linux-2.6.12/fs/ext3/super.c 2005-11-25 05:59:47.000000000 -0700
5 @@ -2165,13 +2165,13 @@
7 struct ext3_super_block *es = EXT3_SB(sb)->s_es;
8 unsigned long overhead;
11 if (test_opt (sb, MINIX_DF))
14 - unsigned long ngroups;
15 - ngroups = EXT3_SB(sb)->s_groups_count;
16 + unsigned long ngroups = EXT3_SB(sb)->s_groups_count, group;
17 + unsigned long three = 1, five = 5, seven = 7;
18 + unsigned long metabg = -1UL;
22 @@ -2189,11 +2188,14 @@
23 * block group descriptors. If the sparse superblocks
24 * feature is turned on, then not all groups have this.
26 - for (i = 0; i < ngroups; i++) {
27 - overhead += ext3_bg_has_super(sb, i) +
28 - ext3_bg_num_gdb(sb, i);
31 + overhead += 1 + EXT3_SB(sb)->s_gdb_count; /* group 0 */
32 + if (EXT3_HAS_INCOMPAT_FEATURE(sb,EXT3_FEATURE_INCOMPAT_META_BG))
33 + metabg =le32_to_cpu(EXT3_SB(sb)->s_es->s_first_meta_bg);
35 + while ((group = ext3_list_backups(sb, &three, &five, &seven)) <
36 + ngroups) /* sb + group descriptors backups */
37 + overhead += 1 + (group >= metabg ? 1 :
38 + EXT3_SB(sb)->s_gdb_count);
41 * Every block group has an inode bitmap, a block
42 @@ -2205,12 +2204,16 @@
43 buf->f_type = EXT3_SUPER_MAGIC;
44 buf->f_bsize = sb->s_blocksize;
45 buf->f_blocks = le32_to_cpu(es->s_blocks_count) - overhead;
46 - buf->f_bfree = ext3_count_free_blocks (sb);
47 + buf->f_bfree = percpu_counter_read(&EXT3_SB(sb)->s_freeblocks_counter);
48 + if (buf->f_bfree < 0)
50 buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
51 if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
53 buf->f_files = le32_to_cpu(es->s_inodes_count);
54 - buf->f_ffree = ext3_count_free_inodes (sb);
55 + buf->f_ffree = percpu_counter_read(&EXT3_SB(sb)->s_freeinodes_counter);
56 + if (buf->f_ffree < 0)
58 buf->f_namelen = EXT3_NAME_LEN;
61 Index: linux-2.6.12/fs/ext3/resize.c
62 ===================================================================
63 --- linux-2.6.12.orig/fs/ext3/resize.c 2005-11-24 15:17:06.000000000 -0700
64 +++ linux-2.6.12/fs/ext3/resize.c 2005-11-25 06:01:01.000000000 -0700
66 * sequence of powers of 3, 5, and 7: 1, 3, 5, 7, 9, 25, 27, 49, 81, ...
67 * For a non-sparse filesystem it will be every group: 1, 2, 3, 4, ...
69 -static unsigned ext3_list_backups(struct super_block *sb, unsigned *three,
70 - unsigned *five, unsigned *seven)
71 +unsigned long ext3_list_backups(struct super_block *sb, unsigned long *three,
72 + unsigned long *five, unsigned long *seven)
74 - unsigned *min = three;
75 + unsigned long metabg = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_meta_bg);
76 + unsigned long *min = three, ret;
80 if (!EXT3_HAS_RO_COMPAT_FEATURE(sb,
81 EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
95 + if (EXT3_HAS_INCOMPAT_FEATURE(sb,EXT3_FEATURE_INCOMPAT_META_BG) &&
96 + *min >= metabg * EXT3_DESC_PER_BLOCK(sb)) {
98 + switch (ret & (EXT3_DESC_PER_BLOCK(sb) - 1)) {
103 + *three = ret + EXT3_DESC_PER_BLOCK(sb) - 2;
106 + *three = (ret | (EXT3_DESC_PER_BLOCK(sb) - 1)) + 1;
118 @@ -324,17 +337,17 @@
120 const unsigned long blk = primary->b_blocknr;
121 const unsigned long end = EXT3_SB(sb)->s_groups_count;
122 - unsigned three = 1;
124 - unsigned seven = 7;
126 + unsigned long three = 1;
127 + unsigned long five = 5;
128 + unsigned long seven = 7;
130 __u32 *p = (__u32 *)primary->b_data;
133 while ((grp = ext3_list_backups(sb, &three, &five, &seven)) < end) {
134 if (le32_to_cpu(*p++) != grp * EXT3_BLOCKS_PER_GROUP(sb) + blk){
135 ext3_warning(sb, __FUNCTION__,
136 - "reserved GDT %ld missing grp %d (%ld)\n",
137 + "reserved GDT %ld missing grp %ld (%ld)\n",
139 grp * EXT3_BLOCKS_PER_GROUP(sb) + blk);
142 struct ext3_sb_info *sbi = EXT3_SB(sb);
143 const unsigned long last = sbi->s_groups_count;
144 const int bpg = EXT3_BLOCKS_PER_GROUP(sb);
145 - unsigned three = 1;
147 - unsigned seven = 7;
149 + unsigned long three = 1, five = 5, seven = 7;
150 + unsigned long group;
151 int rest = sb->s_blocksize - size;
157 ext3_warning(sb, __FUNCTION__,
158 - "can't update backup for group %d (err %d), "
159 + "can't update backup for group %ld (err %d), "
160 "forcing fsck on next reboot\n", group, err);
161 sbi->s_mount_state &= ~EXT3_VALID_FS;
162 sbi->s_es->s_state &= ~cpu_to_le16(EXT3_VALID_FS);
163 Index: linux-2.6.12/include/linux/ext3_fs.h
164 ===================================================================
165 --- linux-2.6.12.orig/include/linux/ext3_fs.h 2005-06-17 13:48:29.000000000 -0600
166 +++ linux-2.6.12/include/linux/ext3_fs.h 2005-11-25 05:59:47.000000000 -0700
168 extern int ext3_group_extend(struct super_block *sb,
169 struct ext3_super_block *es,
170 unsigned long n_blocks_count);
171 +extern unsigned long ext3_list_backups(struct super_block *sb,
172 + unsigned long *three,
173 + unsigned long *five,
174 + unsigned long *seven);
177 extern void ext3_error (struct super_block *, const char *, const char *, ...)