|
@@ -484,11 +484,16 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
|
|
|
|
|
|
free_clusters = percpu_counter_read_positive(fcc);
|
|
|
dirty_clusters = percpu_counter_read_positive(dcc);
|
|
|
- root_clusters = EXT4_B2C(sbi, ext4_r_blocks_count(sbi->s_es));
|
|
|
+
|
|
|
+ /*
|
|
|
+ * r_blocks_count should always be multiple of the cluster ratio so
|
|
|
+ * we are safe to do a plane bit shift only.
|
|
|
+ */
|
|
|
+ root_clusters = ext4_r_blocks_count(sbi->s_es) >> sbi->s_cluster_bits;
|
|
|
|
|
|
if (free_clusters - (nclusters + root_clusters + dirty_clusters) <
|
|
|
EXT4_FREECLUSTERS_WATERMARK) {
|
|
|
- free_clusters = EXT4_C2B(sbi, percpu_counter_sum_positive(fcc));
|
|
|
+ free_clusters = percpu_counter_sum_positive(fcc);
|
|
|
dirty_clusters = percpu_counter_sum_positive(dcc);
|
|
|
}
|
|
|
/* Check whether we have space after accounting for current
|