|
@@ -4675,7 +4675,7 @@ error_return:
|
|
*
|
|
*
|
|
* This marks the blocks as free in the bitmap and buddy.
|
|
* This marks the blocks as free in the bitmap and buddy.
|
|
*/
|
|
*/
|
|
-void ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
|
|
|
|
|
|
+int ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
|
|
ext4_fsblk_t block, unsigned long count)
|
|
ext4_fsblk_t block, unsigned long count)
|
|
{
|
|
{
|
|
struct buffer_head *bitmap_bh = NULL;
|
|
struct buffer_head *bitmap_bh = NULL;
|
|
@@ -4696,15 +4696,24 @@ void ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
|
|
* Check to see if we are freeing blocks across a group
|
|
* Check to see if we are freeing blocks across a group
|
|
* boundary.
|
|
* boundary.
|
|
*/
|
|
*/
|
|
- if (bit + count > EXT4_BLOCKS_PER_GROUP(sb))
|
|
|
|
|
|
+ if (bit + count > EXT4_BLOCKS_PER_GROUP(sb)) {
|
|
|
|
+ ext4_warning(sb, "too much blocks added to group %u\n",
|
|
|
|
+ block_group);
|
|
|
|
+ err = -EINVAL;
|
|
goto error_return;
|
|
goto error_return;
|
|
|
|
+ }
|
|
|
|
|
|
bitmap_bh = ext4_read_block_bitmap(sb, block_group);
|
|
bitmap_bh = ext4_read_block_bitmap(sb, block_group);
|
|
- if (!bitmap_bh)
|
|
|
|
|
|
+ if (!bitmap_bh) {
|
|
|
|
+ err = -EIO;
|
|
goto error_return;
|
|
goto error_return;
|
|
|
|
+ }
|
|
|
|
+
|
|
desc = ext4_get_group_desc(sb, block_group, &gd_bh);
|
|
desc = ext4_get_group_desc(sb, block_group, &gd_bh);
|
|
- if (!desc)
|
|
|
|
|
|
+ if (!desc) {
|
|
|
|
+ err = -EIO;
|
|
goto error_return;
|
|
goto error_return;
|
|
|
|
+ }
|
|
|
|
|
|
if (in_range(ext4_block_bitmap(sb, desc), block, count) ||
|
|
if (in_range(ext4_block_bitmap(sb, desc), block, count) ||
|
|
in_range(ext4_inode_bitmap(sb, desc), block, count) ||
|
|
in_range(ext4_inode_bitmap(sb, desc), block, count) ||
|
|
@@ -4714,6 +4723,7 @@ void ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
|
|
ext4_error(sb, "Adding blocks in system zones - "
|
|
ext4_error(sb, "Adding blocks in system zones - "
|
|
"Block = %llu, count = %lu",
|
|
"Block = %llu, count = %lu",
|
|
block, count);
|
|
block, count);
|
|
|
|
+ err = -EINVAL;
|
|
goto error_return;
|
|
goto error_return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4782,7 +4792,7 @@ void ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
|
|
error_return:
|
|
error_return:
|
|
brelse(bitmap_bh);
|
|
brelse(bitmap_bh);
|
|
ext4_std_error(sb, err);
|
|
ext4_std_error(sb, err);
|
|
- return;
|
|
|
|
|
|
+ return err;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|