Commit 70bfb3a8 authored by Jan Kara's avatar Jan Kara

udf: Truncate added extents on failed expansion

When a file expansion failed because we didn't have enough space for
indirect extents make sure we truncate extents created so far so that we
don't leave extents beyond EOF.

CC: stable@vger.kernel.org
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 1e0290d6
...@@ -431,8 +431,10 @@ static int udf_do_extend_file(struct inode *inode, ...@@ -431,8 +431,10 @@ static int udf_do_extend_file(struct inode *inode,
} }
if (fake) { if (fake) {
udf_add_aext(inode, last_pos, &last_ext->extLocation, err = udf_add_aext(inode, last_pos, &last_ext->extLocation,
last_ext->extLength, 1); last_ext->extLength, 1);
if (err < 0)
goto out_err;
count++; count++;
} else { } else {
struct kernel_lb_addr tmploc; struct kernel_lb_addr tmploc;
...@@ -466,7 +468,7 @@ static int udf_do_extend_file(struct inode *inode, ...@@ -466,7 +468,7 @@ static int udf_do_extend_file(struct inode *inode,
err = udf_add_aext(inode, last_pos, &last_ext->extLocation, err = udf_add_aext(inode, last_pos, &last_ext->extLocation,
last_ext->extLength, 1); last_ext->extLength, 1);
if (err) if (err)
return err; goto out_err;
count++; count++;
} }
if (new_block_bytes) { if (new_block_bytes) {
...@@ -475,7 +477,7 @@ static int udf_do_extend_file(struct inode *inode, ...@@ -475,7 +477,7 @@ static int udf_do_extend_file(struct inode *inode,
err = udf_add_aext(inode, last_pos, &last_ext->extLocation, err = udf_add_aext(inode, last_pos, &last_ext->extLocation,
last_ext->extLength, 1); last_ext->extLength, 1);
if (err) if (err)
return err; goto out_err;
count++; count++;
} }
...@@ -489,6 +491,11 @@ static int udf_do_extend_file(struct inode *inode, ...@@ -489,6 +491,11 @@ static int udf_do_extend_file(struct inode *inode,
return -EIO; return -EIO;
return count; return count;
out_err:
/* Remove extents we've created so far */
udf_clear_extent_cache(inode);
udf_truncate_extents(inode);
return err;
} }
/* Extend the final block of the file to final_block_len bytes */ /* Extend the final block of the file to final_block_len bytes */
......
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