diff options
author | Theodore Ts'o <tytso@mit.edu> | 2011-09-09 18:56:51 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-09-09 18:56:51 -0400 |
commit | 5704265188ffe4290ed73b3cb685206c3ed8209d (patch) | |
tree | 6bc51bea59625b2a7c8e4b74bbb66884371f74dd | |
parent | 0aa060000e83ca3d09ddc446a7174fb0820d99bc (diff) |
ext4: convert s_{dirty,free}blocks_counter to s_{dirty,free}clusters_counter
Convert the percpu counters s_dirtyblocks_counter and
s_freeblocks_counter in struct ext4_super_info to be
s_dirtyclusters_counter and s_freeclusters_counter.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r-- | fs/ext4/balloc.c | 10 | ||||
-rw-r--r-- | fs/ext4/ext4.h | 5 | ||||
-rw-r--r-- | fs/ext4/ialloc.c | 3 | ||||
-rw-r--r-- | fs/ext4/inode.c | 18 | ||||
-rw-r--r-- | fs/ext4/mballoc.c | 12 | ||||
-rw-r--r-- | fs/ext4/resize.c | 4 | ||||
-rw-r--r-- | fs/ext4/super.c | 29 |
7 files changed, 44 insertions, 37 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 89abf1f7b253..9080a857cda9 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
@@ -414,16 +414,16 @@ static int ext4_has_free_blocks(struct ext4_sb_info *sbi, | |||
414 | s64 nblocks, unsigned int flags) | 414 | s64 nblocks, unsigned int flags) |
415 | { | 415 | { |
416 | s64 free_blocks, dirty_blocks, root_blocks; | 416 | s64 free_blocks, dirty_blocks, root_blocks; |
417 | struct percpu_counter *fbc = &sbi->s_freeblocks_counter; | 417 | struct percpu_counter *fcc = &sbi->s_freeclusters_counter; |
418 | struct percpu_counter *dbc = &sbi->s_dirtyblocks_counter; | 418 | struct percpu_counter *dbc = &sbi->s_dirtyclusters_counter; |
419 | 419 | ||
420 | free_blocks = percpu_counter_read_positive(fbc); | 420 | free_blocks = percpu_counter_read_positive(fcc); |
421 | dirty_blocks = percpu_counter_read_positive(dbc); | 421 | dirty_blocks = percpu_counter_read_positive(dbc); |
422 | root_blocks = ext4_r_blocks_count(sbi->s_es); | 422 | root_blocks = ext4_r_blocks_count(sbi->s_es); |
423 | 423 | ||
424 | if (free_blocks - (nblocks + root_blocks + dirty_blocks) < | 424 | if (free_blocks - (nblocks + root_blocks + dirty_blocks) < |
425 | EXT4_FREEBLOCKS_WATERMARK) { | 425 | EXT4_FREEBLOCKS_WATERMARK) { |
426 | free_blocks = percpu_counter_sum_positive(fbc); | 426 | free_blocks = EXT4_C2B(sbi, percpu_counter_sum_positive(fcc)); |
427 | dirty_blocks = percpu_counter_sum_positive(dbc); | 427 | dirty_blocks = percpu_counter_sum_positive(dbc); |
428 | } | 428 | } |
429 | /* Check whether we have space after | 429 | /* Check whether we have space after |
@@ -449,7 +449,7 @@ int ext4_claim_free_blocks(struct ext4_sb_info *sbi, | |||
449 | s64 nblocks, unsigned int flags) | 449 | s64 nblocks, unsigned int flags) |
450 | { | 450 | { |
451 | if (ext4_has_free_blocks(sbi, nblocks, flags)) { | 451 | if (ext4_has_free_blocks(sbi, nblocks, flags)) { |
452 | percpu_counter_add(&sbi->s_dirtyblocks_counter, nblocks); | 452 | percpu_counter_add(&sbi->s_dirtyclusters_counter, nblocks); |
453 | return 0; | 453 | return 0; |
454 | } else | 454 | } else |
455 | return -ENOSPC; | 455 | return -ENOSPC; |
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 030bfc1cb59d..c7588366471c 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -855,6 +855,7 @@ struct ext4_inode_info { | |||
855 | ext4_group_t i_last_alloc_group; | 855 | ext4_group_t i_last_alloc_group; |
856 | 856 | ||
857 | /* allocation reservation info for delalloc */ | 857 | /* allocation reservation info for delalloc */ |
858 | /* In case of bigalloc, these refer to clusters rather than blocks */ | ||
858 | unsigned int i_reserved_data_blocks; | 859 | unsigned int i_reserved_data_blocks; |
859 | unsigned int i_reserved_meta_blocks; | 860 | unsigned int i_reserved_meta_blocks; |
860 | unsigned int i_allocated_meta_blocks; | 861 | unsigned int i_allocated_meta_blocks; |
@@ -1144,10 +1145,10 @@ struct ext4_sb_info { | |||
1144 | u32 s_hash_seed[4]; | 1145 | u32 s_hash_seed[4]; |
1145 | int s_def_hash_version; | 1146 | int s_def_hash_version; |
1146 | int s_hash_unsigned; /* 3 if hash should be signed, 0 if not */ | 1147 | int s_hash_unsigned; /* 3 if hash should be signed, 0 if not */ |
1147 | struct percpu_counter s_freeblocks_counter; | 1148 | struct percpu_counter s_freeclusters_counter; |
1148 | struct percpu_counter s_freeinodes_counter; | 1149 | struct percpu_counter s_freeinodes_counter; |
1149 | struct percpu_counter s_dirs_counter; | 1150 | struct percpu_counter s_dirs_counter; |
1150 | struct percpu_counter s_dirtyblocks_counter; | 1151 | struct percpu_counter s_dirtyclusters_counter; |
1151 | struct blockgroup_lock *s_blockgroup_lock; | 1152 | struct blockgroup_lock *s_blockgroup_lock; |
1152 | struct proc_dir_entry *s_proc; | 1153 | struct proc_dir_entry *s_proc; |
1153 | struct kobject s_kobj; | 1154 | struct kobject s_kobj; |
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index b7a8130d0af4..58115bad163f 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
@@ -490,7 +490,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent, | |||
490 | 490 | ||
491 | freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter); | 491 | freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter); |
492 | avefreei = freei / ngroups; | 492 | avefreei = freei / ngroups; |
493 | freeb = percpu_counter_read_positive(&sbi->s_freeblocks_counter); | 493 | freeb = EXT4_C2B(sbi, |
494 | percpu_counter_read_positive(&sbi->s_freeclusters_counter)); | ||
494 | avefreeb = freeb; | 495 | avefreeb = freeb; |
495 | do_div(avefreeb, ngroups); | 496 | do_div(avefreeb, ngroups); |
496 | ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter); | 497 | ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter); |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 904a9a623dab..40f51aae42fe 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -281,7 +281,7 @@ void ext4_da_update_reserve_space(struct inode *inode, | |||
281 | /* Update per-inode reservations */ | 281 | /* Update per-inode reservations */ |
282 | ei->i_reserved_data_blocks -= used; | 282 | ei->i_reserved_data_blocks -= used; |
283 | ei->i_reserved_meta_blocks -= ei->i_allocated_meta_blocks; | 283 | ei->i_reserved_meta_blocks -= ei->i_allocated_meta_blocks; |
284 | percpu_counter_sub(&sbi->s_dirtyblocks_counter, | 284 | percpu_counter_sub(&sbi->s_dirtyclusters_counter, |
285 | used + ei->i_allocated_meta_blocks); | 285 | used + ei->i_allocated_meta_blocks); |
286 | ei->i_allocated_meta_blocks = 0; | 286 | ei->i_allocated_meta_blocks = 0; |
287 | 287 | ||
@@ -291,7 +291,7 @@ void ext4_da_update_reserve_space(struct inode *inode, | |||
291 | * only when we have written all of the delayed | 291 | * only when we have written all of the delayed |
292 | * allocation blocks. | 292 | * allocation blocks. |
293 | */ | 293 | */ |
294 | percpu_counter_sub(&sbi->s_dirtyblocks_counter, | 294 | percpu_counter_sub(&sbi->s_dirtyclusters_counter, |
295 | ei->i_reserved_meta_blocks); | 295 | ei->i_reserved_meta_blocks); |
296 | ei->i_reserved_meta_blocks = 0; | 296 | ei->i_reserved_meta_blocks = 0; |
297 | ei->i_da_metadata_calc_len = 0; | 297 | ei->i_da_metadata_calc_len = 0; |
@@ -1119,14 +1119,14 @@ static void ext4_da_release_space(struct inode *inode, int to_free) | |||
1119 | * only when we have written all of the delayed | 1119 | * only when we have written all of the delayed |
1120 | * allocation blocks. | 1120 | * allocation blocks. |
1121 | */ | 1121 | */ |
1122 | percpu_counter_sub(&sbi->s_dirtyblocks_counter, | 1122 | percpu_counter_sub(&sbi->s_dirtyclusters_counter, |
1123 | ei->i_reserved_meta_blocks); | 1123 | ei->i_reserved_meta_blocks); |
1124 | ei->i_reserved_meta_blocks = 0; | 1124 | ei->i_reserved_meta_blocks = 0; |
1125 | ei->i_da_metadata_calc_len = 0; | 1125 | ei->i_da_metadata_calc_len = 0; |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | /* update fs dirty data blocks counter */ | 1128 | /* update fs dirty data blocks counter */ |
1129 | percpu_counter_sub(&sbi->s_dirtyblocks_counter, to_free); | 1129 | percpu_counter_sub(&sbi->s_dirtyclusters_counter, to_free); |
1130 | 1130 | ||
1131 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | 1131 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); |
1132 | 1132 | ||
@@ -1349,9 +1349,10 @@ static void ext4_print_free_blocks(struct inode *inode) | |||
1349 | ext4_count_free_blocks(inode->i_sb)); | 1349 | ext4_count_free_blocks(inode->i_sb)); |
1350 | printk(KERN_CRIT "Free/Dirty block details\n"); | 1350 | printk(KERN_CRIT "Free/Dirty block details\n"); |
1351 | printk(KERN_CRIT "free_blocks=%lld\n", | 1351 | printk(KERN_CRIT "free_blocks=%lld\n", |
1352 | (long long) percpu_counter_sum(&sbi->s_freeblocks_counter)); | 1352 | (long long) EXT4_C2B(EXT4_SB(inode->i_sb), |
1353 | percpu_counter_sum(&sbi->s_freeclusters_counter))); | ||
1353 | printk(KERN_CRIT "dirty_blocks=%lld\n", | 1354 | printk(KERN_CRIT "dirty_blocks=%lld\n", |
1354 | (long long) percpu_counter_sum(&sbi->s_dirtyblocks_counter)); | 1355 | (long long) percpu_counter_sum(&sbi->s_dirtyclusters_counter)); |
1355 | printk(KERN_CRIT "Block reservation details\n"); | 1356 | printk(KERN_CRIT "Block reservation details\n"); |
1356 | printk(KERN_CRIT "i_reserved_data_blocks=%u\n", | 1357 | printk(KERN_CRIT "i_reserved_data_blocks=%u\n", |
1357 | EXT4_I(inode)->i_reserved_data_blocks); | 1358 | EXT4_I(inode)->i_reserved_data_blocks); |
@@ -2226,8 +2227,9 @@ static int ext4_nonda_switch(struct super_block *sb) | |||
2226 | * Delalloc need an accurate free block accounting. So switch | 2227 | * Delalloc need an accurate free block accounting. So switch |
2227 | * to non delalloc when we are near to error range. | 2228 | * to non delalloc when we are near to error range. |
2228 | */ | 2229 | */ |
2229 | free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter); | 2230 | free_blocks = EXT4_C2B(sbi, |
2230 | dirty_blocks = percpu_counter_read_positive(&sbi->s_dirtyblocks_counter); | 2231 | percpu_counter_read_positive(&sbi->s_freeclusters_counter)); |
2232 | dirty_blocks = percpu_counter_read_positive(&sbi->s_dirtyclusters_counter); | ||
2231 | if (2 * free_blocks < 3 * dirty_blocks || | 2233 | if (2 * free_blocks < 3 * dirty_blocks || |
2232 | free_blocks < (dirty_blocks + EXT4_FREEBLOCKS_WATERMARK)) { | 2234 | free_blocks < (dirty_blocks + EXT4_FREEBLOCKS_WATERMARK)) { |
2233 | /* | 2235 | /* |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 57ce6960e940..4a38b65bd564 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -2834,13 +2834,14 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, | |||
2834 | gdp->bg_checksum = ext4_group_desc_csum(sbi, ac->ac_b_ex.fe_group, gdp); | 2834 | gdp->bg_checksum = ext4_group_desc_csum(sbi, ac->ac_b_ex.fe_group, gdp); |
2835 | 2835 | ||
2836 | ext4_unlock_group(sb, ac->ac_b_ex.fe_group); | 2836 | ext4_unlock_group(sb, ac->ac_b_ex.fe_group); |
2837 | percpu_counter_sub(&sbi->s_freeblocks_counter, ac->ac_b_ex.fe_len); | 2837 | percpu_counter_sub(&sbi->s_freeclusters_counter, ac->ac_b_ex.fe_len); |
2838 | /* | 2838 | /* |
2839 | * Now reduce the dirty block count also. Should not go negative | 2839 | * Now reduce the dirty block count also. Should not go negative |
2840 | */ | 2840 | */ |
2841 | if (!(ac->ac_flags & EXT4_MB_DELALLOC_RESERVED)) | 2841 | if (!(ac->ac_flags & EXT4_MB_DELALLOC_RESERVED)) |
2842 | /* release all the reserved blocks if non delalloc */ | 2842 | /* release all the reserved blocks if non delalloc */ |
2843 | percpu_counter_sub(&sbi->s_dirtyblocks_counter, reserv_clstrs); | 2843 | percpu_counter_sub(&sbi->s_dirtyclusters_counter, |
2844 | reserv_clstrs); | ||
2844 | 2845 | ||
2845 | if (sbi->s_log_groups_per_flex) { | 2846 | if (sbi->s_log_groups_per_flex) { |
2846 | ext4_group_t flex_group = ext4_flex_group(sbi, | 2847 | ext4_group_t flex_group = ext4_flex_group(sbi, |
@@ -4384,7 +4385,7 @@ out: | |||
4384 | if (!ext4_test_inode_state(ar->inode, | 4385 | if (!ext4_test_inode_state(ar->inode, |
4385 | EXT4_STATE_DELALLOC_RESERVED)) | 4386 | EXT4_STATE_DELALLOC_RESERVED)) |
4386 | /* release all the reserved blocks if non delalloc */ | 4387 | /* release all the reserved blocks if non delalloc */ |
4387 | percpu_counter_sub(&sbi->s_dirtyblocks_counter, | 4388 | percpu_counter_sub(&sbi->s_dirtyclusters_counter, |
4388 | reserv_clstrs); | 4389 | reserv_clstrs); |
4389 | } | 4390 | } |
4390 | 4391 | ||
@@ -4691,7 +4692,7 @@ do_more: | |||
4691 | ext4_free_blks_set(sb, gdp, ret); | 4692 | ext4_free_blks_set(sb, gdp, ret); |
4692 | gdp->bg_checksum = ext4_group_desc_csum(sbi, block_group, gdp); | 4693 | gdp->bg_checksum = ext4_group_desc_csum(sbi, block_group, gdp); |
4693 | ext4_unlock_group(sb, block_group); | 4694 | ext4_unlock_group(sb, block_group); |
4694 | percpu_counter_add(&sbi->s_freeblocks_counter, count); | 4695 | percpu_counter_add(&sbi->s_freeclusters_counter, count_clusters); |
4695 | 4696 | ||
4696 | if (sbi->s_log_groups_per_flex) { | 4697 | if (sbi->s_log_groups_per_flex) { |
4697 | ext4_group_t flex_group = ext4_flex_group(sbi, block_group); | 4698 | ext4_group_t flex_group = ext4_flex_group(sbi, block_group); |
@@ -4833,7 +4834,8 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb, | |||
4833 | ext4_free_blks_set(sb, desc, blk_free_count); | 4834 | ext4_free_blks_set(sb, desc, blk_free_count); |
4834 | desc->bg_checksum = ext4_group_desc_csum(sbi, block_group, desc); | 4835 | desc->bg_checksum = ext4_group_desc_csum(sbi, block_group, desc); |
4835 | ext4_unlock_group(sb, block_group); | 4836 | ext4_unlock_group(sb, block_group); |
4836 | percpu_counter_add(&sbi->s_freeblocks_counter, blocks_freed); | 4837 | percpu_counter_add(&sbi->s_freeclusters_counter, |
4838 | EXT4_B2C(sbi, blocks_freed)); | ||
4837 | 4839 | ||
4838 | if (sbi->s_log_groups_per_flex) { | 4840 | if (sbi->s_log_groups_per_flex) { |
4839 | ext4_group_t flex_group = ext4_flex_group(sbi, block_group); | 4841 | ext4_group_t flex_group = ext4_flex_group(sbi, block_group); |
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 707d3f16f7ce..a324a537f2dc 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
@@ -937,8 +937,8 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) | |||
937 | input->reserved_blocks); | 937 | input->reserved_blocks); |
938 | 938 | ||
939 | /* Update the free space counts */ | 939 | /* Update the free space counts */ |
940 | percpu_counter_add(&sbi->s_freeblocks_counter, | 940 | percpu_counter_add(&sbi->s_freeclusters_counter, |
941 | input->free_blocks_count); | 941 | EXT4_B2C(sbi, input->free_blocks_count)); |
942 | percpu_counter_add(&sbi->s_freeinodes_counter, | 942 | percpu_counter_add(&sbi->s_freeinodes_counter, |
943 | EXT4_INODES_PER_GROUP(sb)); | 943 | EXT4_INODES_PER_GROUP(sb)); |
944 | 944 | ||
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 25a4bfe3f39f..f81e7e791655 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -837,10 +837,10 @@ static void ext4_put_super(struct super_block *sb) | |||
837 | brelse(sbi->s_group_desc[i]); | 837 | brelse(sbi->s_group_desc[i]); |
838 | ext4_kvfree(sbi->s_group_desc); | 838 | ext4_kvfree(sbi->s_group_desc); |
839 | ext4_kvfree(sbi->s_flex_groups); | 839 | ext4_kvfree(sbi->s_flex_groups); |
840 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | 840 | percpu_counter_destroy(&sbi->s_freeclusters_counter); |
841 | percpu_counter_destroy(&sbi->s_freeinodes_counter); | 841 | percpu_counter_destroy(&sbi->s_freeinodes_counter); |
842 | percpu_counter_destroy(&sbi->s_dirs_counter); | 842 | percpu_counter_destroy(&sbi->s_dirs_counter); |
843 | percpu_counter_destroy(&sbi->s_dirtyblocks_counter); | 843 | percpu_counter_destroy(&sbi->s_dirtyclusters_counter); |
844 | brelse(sbi->s_sbh); | 844 | brelse(sbi->s_sbh); |
845 | #ifdef CONFIG_QUOTA | 845 | #ifdef CONFIG_QUOTA |
846 | for (i = 0; i < MAXQUOTAS; i++) | 846 | for (i = 0; i < MAXQUOTAS; i++) |
@@ -2473,7 +2473,7 @@ static ssize_t delayed_allocation_blocks_show(struct ext4_attr *a, | |||
2473 | char *buf) | 2473 | char *buf) |
2474 | { | 2474 | { |
2475 | return snprintf(buf, PAGE_SIZE, "%llu\n", | 2475 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
2476 | (s64) percpu_counter_sum(&sbi->s_dirtyblocks_counter)); | 2476 | (s64) percpu_counter_sum(&sbi->s_dirtyclusters_counter)); |
2477 | } | 2477 | } |
2478 | 2478 | ||
2479 | static ssize_t session_write_kbytes_show(struct ext4_attr *a, | 2479 | static ssize_t session_write_kbytes_show(struct ext4_attr *a, |
@@ -3575,7 +3575,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3575 | sbi->s_err_report.function = print_daily_error_info; | 3575 | sbi->s_err_report.function = print_daily_error_info; |
3576 | sbi->s_err_report.data = (unsigned long) sb; | 3576 | sbi->s_err_report.data = (unsigned long) sb; |
3577 | 3577 | ||
3578 | err = percpu_counter_init(&sbi->s_freeblocks_counter, | 3578 | err = percpu_counter_init(&sbi->s_freeclusters_counter, |
3579 | ext4_count_free_blocks(sb)); | 3579 | ext4_count_free_blocks(sb)); |
3580 | if (!err) { | 3580 | if (!err) { |
3581 | err = percpu_counter_init(&sbi->s_freeinodes_counter, | 3581 | err = percpu_counter_init(&sbi->s_freeinodes_counter, |
@@ -3586,7 +3586,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3586 | ext4_count_dirs(sb)); | 3586 | ext4_count_dirs(sb)); |
3587 | } | 3587 | } |
3588 | if (!err) { | 3588 | if (!err) { |
3589 | err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); | 3589 | err = percpu_counter_init(&sbi->s_dirtyclusters_counter, 0); |
3590 | } | 3590 | } |
3591 | if (err) { | 3591 | if (err) { |
3592 | ext4_msg(sb, KERN_ERR, "insufficient memory"); | 3592 | ext4_msg(sb, KERN_ERR, "insufficient memory"); |
@@ -3701,13 +3701,13 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3701 | * The journal may have updated the bg summary counts, so we | 3701 | * The journal may have updated the bg summary counts, so we |
3702 | * need to update the global counters. | 3702 | * need to update the global counters. |
3703 | */ | 3703 | */ |
3704 | percpu_counter_set(&sbi->s_freeblocks_counter, | 3704 | percpu_counter_set(&sbi->s_freeclusters_counter, |
3705 | ext4_count_free_blocks(sb)); | 3705 | ext4_count_free_blocks(sb)); |
3706 | percpu_counter_set(&sbi->s_freeinodes_counter, | 3706 | percpu_counter_set(&sbi->s_freeinodes_counter, |
3707 | ext4_count_free_inodes(sb)); | 3707 | ext4_count_free_inodes(sb)); |
3708 | percpu_counter_set(&sbi->s_dirs_counter, | 3708 | percpu_counter_set(&sbi->s_dirs_counter, |
3709 | ext4_count_dirs(sb)); | 3709 | ext4_count_dirs(sb)); |
3710 | percpu_counter_set(&sbi->s_dirtyblocks_counter, 0); | 3710 | percpu_counter_set(&sbi->s_dirtyclusters_counter, 0); |
3711 | 3711 | ||
3712 | no_journal: | 3712 | no_journal: |
3713 | /* | 3713 | /* |
@@ -3847,10 +3847,10 @@ failed_mount3: | |||
3847 | del_timer(&sbi->s_err_report); | 3847 | del_timer(&sbi->s_err_report); |
3848 | if (sbi->s_flex_groups) | 3848 | if (sbi->s_flex_groups) |
3849 | ext4_kvfree(sbi->s_flex_groups); | 3849 | ext4_kvfree(sbi->s_flex_groups); |
3850 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | 3850 | percpu_counter_destroy(&sbi->s_freeclusters_counter); |
3851 | percpu_counter_destroy(&sbi->s_freeinodes_counter); | 3851 | percpu_counter_destroy(&sbi->s_freeinodes_counter); |
3852 | percpu_counter_destroy(&sbi->s_dirs_counter); | 3852 | percpu_counter_destroy(&sbi->s_dirs_counter); |
3853 | percpu_counter_destroy(&sbi->s_dirtyblocks_counter); | 3853 | percpu_counter_destroy(&sbi->s_dirtyclusters_counter); |
3854 | if (sbi->s_mmp_tsk) | 3854 | if (sbi->s_mmp_tsk) |
3855 | kthread_stop(sbi->s_mmp_tsk); | 3855 | kthread_stop(sbi->s_mmp_tsk); |
3856 | failed_mount2: | 3856 | failed_mount2: |
@@ -4173,8 +4173,9 @@ static int ext4_commit_super(struct super_block *sb, int sync) | |||
4173 | else | 4173 | else |
4174 | es->s_kbytes_written = | 4174 | es->s_kbytes_written = |
4175 | cpu_to_le64(EXT4_SB(sb)->s_kbytes_written); | 4175 | cpu_to_le64(EXT4_SB(sb)->s_kbytes_written); |
4176 | ext4_free_blocks_count_set(es, percpu_counter_sum_positive( | 4176 | ext4_free_blocks_count_set(es, |
4177 | &EXT4_SB(sb)->s_freeblocks_counter)); | 4177 | EXT4_C2B(EXT4_SB(sb), percpu_counter_sum_positive( |
4178 | &EXT4_SB(sb)->s_freeclusters_counter))); | ||
4178 | es->s_free_inodes_count = | 4179 | es->s_free_inodes_count = |
4179 | cpu_to_le32(percpu_counter_sum_positive( | 4180 | cpu_to_le32(percpu_counter_sum_positive( |
4180 | &EXT4_SB(sb)->s_freeinodes_counter)); | 4181 | &EXT4_SB(sb)->s_freeinodes_counter)); |
@@ -4629,10 +4630,10 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
4629 | buf->f_type = EXT4_SUPER_MAGIC; | 4630 | buf->f_type = EXT4_SUPER_MAGIC; |
4630 | buf->f_bsize = sb->s_blocksize; | 4631 | buf->f_bsize = sb->s_blocksize; |
4631 | buf->f_blocks = ext4_blocks_count(es) - sbi->s_overhead_last; | 4632 | buf->f_blocks = ext4_blocks_count(es) - sbi->s_overhead_last; |
4632 | bfree = percpu_counter_sum_positive(&sbi->s_freeblocks_counter) - | 4633 | bfree = percpu_counter_sum_positive(&sbi->s_freeclusters_counter) - |
4633 | percpu_counter_sum_positive(&sbi->s_dirtyblocks_counter); | 4634 | percpu_counter_sum_positive(&sbi->s_dirtyclusters_counter); |
4634 | /* prevent underflow in case that few free space is available */ | 4635 | /* prevent underflow in case that few free space is available */ |
4635 | buf->f_bfree = max_t(s64, bfree, 0); | 4636 | buf->f_bfree = EXT4_C2B(sbi, max_t(s64, bfree, 0)); |
4636 | buf->f_bavail = buf->f_bfree - ext4_r_blocks_count(es); | 4637 | buf->f_bavail = buf->f_bfree - ext4_r_blocks_count(es); |
4637 | if (buf->f_bfree < ext4_r_blocks_count(es)) | 4638 | if (buf->f_bfree < ext4_r_blocks_count(es)) |
4638 | buf->f_bavail = 0; | 4639 | buf->f_bavail = 0; |