Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752984AbbFICX4 (ORCPT ); Mon, 8 Jun 2015 22:23:56 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:34630 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751335AbbFICXr (ORCPT ); Mon, 8 Jun 2015 22:23:47 -0400 X-AuditID: cbfee61b-f79416d0000014c0-22-55764e30533f From: Chao Yu To: "'Jaegeuk Kim'" Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <000101d09f7b$4a2559e0$de700da0$@samsung.com> <20150608180643.GA59258@jaegeuk-mac02.mot.com> In-reply-to: <20150608180643.GA59258@jaegeuk-mac02.mot.com> Subject: RE: [PATCH] f2fs: do not trim preallocated blocks when truncating after i_size Date: Tue, 09 Jun 2015 10:22:49 +0800 Message-id: <007a01d0a25b$4dbb2b60$e9318220$@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: AQJz4TkzjoNSNmjH80HtxnAuSberwwGWIDInnFArRlA= Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRmVeSWpSXmKPExsVy+t9jQV0Dv7JQgwW/9SyerJ/FbHFpkbvF 5V1z2ByYPTat6mTz2L3gM5PH501yAcxRXDYpqTmZZalF+nYJXBmrdgoUvBauaJ32g6WBsY+/ i5GTQ0LAROLVtB1sELaYxIV764FsLg4hgemMEkcWX2OCcF4xShzrXMkKUsUmoCKxvOM/E4gt IqAm0btvCpjNLOAh0djxHaxGSCBLYn/LDDCbU8Ba4uqZvSwgtrBApMSS6xPZQWwWAVWJnp/H wWp4BSwl1lzqZ4GwBSV+TL7HAjFTS2L9zuNQ8+UlNq95ywxxqYLEjrOvGbsYOYBusJK4Mb0K okRcYuORWywTGIVmIZk0C8mkWUgmzULSsoCRZRWjaGpBckFxUnqukV5xYm5xaV66XnJ+7iZG cLA/k97BuKrB4hCjAAejEg/vCYWyUCHWxLLiytxDjBIczEoivIWsQCHelMTKqtSi/Pii0pzU 4kOM0hwsSuK8J/N9QoUE0hNLUrNTUwtSi2CyTBycUg2Met6h5ceOG4X94th3l8Eoar1+Vmz2 V+ELXsz3LTtmmGzn4Zm4TGOh5pr6lT85vH7V/+pKjy0VWjP5q4DE55lTz8j/bw0MYhGqDfm5 vZxNUFJp1SpNkdQHmjFaEr7yPySD1gS8Z5nW8P6GhbIur8CdU17znVSlmsTWMrt/Zp+z9meO 0hPnihAlluKMREMt5qLiRAAT4sJbcgIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2705 Lines: 84 > -----Original Message----- > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org] > Sent: Tuesday, June 09, 2015 2:07 AM > To: Chao Yu > Cc: linux-f2fs-devel@lists.sourceforge.net; linux-kernel@vger.kernel.org > Subject: Re: [PATCH] f2fs: do not trim preallocated blocks when truncating after i_size > > On Fri, Jun 05, 2015 at 06:34:02PM +0800, Chao Yu wrote: > > When we perform generic/092 in xfstests, output is like below: > > > > XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > > 0: [0..10239]: data > > 0: [0..10239]: data > > -1: [10240..20479]: unwritten > > +1: [10240..14335]: unwritten > > > > This is because with this testcase, we redefine the regulation for > > truncate in perallocated space past i_size as below: > > > > "There was some confused about what the fs was supposed to do when you > > truncate at i_size with preallocated space past i_size. We decided on the > > following things. > > > > 1) truncate(i_size) will trim all blocks past i_size. > > 2) truncate(x) where x > i_size will not trim all blocks past i_size. > > " > > > > This method is used in xfs, and then ext4/btrfs will follow the rule. > > > > This patch fixes to follow the new rule for f2fs. > > > > Signed-off-by: Chao Yu > > --- > > fs/f2fs/file.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > > index 4d42d66..85f97af 100644 > > --- a/fs/f2fs/file.c > > +++ b/fs/f2fs/file.c > > @@ -651,16 +651,16 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) > > f2fs_get_encryption_info(inode)) > > return -EACCES; > > > > - if (attr->ia_size != i_size_read(inode)) { > > + if (attr->ia_size <= i_size_read(inode)) { > > truncate_setsize(inode, attr->ia_size); > > f2fs_truncate(inode); > > f2fs_balance_fs(F2FS_I_SB(inode)); > > } else { > > /* > > - * giving a chance to truncate blocks past EOF which > > - * are fallocated with FALLOC_FL_KEEP_SIZE. > > + * do not trim all blocks after i_size if target size is > > + * larger than i_size. > > */ > > - f2fs_truncate(inode); > > + truncate_setsize(inode, attr->ia_size); > > So, we can do: > truncate_setsize(); > > if (attr->ia_size <= i_size_read(inode)) { > f2fs_truncate(inode); > f2fs_balance_fs(); > } > > Right? Yes, let me fix and resend the patch. Thanks, > > > } > > } > > > > -- > > 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/