aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3/balloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext3/balloc.c')
-rw-r--r--fs/ext3/balloc.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index b1633cd28eca..96172e89ddc3 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -168,8 +168,7 @@ goal_in_my_reservation(struct ext3_reserve_window *rsv, ext3_grpblk_t grp_goal,
168{ 168{
169 ext3_fsblk_t group_first_block, group_last_block; 169 ext3_fsblk_t group_first_block, group_last_block;
170 170
171 group_first_block = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) + 171 group_first_block = ext3_group_first_block_no(sb, group);
172 group * EXT3_BLOCKS_PER_GROUP(sb);
173 group_last_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1; 172 group_last_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1;
174 173
175 if ((rsv->_rsv_start > group_last_block) || 174 if ((rsv->_rsv_start > group_last_block) ||
@@ -664,9 +663,7 @@ ext3_try_to_allocate(struct super_block *sb, handle_t *handle, int group,
664 663
665 /* we do allocation within the reservation window if we have a window */ 664 /* we do allocation within the reservation window if we have a window */
666 if (my_rsv) { 665 if (my_rsv) {
667 group_first_block = 666 group_first_block = ext3_group_first_block_no(sb, group);
668 le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) +
669 group * EXT3_BLOCKS_PER_GROUP(sb);
670 if (my_rsv->_rsv_start >= group_first_block) 667 if (my_rsv->_rsv_start >= group_first_block)
671 start = my_rsv->_rsv_start - group_first_block; 668 start = my_rsv->_rsv_start - group_first_block;
672 else 669 else
@@ -900,8 +897,7 @@ static int alloc_new_reservation(struct ext3_reserve_window_node *my_rsv,
900 int ret; 897 int ret;
901 spinlock_t *rsv_lock = &EXT3_SB(sb)->s_rsv_window_lock; 898 spinlock_t *rsv_lock = &EXT3_SB(sb)->s_rsv_window_lock;
902 899
903 group_first_block = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) + 900 group_first_block = ext3_group_first_block_no(sb, group);
904 group * EXT3_BLOCKS_PER_GROUP(sb);
905 group_end_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1; 901 group_end_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1;
906 902
907 if (grp_goal < 0) 903 if (grp_goal < 0)
@@ -1104,8 +1100,7 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1104 * first block is a filesystem wide block number 1100 * first block is a filesystem wide block number
1105 * first block is the block number of the first block in this group 1101 * first block is the block number of the first block in this group
1106 */ 1102 */
1107 group_first_block = le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block) + 1103 group_first_block = ext3_group_first_block_no(sb, group);
1108 group * EXT3_BLOCKS_PER_GROUP(sb);
1109 1104
1110 /* 1105 /*
1111 * Basically we will allocate a new block from inode's reservation 1106 * Basically we will allocate a new block from inode's reservation
@@ -1371,8 +1366,7 @@ allocated:
1371 if (fatal) 1366 if (fatal)
1372 goto out; 1367 goto out;
1373 1368
1374 ret_block = grp_alloc_blk + group_no * EXT3_BLOCKS_PER_GROUP(sb) 1369 ret_block = grp_alloc_blk + ext3_group_first_block_no(sb, group_no);
1375 + le32_to_cpu(es->s_first_data_block);
1376 1370
1377 if (in_range(le32_to_cpu(gdp->bg_block_bitmap), ret_block, num) || 1371 if (in_range(le32_to_cpu(gdp->bg_block_bitmap), ret_block, num) ||
1378 in_range(le32_to_cpu(gdp->bg_inode_bitmap), ret_block, num) || 1372 in_range(le32_to_cpu(gdp->bg_inode_bitmap), ret_block, num) ||
@@ -1478,15 +1472,16 @@ ext3_fsblk_t ext3_new_block(handle_t *handle, struct inode *inode,
1478 return ext3_new_blocks(handle, inode, goal, &count, errp); 1472 return ext3_new_blocks(handle, inode, goal, &count, errp);
1479} 1473}
1480 1474
1481unsigned long ext3_count_free_blocks(struct super_block *sb) 1475ext3_fsblk_t ext3_count_free_blocks(struct super_block *sb)
1482{ 1476{
1483 unsigned long desc_count; 1477 ext3_fsblk_t desc_count;
1484 struct ext3_group_desc *gdp; 1478 struct ext3_group_desc *gdp;
1485 int i; 1479 int i;
1486 unsigned long ngroups = EXT3_SB(sb)->s_groups_count; 1480 unsigned long ngroups = EXT3_SB(sb)->s_groups_count;
1487#ifdef EXT3FS_DEBUG 1481#ifdef EXT3FS_DEBUG
1488 struct ext3_super_block *es; 1482 struct ext3_super_block *es;
1489 unsigned long bitmap_count, x; 1483 ext3_fsblk_t bitmap_count;
1484 unsigned long x;
1490 struct buffer_head *bitmap_bh = NULL; 1485 struct buffer_head *bitmap_bh = NULL;
1491 1486
1492 es = EXT3_SB(sb)->s_es; 1487 es = EXT3_SB(sb)->s_es;
@@ -1511,8 +1506,10 @@ unsigned long ext3_count_free_blocks(struct super_block *sb)
1511 bitmap_count += x; 1506 bitmap_count += x;
1512 } 1507 }
1513 brelse(bitmap_bh); 1508 brelse(bitmap_bh);
1514 printk("ext3_count_free_blocks: stored = %u, computed = %lu, %lu\n", 1509 printk("ext3_count_free_blocks: stored = "E3FSBLK
1515 le32_to_cpu(es->s_free_blocks_count), desc_count, bitmap_count); 1510 ", computed = "E3FSBLK", "E3FSBLK"\n",
1511 le32_to_cpu(es->s_free_blocks_count),
1512 desc_count, bitmap_count);
1516 return bitmap_count; 1513 return bitmap_count;
1517#else 1514#else
1518 desc_count = 0; 1515 desc_count = 0;