aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2015-08-24 05:39:42 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2015-08-24 12:39:56 -0400
commitb01548919c33767bc457390fa3c41aedc273bfff (patch)
tree69f966bc6a63078e1f54da898e8bac9a9783b701
parent4ec17d688d74b6b7cb10043c57ff4818cde2b0ca (diff)
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: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/f2fs.h2
-rw-r--r--fs/f2fs/file.c26
2 files changed, 18 insertions, 10 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index ece5e704dfd0..806439f1c886 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1595,7 +1595,7 @@ static inline bool f2fs_may_extent_tree(struct inode *inode)
1595int f2fs_sync_file(struct file *, loff_t, loff_t, int); 1595int f2fs_sync_file(struct file *, loff_t, loff_t, int);
1596void truncate_data_blocks(struct dnode_of_data *); 1596void truncate_data_blocks(struct dnode_of_data *);
1597int truncate_blocks(struct inode *, u64, bool); 1597int truncate_blocks(struct inode *, u64, bool);
1598void f2fs_truncate(struct inode *, bool); 1598int f2fs_truncate(struct inode *, bool);
1599int f2fs_getattr(struct vfsmount *, struct dentry *, struct kstat *); 1599int f2fs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
1600int f2fs_setattr(struct dentry *, struct iattr *); 1600int f2fs_setattr(struct dentry *, struct iattr *);
1601int truncate_hole(struct inode *, pgoff_t, pgoff_t); 1601int truncate_hole(struct inode *, pgoff_t, pgoff_t);
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 7faafb5043e0..86a5c76eb106 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -579,24 +579,30 @@ out:
579 return err; 579 return err;
580} 580}
581 581
582void f2fs_truncate(struct inode *inode, bool lock) 582int f2fs_truncate(struct inode *inode, bool lock)
583{ 583{
584 int err;
585
584 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || 586 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
585 S_ISLNK(inode->i_mode))) 587 S_ISLNK(inode->i_mode)))
586 return; 588 return 0;
587 589
588 trace_f2fs_truncate(inode); 590 trace_f2fs_truncate(inode);
589 591
590 /* we should check inline_data size */ 592 /* we should check inline_data size */
591 if (f2fs_has_inline_data(inode) && !f2fs_may_inline_data(inode)) { 593 if (f2fs_has_inline_data(inode) && !f2fs_may_inline_data(inode)) {
592 if (f2fs_convert_inline_inode(inode)) 594 err = f2fs_convert_inline_inode(inode);
593 return; 595 if (err)
596 return err;
594 } 597 }
595 598
596 if (!truncate_blocks(inode, i_size_read(inode), lock)) { 599 err = truncate_blocks(inode, i_size_read(inode), lock);
597 inode->i_mtime = inode->i_ctime = CURRENT_TIME; 600 if (err)
598 mark_inode_dirty(inode); 601 return err;
599 } 602
603 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
604 mark_inode_dirty(inode);
605 return 0;
600} 606}
601 607
602int f2fs_getattr(struct vfsmount *mnt, 608int f2fs_getattr(struct vfsmount *mnt,
@@ -656,7 +662,9 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
656 662
657 if (attr->ia_size <= i_size_read(inode)) { 663 if (attr->ia_size <= i_size_read(inode)) {
658 truncate_setsize(inode, attr->ia_size); 664 truncate_setsize(inode, attr->ia_size);
659 f2fs_truncate(inode, true); 665 err = f2fs_truncate(inode, true);
666 if (err)
667 return err;
660 f2fs_balance_fs(F2FS_I_SB(inode)); 668 f2fs_balance_fs(F2FS_I_SB(inode));
661 } else { 669 } else {
662 /* 670 /*