aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3/ialloc.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2012-05-30 15:11:26 -0400
committerH. Peter Anvin <hpa@zytor.com>2012-05-30 15:11:32 -0400
commitbbd771474ec44b516107685d77e1c80bbe09f141 (patch)
tree0cb15781539a68f27b4ea6c89f827282630cbce6 /fs/ext3/ialloc.c
parent403e1c5b7495d7b80fae9fc4d0a7a6f5abdc3307 (diff)
parent319b6ffc6df892e4ccffff823cc5521a4a5d2dca (diff)
Merge branch 'x86/trampoline' into x86/urgent
x86/trampoline contains an urgent commit which is necessarily on a newer baseline. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'fs/ext3/ialloc.c')
-rw-r--r--fs/ext3/ialloc.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index e3c39e4cec19..082afd78b107 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -180,8 +180,7 @@ error_return:
180 * It's OK to put directory into a group unless 180 * It's OK to put directory into a group unless
181 * it has too many directories already (max_dirs) or 181 * it has too many directories already (max_dirs) or
182 * it has too few free inodes left (min_inodes) or 182 * it has too few free inodes left (min_inodes) or
183 * it has too few free blocks left (min_blocks) or 183 * it has too few free blocks left (min_blocks).
184 * it's already running too large debt (max_debt).
185 * Parent's group is preferred, if it doesn't satisfy these 184 * Parent's group is preferred, if it doesn't satisfy these
186 * conditions we search cyclically through the rest. If none 185 * conditions we search cyclically through the rest. If none
187 * of the groups look good we just look for a group with more 186 * of the groups look good we just look for a group with more
@@ -191,21 +190,16 @@ error_return:
191 * when we allocate an inode, within 0--255. 190 * when we allocate an inode, within 0--255.
192 */ 191 */
193 192
194#define INODE_COST 64
195#define BLOCK_COST 256
196
197static int find_group_orlov(struct super_block *sb, struct inode *parent) 193static int find_group_orlov(struct super_block *sb, struct inode *parent)
198{ 194{
199 int parent_group = EXT3_I(parent)->i_block_group; 195 int parent_group = EXT3_I(parent)->i_block_group;
200 struct ext3_sb_info *sbi = EXT3_SB(sb); 196 struct ext3_sb_info *sbi = EXT3_SB(sb);
201 struct ext3_super_block *es = sbi->s_es;
202 int ngroups = sbi->s_groups_count; 197 int ngroups = sbi->s_groups_count;
203 int inodes_per_group = EXT3_INODES_PER_GROUP(sb); 198 int inodes_per_group = EXT3_INODES_PER_GROUP(sb);
204 unsigned int freei, avefreei; 199 unsigned int freei, avefreei;
205 ext3_fsblk_t freeb, avefreeb; 200 ext3_fsblk_t freeb, avefreeb;
206 ext3_fsblk_t blocks_per_dir;
207 unsigned int ndirs; 201 unsigned int ndirs;
208 int max_debt, max_dirs, min_inodes; 202 int max_dirs, min_inodes;
209 ext3_grpblk_t min_blocks; 203 ext3_grpblk_t min_blocks;
210 int group = -1, i; 204 int group = -1, i;
211 struct ext3_group_desc *desc; 205 struct ext3_group_desc *desc;
@@ -242,20 +236,10 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
242 goto fallback; 236 goto fallback;
243 } 237 }
244 238
245 blocks_per_dir = (le32_to_cpu(es->s_blocks_count) - freeb) / ndirs;
246
247 max_dirs = ndirs / ngroups + inodes_per_group / 16; 239 max_dirs = ndirs / ngroups + inodes_per_group / 16;
248 min_inodes = avefreei - inodes_per_group / 4; 240 min_inodes = avefreei - inodes_per_group / 4;
249 min_blocks = avefreeb - EXT3_BLOCKS_PER_GROUP(sb) / 4; 241 min_blocks = avefreeb - EXT3_BLOCKS_PER_GROUP(sb) / 4;
250 242
251 max_debt = EXT3_BLOCKS_PER_GROUP(sb) / max(blocks_per_dir, (ext3_fsblk_t)BLOCK_COST);
252 if (max_debt * INODE_COST > inodes_per_group)
253 max_debt = inodes_per_group / INODE_COST;
254 if (max_debt > 255)
255 max_debt = 255;
256 if (max_debt == 0)
257 max_debt = 1;
258
259 for (i = 0; i < ngroups; i++) { 243 for (i = 0; i < ngroups; i++) {
260 group = (parent_group + i) % ngroups; 244 group = (parent_group + i) % ngroups;
261 desc = ext3_get_group_desc (sb, group, NULL); 245 desc = ext3_get_group_desc (sb, group, NULL);