aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ext4/balloc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 33938c120c85..2f2e0da1a6b7 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -484,11 +484,16 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
484 484
485 free_clusters = percpu_counter_read_positive(fcc); 485 free_clusters = percpu_counter_read_positive(fcc);
486 dirty_clusters = percpu_counter_read_positive(dcc); 486 dirty_clusters = percpu_counter_read_positive(dcc);
487 root_clusters = EXT4_B2C(sbi, ext4_r_blocks_count(sbi->s_es)); 487
488 /*
489 * r_blocks_count should always be multiple of the cluster ratio so
490 * we are safe to do a plane bit shift only.
491 */
492 root_clusters = ext4_r_blocks_count(sbi->s_es) >> sbi->s_cluster_bits;
488 493
489 if (free_clusters - (nclusters + root_clusters + dirty_clusters) < 494 if (free_clusters - (nclusters + root_clusters + dirty_clusters) <
490 EXT4_FREECLUSTERS_WATERMARK) { 495 EXT4_FREECLUSTERS_WATERMARK) {
491 free_clusters = EXT4_C2B(sbi, percpu_counter_sum_positive(fcc)); 496 free_clusters = percpu_counter_sum_positive(fcc);
492 dirty_clusters = percpu_counter_sum_positive(dcc); 497 dirty_clusters = percpu_counter_sum_positive(dcc);
493 } 498 }
494 /* Check whether we have space after accounting for current 499 /* Check whether we have space after accounting for current