Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 319117
b: refs/heads/master
c: 968dee7
h: refs/heads/master
i:
  319115: 661ef6a
v: v3
  • Loading branch information
Ashish Sangwan authored and Theodore Ts'o committed Jul 23, 2012
1 parent cab38a0 commit b8ac1b9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 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: b50924c2c606eccfe0caef39beb0929dfa9a1a81
refs/heads/master: 968dee77220768a5f52cf8b21d0bdb73486febef
46 changes: 29 additions & 17 deletions trunk/fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -2569,10 +2569,10 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
{
struct super_block *sb = inode->i_sb;
int depth = ext_depth(inode);
struct ext4_ext_path *path;
struct ext4_ext_path *path = NULL;
ext4_fsblk_t partial_cluster = 0;
handle_t *handle;
int i, err;
int i = 0, err;

ext_debug("truncate since %u to %u\n", start, end);

Expand Down Expand Up @@ -2605,8 +2605,12 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
}
depth = ext_depth(inode);
ex = path[depth].p_ext;
if (!ex)
if (!ex) {
ext4_ext_drop_refs(path);
kfree(path);
path = NULL;
goto cont;
}

ee_block = le32_to_cpu(ex->ee_block);

Expand Down Expand Up @@ -2636,8 +2640,6 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
if (err < 0)
goto out;
}
ext4_ext_drop_refs(path);
kfree(path);
}
cont:

Expand All @@ -2646,19 +2648,27 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
* after i_size and walking into the tree depth-wise.
*/
depth = ext_depth(inode);
path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_NOFS);
if (path == NULL) {
ext4_journal_stop(handle);
return -ENOMEM;
}
path[0].p_depth = depth;
path[0].p_hdr = ext_inode_hdr(inode);
if (path) {
int k = i = depth;
while (--k > 0)
path[k].p_block =
le16_to_cpu(path[k].p_hdr->eh_entries)+1;
} else {
path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1),
GFP_NOFS);
if (path == NULL) {
ext4_journal_stop(handle);
return -ENOMEM;
}
path[0].p_depth = depth;
path[0].p_hdr = ext_inode_hdr(inode);

if (ext4_ext_check(inode, path[0].p_hdr, depth)) {
err = -EIO;
goto out;
if (ext4_ext_check(inode, path[0].p_hdr, depth)) {
err = -EIO;
goto out;
}
}
i = err = 0;
err = 0;

while (i >= 0 && err == 0) {
if (i == depth) {
Expand Down Expand Up @@ -2772,8 +2782,10 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
out:
ext4_ext_drop_refs(path);
kfree(path);
if (err == -EAGAIN)
if (err == -EAGAIN) {
path = NULL;
goto again;
}
ext4_journal_stop(handle);

return err;
Expand Down

0 comments on commit b8ac1b9

Please sign in to comment.