Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754220AbbHXJk2 (ORCPT ); Mon, 24 Aug 2015 05:40:28 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:45086 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754091AbbHXJkZ (ORCPT ); Mon, 24 Aug 2015 05:40:25 -0400 X-AuditID: cbfee61b-f79706d000001b96-4e-55dae6889f9b From: Chao Yu To: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] f2fs: handle f2fs_truncate error correctly Date: Mon, 24 Aug 2015 17:39:42 +0800 Message-id: <001a01d0de50$e6830300$b3890900$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdDeUGW4OGlxVZoET2uqQKRmMFXd4g== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsVy+t9jQd2OZ7dCDZa18lk8WT+L2eLSIneL y7vmsDkwe2xa1cnmsXvBZyaPz5vkApijuGxSUnMyy1KL9O0SuDLWHLvEWrBLqGLy21XsDYyt /F2MnBwSAiYSZ6ZsY4awxSQu3FvP1sXIxSEkMItRYu3pt8wQzitGidMbZoJVsQmoSCzv+M8E YosA2YcWXWYHsZkFPCQaO76zgtjCAvYS7yd0g9WwCKhKtGy8CTSVg4NXwFLi2zywEl4BQYkf k++xQLRqSazfeZwJwpaX2LzmLdRBChI7zr5mBGkVEdCTuHVNAKJEXGLjkVssExiBjkSYNAvJ pFlIJs1C0rKAkWUVo0RqQXJBcVJ6rlFearlecWJucWleul5yfu4mRnAIP5PewXh4l/shRgEO RiUeXgbLW6FCrIllxZW5hxglOJiVRHiVXt4MFeJNSaysSi3Kjy8qzUktPsQozcGiJM6rb7Ip VEggPbEkNTs1tSC1CCbLxMEp1cBYtunmnqBNNga3BbsW3pj2x3F9c5H06vNL/E/OvrZZ9iLP fhu7y+d+aDw6ddp4Qri81+59bzyXnTR137fEeqLh0/plh93PnbOff5k1qfPjR/V5q88V8xiI yrKnLTllp3rb/560+eXZJ9zt67Z1XLOdK256jmHPXI99lVe22B76JdBX3HX26yS3IiWW4oxE Qy3mouJEAD3XArxdAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2527 Lines: 85 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 --- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index ece5e70..806439f 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) 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); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 7faafb5..86a5c76 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -579,24 +579,30 @@ out: 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 { /* -- 2.4.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/