diff options
author | Theodore Ts'o <tytso@mit.edu> | 2011-09-09 18:58:51 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-09-09 18:58:51 -0400 |
commit | 24aaa8ef4e2b5764ada1fc69787e2fbd4f6276e5 (patch) | |
tree | 7f83cc8e52b5f2edc5d89d2d1808d0972831f9bf | |
parent | 5704265188ffe4290ed73b3cb685206c3ed8209d (diff) |
ext4: convert the free_blocks field in s_flex_groups to be free_clusters
Convert the free_blocks to be free_clusters to make the final revised
bigalloc changes easier to read/understand.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r-- | fs/ext4/ext4.h | 2 | ||||
-rw-r--r-- | fs/ext4/ialloc.c | 40 | ||||
-rw-r--r-- | fs/ext4/mballoc.c | 9 | ||||
-rw-r--r-- | fs/ext4/resize.c | 4 | ||||
-rw-r--r-- | fs/ext4/super.c | 2 |
5 files changed, 30 insertions, 27 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index c7588366471c..d2584224c89a 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -300,7 +300,7 @@ struct ext4_group_desc | |||
300 | 300 | ||
301 | struct flex_groups { | 301 | struct flex_groups { |
302 | atomic_t free_inodes; | 302 | atomic_t free_inodes; |
303 | atomic_t free_blocks; | 303 | atomic_t free_clusters; |
304 | atomic_t used_dirs; | 304 | atomic_t used_dirs; |
305 | }; | 305 | }; |
306 | 306 | ||
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 58115bad163f..0be5862313f0 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
@@ -346,7 +346,7 @@ static int find_group_flex(struct super_block *sb, struct inode *parent, | |||
346 | int flex_size = ext4_flex_bg_size(sbi); | 346 | int flex_size = ext4_flex_bg_size(sbi); |
347 | ext4_group_t best_flex = parent_fbg_group; | 347 | ext4_group_t best_flex = parent_fbg_group; |
348 | int blocks_per_flex = sbi->s_blocks_per_group * flex_size; | 348 | int blocks_per_flex = sbi->s_blocks_per_group * flex_size; |
349 | int flexbg_free_blocks; | 349 | int flexbg_free_clusters; |
350 | int flex_freeb_ratio; | 350 | int flex_freeb_ratio; |
351 | ext4_group_t n_fbg_groups; | 351 | ext4_group_t n_fbg_groups; |
352 | ext4_group_t i; | 352 | ext4_group_t i; |
@@ -355,8 +355,9 @@ static int find_group_flex(struct super_block *sb, struct inode *parent, | |||
355 | sbi->s_log_groups_per_flex; | 355 | sbi->s_log_groups_per_flex; |
356 | 356 | ||
357 | find_close_to_parent: | 357 | find_close_to_parent: |
358 | flexbg_free_blocks = atomic_read(&flex_group[best_flex].free_blocks); | 358 | flexbg_free_clusters = atomic_read(&flex_group[best_flex].free_clusters); |
359 | flex_freeb_ratio = flexbg_free_blocks * 100 / blocks_per_flex; | 359 | flex_freeb_ratio = EXT4_C2B(sbi, flexbg_free_clusters) * 100 / |
360 | blocks_per_flex; | ||
360 | if (atomic_read(&flex_group[best_flex].free_inodes) && | 361 | if (atomic_read(&flex_group[best_flex].free_inodes) && |
361 | flex_freeb_ratio > free_block_ratio) | 362 | flex_freeb_ratio > free_block_ratio) |
362 | goto found_flexbg; | 363 | goto found_flexbg; |
@@ -370,8 +371,9 @@ find_close_to_parent: | |||
370 | if (i == parent_fbg_group || i == parent_fbg_group - 1) | 371 | if (i == parent_fbg_group || i == parent_fbg_group - 1) |
371 | continue; | 372 | continue; |
372 | 373 | ||
373 | flexbg_free_blocks = atomic_read(&flex_group[i].free_blocks); | 374 | flexbg_free_clusters = atomic_read(&flex_group[i].free_clusters); |
374 | flex_freeb_ratio = flexbg_free_blocks * 100 / blocks_per_flex; | 375 | flex_freeb_ratio = EXT4_C2B(sbi, flexbg_free_clusters) * 100 / |
376 | blocks_per_flex; | ||
375 | 377 | ||
376 | if (flex_freeb_ratio > free_block_ratio && | 378 | if (flex_freeb_ratio > free_block_ratio && |
377 | (atomic_read(&flex_group[i].free_inodes))) { | 379 | (atomic_read(&flex_group[i].free_inodes))) { |
@@ -380,14 +382,14 @@ find_close_to_parent: | |||
380 | } | 382 | } |
381 | 383 | ||
382 | if ((atomic_read(&flex_group[best_flex].free_inodes) == 0) || | 384 | if ((atomic_read(&flex_group[best_flex].free_inodes) == 0) || |
383 | ((atomic_read(&flex_group[i].free_blocks) > | 385 | ((atomic_read(&flex_group[i].free_clusters) > |
384 | atomic_read(&flex_group[best_flex].free_blocks)) && | 386 | atomic_read(&flex_group[best_flex].free_clusters)) && |
385 | atomic_read(&flex_group[i].free_inodes))) | 387 | atomic_read(&flex_group[i].free_inodes))) |
386 | best_flex = i; | 388 | best_flex = i; |
387 | } | 389 | } |
388 | 390 | ||
389 | if (!atomic_read(&flex_group[best_flex].free_inodes) || | 391 | if (!atomic_read(&flex_group[best_flex].free_inodes) || |
390 | !atomic_read(&flex_group[best_flex].free_blocks)) | 392 | !atomic_read(&flex_group[best_flex].free_clusters)) |
391 | return -1; | 393 | return -1; |
392 | 394 | ||
393 | found_flexbg: | 395 | found_flexbg: |
@@ -407,7 +409,7 @@ out: | |||
407 | 409 | ||
408 | struct orlov_stats { | 410 | struct orlov_stats { |
409 | __u32 free_inodes; | 411 | __u32 free_inodes; |
410 | __u32 free_blocks; | 412 | __u32 free_clusters; |
411 | __u32 used_dirs; | 413 | __u32 used_dirs; |
412 | }; | 414 | }; |
413 | 415 | ||
@@ -424,7 +426,7 @@ static void get_orlov_stats(struct super_block *sb, ext4_group_t g, | |||
424 | 426 | ||
425 | if (flex_size > 1) { | 427 | if (flex_size > 1) { |
426 | stats->free_inodes = atomic_read(&flex_group[g].free_inodes); | 428 | stats->free_inodes = atomic_read(&flex_group[g].free_inodes); |
427 | stats->free_blocks = atomic_read(&flex_group[g].free_blocks); | 429 | stats->free_clusters = atomic_read(&flex_group[g].free_clusters); |
428 | stats->used_dirs = atomic_read(&flex_group[g].used_dirs); | 430 | stats->used_dirs = atomic_read(&flex_group[g].used_dirs); |
429 | return; | 431 | return; |
430 | } | 432 | } |
@@ -432,11 +434,11 @@ static void get_orlov_stats(struct super_block *sb, ext4_group_t g, | |||
432 | desc = ext4_get_group_desc(sb, g, NULL); | 434 | desc = ext4_get_group_desc(sb, g, NULL); |
433 | if (desc) { | 435 | if (desc) { |
434 | stats->free_inodes = ext4_free_inodes_count(sb, desc); | 436 | stats->free_inodes = ext4_free_inodes_count(sb, desc); |
435 | stats->free_blocks = ext4_free_blks_count(sb, desc); | 437 | stats->free_clusters = ext4_free_blks_count(sb, desc); |
436 | stats->used_dirs = ext4_used_dirs_count(sb, desc); | 438 | stats->used_dirs = ext4_used_dirs_count(sb, desc); |
437 | } else { | 439 | } else { |
438 | stats->free_inodes = 0; | 440 | stats->free_inodes = 0; |
439 | stats->free_blocks = 0; | 441 | stats->free_clusters = 0; |
440 | stats->used_dirs = 0; | 442 | stats->used_dirs = 0; |
441 | } | 443 | } |
442 | } | 444 | } |
@@ -471,10 +473,10 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent, | |||
471 | ext4_group_t real_ngroups = ext4_get_groups_count(sb); | 473 | ext4_group_t real_ngroups = ext4_get_groups_count(sb); |
472 | int inodes_per_group = EXT4_INODES_PER_GROUP(sb); | 474 | int inodes_per_group = EXT4_INODES_PER_GROUP(sb); |
473 | unsigned int freei, avefreei; | 475 | unsigned int freei, avefreei; |
474 | ext4_fsblk_t freeb, avefreeb; | 476 | ext4_fsblk_t freeb, avefreec; |
475 | unsigned int ndirs; | 477 | unsigned int ndirs; |
476 | int max_dirs, min_inodes; | 478 | int max_dirs, min_inodes; |
477 | ext4_grpblk_t min_blocks; | 479 | ext4_grpblk_t min_clusters; |
478 | ext4_group_t i, grp, g, ngroups; | 480 | ext4_group_t i, grp, g, ngroups; |
479 | struct ext4_group_desc *desc; | 481 | struct ext4_group_desc *desc; |
480 | struct orlov_stats stats; | 482 | struct orlov_stats stats; |
@@ -492,8 +494,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent, | |||
492 | avefreei = freei / ngroups; | 494 | avefreei = freei / ngroups; |
493 | freeb = EXT4_C2B(sbi, | 495 | freeb = EXT4_C2B(sbi, |
494 | percpu_counter_read_positive(&sbi->s_freeclusters_counter)); | 496 | percpu_counter_read_positive(&sbi->s_freeclusters_counter)); |
495 | avefreeb = freeb; | 497 | avefreec = freeb; |
496 | do_div(avefreeb, ngroups); | 498 | do_div(avefreec, ngroups); |
497 | ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter); | 499 | ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter); |
498 | 500 | ||
499 | if (S_ISDIR(mode) && | 501 | if (S_ISDIR(mode) && |
@@ -519,7 +521,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent, | |||
519 | continue; | 521 | continue; |
520 | if (stats.free_inodes < avefreei) | 522 | if (stats.free_inodes < avefreei) |
521 | continue; | 523 | continue; |
522 | if (stats.free_blocks < avefreeb) | 524 | if (stats.free_clusters < avefreec) |
523 | continue; | 525 | continue; |
524 | grp = g; | 526 | grp = g; |
525 | ret = 0; | 527 | ret = 0; |
@@ -557,7 +559,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent, | |||
557 | min_inodes = avefreei - inodes_per_group*flex_size / 4; | 559 | min_inodes = avefreei - inodes_per_group*flex_size / 4; |
558 | if (min_inodes < 1) | 560 | if (min_inodes < 1) |
559 | min_inodes = 1; | 561 | min_inodes = 1; |
560 | min_blocks = avefreeb - EXT4_BLOCKS_PER_GROUP(sb)*flex_size / 4; | 562 | min_clusters = avefreec - EXT4_CLUSTERS_PER_GROUP(sb)*flex_size / 4; |
561 | 563 | ||
562 | /* | 564 | /* |
563 | * Start looking in the flex group where we last allocated an | 565 | * Start looking in the flex group where we last allocated an |
@@ -576,7 +578,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent, | |||
576 | continue; | 578 | continue; |
577 | if (stats.free_inodes < min_inodes) | 579 | if (stats.free_inodes < min_inodes) |
578 | continue; | 580 | continue; |
579 | if (stats.free_blocks < min_blocks) | 581 | if (stats.free_clusters < min_clusters) |
580 | continue; | 582 | continue; |
581 | goto found_flex_bg; | 583 | goto found_flex_bg; |
582 | } | 584 | } |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 4a38b65bd564..f8e37cf2c2dd 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -2847,7 +2847,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, | |||
2847 | ext4_group_t flex_group = ext4_flex_group(sbi, | 2847 | ext4_group_t flex_group = ext4_flex_group(sbi, |
2848 | ac->ac_b_ex.fe_group); | 2848 | ac->ac_b_ex.fe_group); |
2849 | atomic_sub(ac->ac_b_ex.fe_len, | 2849 | atomic_sub(ac->ac_b_ex.fe_len, |
2850 | &sbi->s_flex_groups[flex_group].free_blocks); | 2850 | &sbi->s_flex_groups[flex_group].free_clusters); |
2851 | } | 2851 | } |
2852 | 2852 | ||
2853 | err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh); | 2853 | err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh); |
@@ -4696,7 +4696,8 @@ do_more: | |||
4696 | 4696 | ||
4697 | if (sbi->s_log_groups_per_flex) { | 4697 | if (sbi->s_log_groups_per_flex) { |
4698 | ext4_group_t flex_group = ext4_flex_group(sbi, block_group); | 4698 | ext4_group_t flex_group = ext4_flex_group(sbi, block_group); |
4699 | atomic_add(count, &sbi->s_flex_groups[flex_group].free_blocks); | 4699 | atomic_add(count_clusters, |
4700 | &sbi->s_flex_groups[flex_group].free_clusters); | ||
4700 | } | 4701 | } |
4701 | 4702 | ||
4702 | ext4_mb_unload_buddy(&e4b); | 4703 | ext4_mb_unload_buddy(&e4b); |
@@ -4839,8 +4840,8 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb, | |||
4839 | 4840 | ||
4840 | if (sbi->s_log_groups_per_flex) { | 4841 | if (sbi->s_log_groups_per_flex) { |
4841 | ext4_group_t flex_group = ext4_flex_group(sbi, block_group); | 4842 | ext4_group_t flex_group = ext4_flex_group(sbi, block_group); |
4842 | atomic_add(blocks_freed, | 4843 | atomic_add(EXT4_B2C(sbi, blocks_freed), |
4843 | &sbi->s_flex_groups[flex_group].free_blocks); | 4844 | &sbi->s_flex_groups[flex_group].free_clusters); |
4844 | } | 4845 | } |
4845 | 4846 | ||
4846 | ext4_mb_unload_buddy(&e4b); | 4847 | ext4_mb_unload_buddy(&e4b); |
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index a324a537f2dc..95a09ddca3b9 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
@@ -946,8 +946,8 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) | |||
946 | sbi->s_log_groups_per_flex) { | 946 | sbi->s_log_groups_per_flex) { |
947 | ext4_group_t flex_group; | 947 | ext4_group_t flex_group; |
948 | flex_group = ext4_flex_group(sbi, input->group); | 948 | flex_group = ext4_flex_group(sbi, input->group); |
949 | atomic_add(input->free_blocks_count, | 949 | atomic_add(EXT4_B2C(sbi, input->free_blocks_count), |
950 | &sbi->s_flex_groups[flex_group].free_blocks); | 950 | &sbi->s_flex_groups[flex_group].free_clusters); |
951 | atomic_add(EXT4_INODES_PER_GROUP(sb), | 951 | atomic_add(EXT4_INODES_PER_GROUP(sb), |
952 | &sbi->s_flex_groups[flex_group].free_inodes); | 952 | &sbi->s_flex_groups[flex_group].free_inodes); |
953 | } | 953 | } |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index f81e7e791655..d7e0e045b11b 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -2035,7 +2035,7 @@ static int ext4_fill_flex_info(struct super_block *sb) | |||
2035 | atomic_add(ext4_free_inodes_count(sb, gdp), | 2035 | atomic_add(ext4_free_inodes_count(sb, gdp), |
2036 | &sbi->s_flex_groups[flex_group].free_inodes); | 2036 | &sbi->s_flex_groups[flex_group].free_inodes); |
2037 | atomic_add(ext4_free_blks_count(sb, gdp), | 2037 | atomic_add(ext4_free_blks_count(sb, gdp), |
2038 | &sbi->s_flex_groups[flex_group].free_blocks); | 2038 | &sbi->s_flex_groups[flex_group].free_clusters); |
2039 | atomic_add(ext4_used_dirs_count(sb, gdp), | 2039 | atomic_add(ext4_used_dirs_count(sb, gdp), |
2040 | &sbi->s_flex_groups[flex_group].used_dirs); | 2040 | &sbi->s_flex_groups[flex_group].used_dirs); |
2041 | } | 2041 | } |