* [PATCH v2] f2fs: do not trim preallocated blocks when truncating after i_size
@ 2015-06-09 2:27 Chao Yu
2015-06-12 0:30 ` [f2fs-dev] " Chao Yu
0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2015-06-09 2:27 UTC (permalink / raw)
To: Jaegeuk Kim, Changman Lee; +Cc: linux-f2fs-devel, linux-kernel
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 <chao2.yu@samsung.com>
---
v2:
* adjust code style pointed out by Jaegeuk Kim.
fs/f2fs/file.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 4d42d66..ec47c4a 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -651,16 +651,15 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
f2fs_get_encryption_info(inode))
return -EACCES;
- if (attr->ia_size != i_size_read(inode)) {
- truncate_setsize(inode, attr->ia_size);
+ truncate_setsize(inode, attr->ia_size);
+
+ /*
+ * do not trim all preallocated blocks after i_size if target
+ * size is larger than i_size.
+ */
+ if (attr->ia_size <= i_size_read(inode)) {
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.
- */
- f2fs_truncate(inode);
}
}
--
2.4.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [f2fs-dev] [PATCH v2] f2fs: do not trim preallocated blocks when truncating after i_size
2015-06-09 2:27 [PATCH v2] f2fs: do not trim preallocated blocks when truncating after i_size Chao Yu
@ 2015-06-12 0:30 ` Chao Yu
2015-06-12 1:30 ` [f2fs-dev] " Jaegeuk Kim
0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2015-06-12 0:30 UTC (permalink / raw)
To: 'Jaegeuk Kim', 'Changman Lee'
Cc: linux-kernel, linux-f2fs-devel
Hi Jaegeuk,
> -----Original Message-----
> From: Chao Yu [mailto:chao2.yu@samsung.com]
> Sent: Tuesday, June 09, 2015 10:28 AM
> To: Jaegeuk Kim; Changman Lee
> Cc: linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net
> Subject: [f2fs-dev] [PATCH v2] f2fs: do not trim preallocated blocks when truncating after i_size
>
> 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 <chao2.yu@samsung.com>
> ---
> v2:
> * adjust code style pointed out by Jaegeuk Kim.
>
> fs/f2fs/file.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 4d42d66..ec47c4a 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -651,16 +651,15 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
> f2fs_get_encryption_info(inode))
> return -EACCES;
>
> - if (attr->ia_size != i_size_read(inode)) {
> - truncate_setsize(inode, attr->ia_size);
> + truncate_setsize(inode, attr->ia_size);
> +
> + /*
> + * do not trim all preallocated blocks after i_size if target
> + * size is larger than i_size.
> + */
> + if (attr->ia_size <= i_size_read(inode)) {
It's wrong implementation here, because we have set i_size in inode with
attr->ia_size, so that we will always go into this "truncate smaller size"
branch.
Please ignore this patch, sorry for my mistake.
Jaegeuk, I'd like to use v1 patch, how do you think?
Thanks,
> 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.
> - */
> - f2fs_truncate(inode);
> }
> }
>
> --
> 2.4.2
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] f2fs: do not trim preallocated blocks when truncating after i_size
2015-06-12 0:30 ` [f2fs-dev] " Chao Yu
@ 2015-06-12 1:30 ` Jaegeuk Kim
0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2015-06-12 1:30 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel
On Fri, Jun 12, 2015 at 08:30:09AM +0800, Chao Yu wrote:
> Hi Jaegeuk,
>
> > -----Original Message-----
> > From: Chao Yu [mailto:chao2.yu@samsung.com]
> > Sent: Tuesday, June 09, 2015 10:28 AM
> > To: Jaegeuk Kim; Changman Lee
> > Cc: linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net
> > Subject: [f2fs-dev] [PATCH v2] f2fs: do not trim preallocated blocks when truncating after i_size
> >
> > 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 <chao2.yu@samsung.com>
> > ---
> > v2:
> > * adjust code style pointed out by Jaegeuk Kim.
> >
> > fs/f2fs/file.c | 15 +++++++--------
> > 1 file changed, 7 insertions(+), 8 deletions(-)
> >
> > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> > index 4d42d66..ec47c4a 100644
> > --- a/fs/f2fs/file.c
> > +++ b/fs/f2fs/file.c
> > @@ -651,16 +651,15 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
> > f2fs_get_encryption_info(inode))
> > return -EACCES;
> >
> > - if (attr->ia_size != i_size_read(inode)) {
> > - truncate_setsize(inode, attr->ia_size);
> > + truncate_setsize(inode, attr->ia_size);
> > +
> > + /*
> > + * do not trim all preallocated blocks after i_size if target
> > + * size is larger than i_size.
> > + */
> > + if (attr->ia_size <= i_size_read(inode)) {
>
> It's wrong implementation here, because we have set i_size in inode with
> attr->ia_size, so that we will always go into this "truncate smaller size"
> branch.
>
> Please ignore this patch, sorry for my mistake.
>
> Jaegeuk, I'd like to use v1 patch, how do you think?
Oh, I see.
I'll merge v1.
Thank you for pointing out this.
>
> Thanks,
>
> > 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.
> > - */
> > - f2fs_truncate(inode);
> > }
> > }
> >
> > --
> > 2.4.2
> >
> >
> >
> > ------------------------------------------------------------------------------
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: do not trim preallocated blocks when truncating after i_size
@ 2015-06-12 1:30 ` Jaegeuk Kim
0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2015-06-12 1:30 UTC (permalink / raw)
To: Chao Yu; +Cc: 'Changman Lee', linux-kernel, linux-f2fs-devel
On Fri, Jun 12, 2015 at 08:30:09AM +0800, Chao Yu wrote:
> Hi Jaegeuk,
>
> > -----Original Message-----
> > From: Chao Yu [mailto:chao2.yu@samsung.com]
> > Sent: Tuesday, June 09, 2015 10:28 AM
> > To: Jaegeuk Kim; Changman Lee
> > Cc: linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net
> > Subject: [f2fs-dev] [PATCH v2] f2fs: do not trim preallocated blocks when truncating after i_size
> >
> > 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 <chao2.yu@samsung.com>
> > ---
> > v2:
> > * adjust code style pointed out by Jaegeuk Kim.
> >
> > fs/f2fs/file.c | 15 +++++++--------
> > 1 file changed, 7 insertions(+), 8 deletions(-)
> >
> > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> > index 4d42d66..ec47c4a 100644
> > --- a/fs/f2fs/file.c
> > +++ b/fs/f2fs/file.c
> > @@ -651,16 +651,15 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
> > f2fs_get_encryption_info(inode))
> > return -EACCES;
> >
> > - if (attr->ia_size != i_size_read(inode)) {
> > - truncate_setsize(inode, attr->ia_size);
> > + truncate_setsize(inode, attr->ia_size);
> > +
> > + /*
> > + * do not trim all preallocated blocks after i_size if target
> > + * size is larger than i_size.
> > + */
> > + if (attr->ia_size <= i_size_read(inode)) {
>
> It's wrong implementation here, because we have set i_size in inode with
> attr->ia_size, so that we will always go into this "truncate smaller size"
> branch.
>
> Please ignore this patch, sorry for my mistake.
>
> Jaegeuk, I'd like to use v1 patch, how do you think?
Oh, I see.
I'll merge v1.
Thank you for pointing out this.
>
> Thanks,
>
> > 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.
> > - */
> > - f2fs_truncate(inode);
> > }
> > }
> >
> > --
> > 2.4.2
> >
> >
> >
> > ------------------------------------------------------------------------------
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-06-12 1:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-09 2:27 [PATCH v2] f2fs: do not trim preallocated blocks when truncating after i_size Chao Yu
2015-06-12 0:30 ` [f2fs-dev] " Chao Yu
2015-06-12 1:30 ` Jaegeuk Kim
2015-06-12 1:30 ` [f2fs-dev] " Jaegeuk Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.