Commit 2b42be5e authored by Jan Kara's avatar Jan Kara

udf: Propagate errors from udf_truncate_extents()

Make udf_truncate_extents() properly propagate errors to its callers and
let udf_setsize() handle the error properly as well. This lets userspace
know in case there's some error when truncating blocks.
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent d3ca4651
...@@ -1242,8 +1242,10 @@ int udf_setsize(struct inode *inode, loff_t newsize) ...@@ -1242,8 +1242,10 @@ int udf_setsize(struct inode *inode, loff_t newsize)
truncate_setsize(inode, newsize); truncate_setsize(inode, newsize);
down_write(&iinfo->i_data_sem); down_write(&iinfo->i_data_sem);
udf_clear_extent_cache(inode); udf_clear_extent_cache(inode);
udf_truncate_extents(inode); err = udf_truncate_extents(inode);
up_write(&iinfo->i_data_sem); up_write(&iinfo->i_data_sem);
if (err)
return err;
} }
update_time: update_time:
inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_mtime = inode->i_ctime = current_time(inode);
......
...@@ -199,7 +199,7 @@ static void udf_update_alloc_ext_desc(struct inode *inode, ...@@ -199,7 +199,7 @@ static void udf_update_alloc_ext_desc(struct inode *inode,
* for making file shorter. For making file longer, udf_extend_file() has to * for making file shorter. For making file longer, udf_extend_file() has to
* be used. * be used.
*/ */
void udf_truncate_extents(struct inode *inode) int udf_truncate_extents(struct inode *inode)
{ {
struct extent_position epos; struct extent_position epos;
struct kernel_lb_addr eloc, neloc = {}; struct kernel_lb_addr eloc, neloc = {};
...@@ -224,7 +224,7 @@ void udf_truncate_extents(struct inode *inode) ...@@ -224,7 +224,7 @@ void udf_truncate_extents(struct inode *inode)
if (etype == -1) { if (etype == -1) {
/* We should extend the file? */ /* We should extend the file? */
WARN_ON(byte_offset); WARN_ON(byte_offset);
return; return 0;
} }
epos.offset -= adsize; epos.offset -= adsize;
extent_trunc(inode, &epos, &eloc, etype, elen, byte_offset); extent_trunc(inode, &epos, &eloc, etype, elen, byte_offset);
...@@ -262,7 +262,7 @@ void udf_truncate_extents(struct inode *inode) ...@@ -262,7 +262,7 @@ void udf_truncate_extents(struct inode *inode)
udf_get_lb_pblock(sb, &eloc, 0)); udf_get_lb_pblock(sb, &eloc, 0));
/* Error reading indirect block? */ /* Error reading indirect block? */
if (!epos.bh) if (!epos.bh)
return; return -EIO;
if (elen) if (elen)
indirect_ext_len = indirect_ext_len =
(elen + sb->s_blocksize - 1) >> (elen + sb->s_blocksize - 1) >>
...@@ -286,4 +286,5 @@ void udf_truncate_extents(struct inode *inode) ...@@ -286,4 +286,5 @@ void udf_truncate_extents(struct inode *inode)
iinfo->i_lenExtents = inode->i_size; iinfo->i_lenExtents = inode->i_size;
brelse(epos.bh); brelse(epos.bh);
return 0;
} }
...@@ -235,7 +235,7 @@ extern struct inode *udf_new_inode(struct inode *, umode_t); ...@@ -235,7 +235,7 @@ extern struct inode *udf_new_inode(struct inode *, umode_t);
/* truncate.c */ /* truncate.c */
extern void udf_truncate_tail_extent(struct inode *); extern void udf_truncate_tail_extent(struct inode *);
extern void udf_discard_prealloc(struct inode *); extern void udf_discard_prealloc(struct inode *);
extern void udf_truncate_extents(struct inode *); extern int udf_truncate_extents(struct inode *);
/* balloc.c */ /* balloc.c */
extern void udf_free_blocks(struct super_block *, struct inode *, extern void udf_free_blocks(struct super_block *, struct inode *,
......
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