diff options
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 8fd6c567964a..91ae46098ea4 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -3023,6 +3023,14 @@ out: | |||
3023 | return err; | 3023 | return err; |
3024 | } | 3024 | } |
3025 | 3025 | ||
3026 | static void unmap_underlying_metadata_blocks(struct block_device *bdev, | ||
3027 | sector_t block, int count) | ||
3028 | { | ||
3029 | int i; | ||
3030 | for (i = 0; i < count; i++) | ||
3031 | unmap_underlying_metadata(bdev, block + i); | ||
3032 | } | ||
3033 | |||
3026 | static int | 3034 | static int |
3027 | ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, | 3035 | ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, |
3028 | ext4_lblk_t iblock, unsigned int max_blocks, | 3036 | ext4_lblk_t iblock, unsigned int max_blocks, |
@@ -3098,6 +3106,18 @@ out: | |||
3098 | } else | 3106 | } else |
3099 | allocated = ret; | 3107 | allocated = ret; |
3100 | set_buffer_new(bh_result); | 3108 | set_buffer_new(bh_result); |
3109 | /* | ||
3110 | * if we allocated more blocks than requested | ||
3111 | * we need to make sure we unmap the extra block | ||
3112 | * allocated. The actual needed block will get | ||
3113 | * unmapped later when we find the buffer_head marked | ||
3114 | * new. | ||
3115 | */ | ||
3116 | if (allocated > max_blocks) { | ||
3117 | unmap_underlying_metadata_blocks(inode->i_sb->s_bdev, | ||
3118 | newblock + max_blocks, | ||
3119 | allocated - max_blocks); | ||
3120 | } | ||
3101 | map_out: | 3121 | map_out: |
3102 | set_buffer_mapped(bh_result); | 3122 | set_buffer_mapped(bh_result); |
3103 | out1: | 3123 | out1: |