Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext3-statfs-2.6.12.patch
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 @@
6  {
7         struct ext3_super_block *es = EXT3_SB(sb)->s_es;
8         unsigned long overhead;
9 -       int i;
10  
11         if (test_opt (sb, MINIX_DF))
12                 overhead = 0;
13         else {
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;
19                 smp_rmb();
20  
21                 /*
22 @@ -2189,11 +2188,14 @@
23                  * block group descriptors.  If the sparse superblocks
24                  * feature is turned on, then not all groups have this.
25                  */
26 -               for (i = 0; i < ngroups; i++) {
27 -                       overhead += ext3_bg_has_super(sb, i) +
28 -                               ext3_bg_num_gdb(sb, i);
29 -                       cond_resched();
30 -               }
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);
34 +
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);
39  
40                 /*
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)
49 +               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))
52                 buf->f_bavail = 0;
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)
57 +               buf->f_ffree = 0;
58         buf->f_namelen = EXT3_NAME_LEN;
59         return 0;
60  }
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
65 @@ -285,17 +285,17 @@
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, ...
68   */
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)
73  {
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;
77         int mult = 3;
78 -       unsigned ret;
79  
80         if (!EXT3_HAS_RO_COMPAT_FEATURE(sb,
81                                         EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
82 -               ret = *min;
83 -               *min += 1;
84 +               ret = *three;
85 +               *three += 1;
86                 return ret;
87         }
88  
89 @@ -308,8 +307,26 @@
90                 mult = 7;
91         }
92  
93 -       ret = *min;
94 -       *min *= mult;
95 +       if (EXT3_HAS_INCOMPAT_FEATURE(sb,EXT3_FEATURE_INCOMPAT_META_BG) &&
96 +           *min >= metabg * EXT3_DESC_PER_BLOCK(sb)) {
97 +               ret = *min;
98 +               switch (ret & (EXT3_DESC_PER_BLOCK(sb) - 1)) {
99 +               case 0:
100 +                       *three = ret + 1;
101 +                       break;
102 +               case 1:
103 +                       *three = ret + EXT3_DESC_PER_BLOCK(sb) - 2;
104 +                       break;
105 +               default:
106 +                       *three = (ret | (EXT3_DESC_PER_BLOCK(sb) - 1)) + 1;
107 +                       break;
108 +               }
109 +               *five = -1UL;
110 +               *seven = -1UL;
111 +       } else {
112 +               ret = *min;
113 +               *min *= mult;
114 +       }
115  
116         return ret;
117  }
118 @@ -324,17 +337,17 @@
119  {
120         const unsigned long blk = primary->b_blocknr;
121         const unsigned long end = EXT3_SB(sb)->s_groups_count;
122 -       unsigned three = 1;
123 -       unsigned five = 5;
124 -       unsigned seven = 7;
125 -       unsigned grp;
126 +       unsigned long three = 1;
127 +       unsigned long five = 5;
128 +       unsigned long seven = 7;
129 +       unsigned long grp;
130         __u32 *p = (__u32 *)primary->b_data;
131         int gdbackups = 0;
132  
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",
138                                      blk, grp,
139                                      grp * EXT3_BLOCKS_PER_GROUP(sb) + blk);
140                         return -EINVAL;
141 @@ -618,10 +631,8 @@
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;
146 -       unsigned five = 5;
147 -       unsigned seven = 7;
148 -       unsigned group;
149 +       unsigned long three = 1, five = 5, seven = 7;
150 +       unsigned long group;
151         int rest = sb->s_blocksize - size;
152         handle_t *handle;
153         int err = 0, err2;
154 @@ -672,7 +683,7 @@
155  exit_err:
156         if (err) {
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
167 @@ -788,6 +788,10 @@
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);
175  
176  /* super.c */
177  extern void ext3_error (struct super_block *, const char *, const char *, ...)