Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24087
b: refs/heads/master
c: faa5697
h: refs/heads/master
i:
  24085: fe2e412
  24083: 6f476e7
  24079: cc23795
v: v3
  • Loading branch information
Mingming Cao authored and Linus Torvalds committed Mar 26, 2006
1 parent f5f5e56 commit f90db07
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b54e41ec17ae91dce174eb5a3515e7af4a440d42
refs/heads/master: faa569763a7753e0a7cb8fd3919a62c0f7cc1e3c
31 changes: 19 additions & 12 deletions trunk/fs/ext3/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ int ext3_new_blocks(handle_t *handle, struct inode *inode,
/*
* Check quota for allocation of this block.
*/
if (DQUOT_ALLOC_BLOCK(inode, 1)) {
if (DQUOT_ALLOC_BLOCK(inode, num)) {
*errp = -EDQUOT;
return 0;
}
Expand Down Expand Up @@ -1333,13 +1333,15 @@ int ext3_new_blocks(handle_t *handle, struct inode *inode,
target_block = ret_block + group_no * EXT3_BLOCKS_PER_GROUP(sb)
+ le32_to_cpu(es->s_first_data_block);

if (target_block == le32_to_cpu(gdp->bg_block_bitmap) ||
target_block == le32_to_cpu(gdp->bg_inode_bitmap) ||
if (in_range(le32_to_cpu(gdp->bg_block_bitmap), target_block, num) ||
in_range(le32_to_cpu(gdp->bg_inode_bitmap), target_block, num) ||
in_range(target_block, le32_to_cpu(gdp->bg_inode_table),
EXT3_SB(sb)->s_itb_per_group) ||
in_range(target_block + num - 1, le32_to_cpu(gdp->bg_inode_table),
EXT3_SB(sb)->s_itb_per_group))
ext3_error(sb, "ext3_new_block",
"Allocating block in system zone - "
"block = %u", target_block);
"blocks from %u, length %lu", target_block, num);

performed_allocation = 1;

Expand All @@ -1358,10 +1360,14 @@ int ext3_new_blocks(handle_t *handle, struct inode *inode,
jbd_lock_bh_state(bitmap_bh);
spin_lock(sb_bgl_lock(sbi, group_no));
if (buffer_jbd(bitmap_bh) && bh2jh(bitmap_bh)->b_committed_data) {
if (ext3_test_bit(ret_block,
bh2jh(bitmap_bh)->b_committed_data)) {
printk("%s: block was unexpectedly set in "
"b_committed_data\n", __FUNCTION__);
int i;

for (i = 0; i < num; i++) {
if (ext3_test_bit(ret_block,
bh2jh(bitmap_bh)->b_committed_data)) {
printk("%s: block was unexpectedly set in "
"b_committed_data\n", __FUNCTION__);
}
}
}
ext3_debug("found bit %d\n", ret_block);
Expand All @@ -1372,7 +1378,7 @@ int ext3_new_blocks(handle_t *handle, struct inode *inode,
/* ret_block was blockgroup-relative. Now it becomes fs-relative */
ret_block = target_block;

if (ret_block >= le32_to_cpu(es->s_blocks_count)) {
if (ret_block + num - 1 >= le32_to_cpu(es->s_blocks_count)) {
ext3_error(sb, "ext3_new_block",
"block(%d) >= blocks count(%d) - "
"block_group = %d, es == %p ", ret_block,
Expand All @@ -1390,9 +1396,9 @@ int ext3_new_blocks(handle_t *handle, struct inode *inode,

spin_lock(sb_bgl_lock(sbi, group_no));
gdp->bg_free_blocks_count =
cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count) - 1);
cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count) - num);
spin_unlock(sb_bgl_lock(sbi, group_no));
percpu_counter_mod(&sbi->s_freeblocks_counter, -1);
percpu_counter_mod(&sbi->s_freeblocks_counter, -num);

BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor");
err = ext3_journal_dirty_metadata(handle, gdp_bh);
Expand All @@ -1405,6 +1411,7 @@ int ext3_new_blocks(handle_t *handle, struct inode *inode,

*errp = 0;
brelse(bitmap_bh);
DQUOT_FREE_BLOCK(inode, *count-num);
*count = num;
return ret_block;

Expand All @@ -1419,7 +1426,7 @@ int ext3_new_blocks(handle_t *handle, struct inode *inode,
* Undo the block allocation
*/
if (!performed_allocation)
DQUOT_FREE_BLOCK(inode, 1);
DQUOT_FREE_BLOCK(inode, *count);
brelse(bitmap_bh);
return 0;
}
Expand Down

0 comments on commit f90db07

Please sign in to comment.