mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-08 23:04:35 +08:00
udf: Truncate added extents on failed expansion
commit 70bfb3a8d6
upstream.
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: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
aa502e760c
commit
e43adce883
@ -525,8 +525,10 @@ static int udf_do_extend_file(struct inode *inode,
|
||||
}
|
||||
|
||||
if (fake) {
|
||||
udf_add_aext(inode, last_pos, &last_ext->extLocation,
|
||||
last_ext->extLength, 1);
|
||||
err = udf_add_aext(inode, last_pos, &last_ext->extLocation,
|
||||
last_ext->extLength, 1);
|
||||
if (err < 0)
|
||||
goto out_err;
|
||||
count++;
|
||||
} else {
|
||||
struct kernel_lb_addr tmploc;
|
||||
@ -560,7 +562,7 @@ static int udf_do_extend_file(struct inode *inode,
|
||||
err = udf_add_aext(inode, last_pos, &last_ext->extLocation,
|
||||
last_ext->extLength, 1);
|
||||
if (err)
|
||||
return err;
|
||||
goto out_err;
|
||||
count++;
|
||||
}
|
||||
if (new_block_bytes) {
|
||||
@ -569,7 +571,7 @@ static int udf_do_extend_file(struct inode *inode,
|
||||
err = udf_add_aext(inode, last_pos, &last_ext->extLocation,
|
||||
last_ext->extLength, 1);
|
||||
if (err)
|
||||
return err;
|
||||
goto out_err;
|
||||
count++;
|
||||
}
|
||||
|
||||
@ -583,6 +585,11 @@ out:
|
||||
return -EIO;
|
||||
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user