diff options
Diffstat (limited to 'fs/ext3/ialloc.c')
-rw-r--r-- | fs/ext3/ialloc.c | 45 |
1 files changed, 3 insertions, 42 deletions
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index bf09cbf938cc..635bd8ce6d59 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c | |||
@@ -178,42 +178,6 @@ error_return: | |||
178 | } | 178 | } |
179 | 179 | ||
180 | /* | 180 | /* |
181 | * There are two policies for allocating an inode. If the new inode is | ||
182 | * a directory, then a forward search is made for a block group with both | ||
183 | * free space and a low directory-to-inode ratio; if that fails, then of | ||
184 | * the groups with above-average free space, that group with the fewest | ||
185 | * directories already is chosen. | ||
186 | * | ||
187 | * For other inodes, search forward from the parent directory\'s block | ||
188 | * group to find a free inode. | ||
189 | */ | ||
190 | static int find_group_dir(struct super_block *sb, struct inode *parent) | ||
191 | { | ||
192 | int ngroups = EXT3_SB(sb)->s_groups_count; | ||
193 | unsigned int freei, avefreei; | ||
194 | struct ext3_group_desc *desc, *best_desc = NULL; | ||
195 | int group, best_group = -1; | ||
196 | |||
197 | freei = percpu_counter_read_positive(&EXT3_SB(sb)->s_freeinodes_counter); | ||
198 | avefreei = freei / ngroups; | ||
199 | |||
200 | for (group = 0; group < ngroups; group++) { | ||
201 | desc = ext3_get_group_desc (sb, group, NULL); | ||
202 | if (!desc || !desc->bg_free_inodes_count) | ||
203 | continue; | ||
204 | if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei) | ||
205 | continue; | ||
206 | if (!best_desc || | ||
207 | (le16_to_cpu(desc->bg_free_blocks_count) > | ||
208 | le16_to_cpu(best_desc->bg_free_blocks_count))) { | ||
209 | best_group = group; | ||
210 | best_desc = desc; | ||
211 | } | ||
212 | } | ||
213 | return best_group; | ||
214 | } | ||
215 | |||
216 | /* | ||
217 | * Orlov's allocator for directories. | 181 | * Orlov's allocator for directories. |
218 | * | 182 | * |
219 | * We always try to spread first-level directories. | 183 | * We always try to spread first-level directories. |
@@ -436,12 +400,9 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, | |||
436 | 400 | ||
437 | sbi = EXT3_SB(sb); | 401 | sbi = EXT3_SB(sb); |
438 | es = sbi->s_es; | 402 | es = sbi->s_es; |
439 | if (S_ISDIR(mode)) { | 403 | if (S_ISDIR(mode)) |
440 | if (test_opt (sb, OLDALLOC)) | 404 | group = find_group_orlov(sb, dir); |
441 | group = find_group_dir(sb, dir); | 405 | else |
442 | else | ||
443 | group = find_group_orlov(sb, dir); | ||
444 | } else | ||
445 | group = find_group_other(sb, dir); | 406 | group = find_group_other(sb, dir); |
446 | 407 | ||
447 | err = -ENOSPC; | 408 | err = -ENOSPC; |