aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/balloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/balloc.c')
-rw-r--r--fs/ext4/balloc.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index cf1821784a16..2f2e0da1a6b7 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -358,7 +358,7 @@ void ext4_validate_block_bitmap(struct super_block *sb,
358} 358}
359 359
360/** 360/**
361 * ext4_read_block_bitmap() 361 * ext4_read_block_bitmap_nowait()
362 * @sb: super block 362 * @sb: super block
363 * @block_group: given block group 363 * @block_group: given block group
364 * 364 *
@@ -457,6 +457,8 @@ ext4_read_block_bitmap(struct super_block *sb, ext4_group_t block_group)
457 struct buffer_head *bh; 457 struct buffer_head *bh;
458 458
459 bh = ext4_read_block_bitmap_nowait(sb, block_group); 459 bh = ext4_read_block_bitmap_nowait(sb, block_group);
460 if (!bh)
461 return NULL;
460 if (ext4_wait_block_bitmap(sb, block_group, bh)) { 462 if (ext4_wait_block_bitmap(sb, block_group, bh)) {
461 put_bh(bh); 463 put_bh(bh);
462 return NULL; 464 return NULL;
@@ -482,11 +484,16 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
482 484
483 free_clusters = percpu_counter_read_positive(fcc); 485 free_clusters = percpu_counter_read_positive(fcc);
484 dirty_clusters = percpu_counter_read_positive(dcc); 486 dirty_clusters = percpu_counter_read_positive(dcc);
485 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;
486 493
487 if (free_clusters - (nclusters + root_clusters + dirty_clusters) < 494 if (free_clusters - (nclusters + root_clusters + dirty_clusters) <
488 EXT4_FREECLUSTERS_WATERMARK) { 495 EXT4_FREECLUSTERS_WATERMARK) {
489 free_clusters = EXT4_C2B(sbi, percpu_counter_sum_positive(fcc)); 496 free_clusters = percpu_counter_sum_positive(fcc);
490 dirty_clusters = percpu_counter_sum_positive(dcc); 497 dirty_clusters = percpu_counter_sum_positive(dcc);
491 } 498 }
492 /* Check whether we have space after accounting for current 499 /* Check whether we have space after accounting for current