Commit 6f2080e6 authored by Dmitry Monakhov's avatar Dmitry Monakhov Committed by Theodore Ts'o

ext4: fix ext_remove_space for punch_hole case

Inode is allowed to have empty leaf only if it this is blockless inode.
Signed-off-by: default avatarDmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 02d262df
...@@ -2589,7 +2589,7 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start, ...@@ -2589,7 +2589,7 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
struct ext4_ext_path *path = NULL; struct ext4_ext_path *path = NULL;
ext4_fsblk_t partial_cluster = 0; ext4_fsblk_t partial_cluster = 0;
handle_t *handle; handle_t *handle;
int i = 0, err; int i = 0, err = 0;
ext_debug("truncate since %u to %u\n", start, end); ext_debug("truncate since %u to %u\n", start, end);
...@@ -2621,12 +2621,16 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start, ...@@ -2621,12 +2621,16 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
return PTR_ERR(path); return PTR_ERR(path);
} }
depth = ext_depth(inode); depth = ext_depth(inode);
/* Leaf not may not exist only if inode has no blocks at all */
ex = path[depth].p_ext; ex = path[depth].p_ext;
if (!ex) { if (!ex) {
ext4_ext_drop_refs(path); if (depth) {
kfree(path); EXT4_ERROR_INODE(inode,
path = NULL; "path[%d].p_hdr == NULL",
goto cont; depth);
err = -EIO;
}
goto out;
} }
ee_block = le32_to_cpu(ex->ee_block); ee_block = le32_to_cpu(ex->ee_block);
...@@ -2658,8 +2662,6 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start, ...@@ -2658,8 +2662,6 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
goto out; goto out;
} }
} }
cont:
/* /*
* We start scanning from right side, freeing all the blocks * We start scanning from right side, freeing all the blocks
* after i_size and walking into the tree depth-wise. * after i_size and walking into the tree depth-wise.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment