提交 b0154891 编写于 作者: C Chao Yu 提交者: Jaegeuk Kim

f2fs: handle f2fs_truncate error correctly

This patch fixes to return error number of f2fs_truncate, so that we
can handle the error correctly in callers.
Signed-off-by: NChao Yu <chao2.yu@samsung.com>
Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
上级 4ec17d68
......@@ -1595,7 +1595,7 @@ static inline bool f2fs_may_extent_tree(struct inode *inode)
int f2fs_sync_file(struct file *, loff_t, loff_t, int);
void truncate_data_blocks(struct dnode_of_data *);
int truncate_blocks(struct inode *, u64, bool);
void f2fs_truncate(struct inode *, bool);
int f2fs_truncate(struct inode *, bool);
int f2fs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
int f2fs_setattr(struct dentry *, struct iattr *);
int truncate_hole(struct inode *, pgoff_t, pgoff_t);
......
......@@ -579,24 +579,30 @@ int truncate_blocks(struct inode *inode, u64 from, bool lock)
return err;
}
void f2fs_truncate(struct inode *inode, bool lock)
int f2fs_truncate(struct inode *inode, bool lock)
{
int err;
if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
S_ISLNK(inode->i_mode)))
return;
return 0;
trace_f2fs_truncate(inode);
/* we should check inline_data size */
if (f2fs_has_inline_data(inode) && !f2fs_may_inline_data(inode)) {
if (f2fs_convert_inline_inode(inode))
return;
err = f2fs_convert_inline_inode(inode);
if (err)
return err;
}
if (!truncate_blocks(inode, i_size_read(inode), lock)) {
inode->i_mtime = inode->i_ctime = CURRENT_TIME;
mark_inode_dirty(inode);
}
err = truncate_blocks(inode, i_size_read(inode), lock);
if (err)
return err;
inode->i_mtime = inode->i_ctime = CURRENT_TIME;
mark_inode_dirty(inode);
return 0;
}
int f2fs_getattr(struct vfsmount *mnt,
......@@ -656,7 +662,9 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
if (attr->ia_size <= i_size_read(inode)) {
truncate_setsize(inode, attr->ia_size);
f2fs_truncate(inode, true);
err = f2fs_truncate(inode, true);
if (err)
return err;
f2fs_balance_fs(F2FS_I_SB(inode));
} else {
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册