1 Index: linux-2.6.18-8.1.8/fs/ext3/super.c
2 ===================================================================
3 --- linux-2.6.18-8.1.8.orig/fs/ext3/super.c
4 +++ linux-2.6.18-8.1.8/fs/ext3/super.c
5 @@ -2923,18 +2923,18 @@ static int ext3_statfs (struct dentry *
6 struct super_block *sb = dentry->d_sb;
7 struct ext3_sb_info *sbi = EXT3_SB(sb);
8 struct ext3_super_block *es = sbi->s_es;
9 - ext3_fsblk_t overhead;
12 - if (test_opt (sb, MINIX_DF))
15 - unsigned long ngroups;
16 - ngroups = EXT3_SB(sb)->s_groups_count;
17 + if (test_opt(sb, MINIX_DF)) {
18 + sbi->s_overhead_last = 0;
19 + } else if (sbi->s_blocks_last != le32_to_cpu(es->s_blocks_count)) {
20 + unsigned long ngroups = sbi->s_groups_count, i;
21 + ext3_fsblk_t overhead = 0;
25 - * Compute the overhead (FS structures)
26 + * Compute the overhead (FS structures). This is constant
27 + * for a given filesystem unless the number of block groups
28 + * changes so we cache the previous value until it does.
32 @@ -2956,18 +2956,23 @@ static int ext3_statfs (struct dentry *
33 * Every block group has an inode bitmap, a block
34 * bitmap, and an inode table.
36 - overhead += (ngroups * (2 + EXT3_SB(sb)->s_itb_per_group));
37 + overhead += ngroups * (2 + sbi->s_itb_per_group);
38 + sbi->s_overhead_last = overhead;
40 + sbi->s_blocks_last = le32_to_cpu(es->s_blocks_count);
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_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last;
47 buf->f_bfree = percpu_counter_sum(&sbi->s_freeblocks_counter);
48 + es->s_free_blocks_count = cpu_to_le32(buf->f_bfree);
49 buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
50 if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
52 buf->f_files = le32_to_cpu(es->s_inodes_count);
53 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
54 + es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
55 buf->f_namelen = EXT3_NAME_LEN;
58 Index: linux-2.6.18-8.1.8/include/linux/ext3_fs_sb.h
59 ===================================================================
60 --- linux-2.6.18-8.1.8.orig/include/linux/ext3_fs_sb.h
61 +++ linux-2.6.18-8.1.8/include/linux/ext3_fs_sb.h
62 @@ -45,6 +45,8 @@ struct ext3_sb_info {
63 unsigned long s_gdb_count; /* Number of group descriptor blocks */
64 unsigned long s_desc_per_block; /* Number of group descriptors per block */
65 unsigned long s_groups_count; /* Number of groups in the fs */
66 + unsigned long s_overhead_last; /* Last calculated overhead */
67 + unsigned long s_blocks_last; /* Last seen block count */
68 struct buffer_head * s_sbh; /* Buffer containing the super block */
69 struct ext3_super_block * s_es; /* Pointer to the super block in the buffer */
70 struct buffer_head ** s_group_desc;