diff options
| -rw-r--r-- | fs/ext4/inode.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 2d54c822c4c3..5e17d5f22a7e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
| @@ -1005,6 +1005,9 @@ static int ext4_indirect_calc_metadata_amount(struct inode *inode, int blocks) | |||
| 1005 | */ | 1005 | */ |
| 1006 | static int ext4_calc_metadata_amount(struct inode *inode, int blocks) | 1006 | static int ext4_calc_metadata_amount(struct inode *inode, int blocks) |
| 1007 | { | 1007 | { |
| 1008 | if (!blocks) | ||
| 1009 | return 0; | ||
| 1010 | |||
| 1008 | if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) | 1011 | if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) |
| 1009 | return ext4_ext_calc_metadata_amount(inode, blocks); | 1012 | return ext4_ext_calc_metadata_amount(inode, blocks); |
| 1010 | 1013 | ||
| @@ -1559,7 +1562,25 @@ static void ext4_da_release_space(struct inode *inode, int to_free) | |||
| 1559 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 1562 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
| 1560 | int total, mdb, mdb_free, release; | 1563 | int total, mdb, mdb_free, release; |
| 1561 | 1564 | ||
| 1565 | if (!to_free) | ||
| 1566 | return; /* Nothing to release, exit */ | ||
| 1567 | |||
| 1562 | spin_lock(&EXT4_I(inode)->i_block_reservation_lock); | 1568 | spin_lock(&EXT4_I(inode)->i_block_reservation_lock); |
| 1569 | |||
| 1570 | if (!EXT4_I(inode)->i_reserved_data_blocks) { | ||
| 1571 | /* | ||
| 1572 | * if there is no reserved blocks, but we try to free some | ||
| 1573 | * then the counter is messed up somewhere. | ||
| 1574 | * but since this function is called from invalidate | ||
| 1575 | * page, it's harmless to return without any action | ||
| 1576 | */ | ||
| 1577 | printk(KERN_INFO "ext4 delalloc try to release %d reserved " | ||
| 1578 | "blocks for inode %lu, but there is no reserved " | ||
| 1579 | "data blocks\n", to_free, inode->i_ino); | ||
| 1580 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | ||
| 1581 | return; | ||
| 1582 | } | ||
| 1583 | |||
| 1563 | /* recalculate the number of metablocks still need to be reserved */ | 1584 | /* recalculate the number of metablocks still need to be reserved */ |
| 1564 | total = EXT4_I(inode)->i_reserved_data_blocks - to_free; | 1585 | total = EXT4_I(inode)->i_reserved_data_blocks - to_free; |
| 1565 | mdb = ext4_calc_metadata_amount(inode, total); | 1586 | mdb = ext4_calc_metadata_amount(inode, total); |
