* [PATCH] f2fs: skip filesystem level truncate when size isn't changed
@ 2017-02-28 13:34 Kinglong Mee
2017-03-01 2:08 ` Chao Yu
0 siblings, 1 reply; 3+ messages in thread
From: Kinglong Mee @ 2017-02-28 13:34 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-f2fs-devel
When size isn't changed, it's needless to do f2fs level truncate.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
fs/f2fs/file.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index c6ca00c..d144aa3 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -676,6 +676,7 @@ static void __setattr_copy(struct inode *inode, const struct iattr *attr)
int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
+ loff_t old_size = i_size_read(inode);
int err;
bool size_changed = false;
@@ -688,12 +689,13 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
fscrypt_get_encryption_info(inode))
return -EACCES;
- if (attr->ia_size <= i_size_read(inode)) {
+ if (attr->ia_size < old_size) {
truncate_setsize(inode, attr->ia_size);
err = f2fs_truncate(inode);
if (err)
return err;
- } else {
+ size_changed = true;
+ } else if (attr->ia_size > old_size) {
/*
* do not trim all blocks after i_size if target size is
* larger than i_size.
@@ -707,9 +709,8 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
return err;
}
inode->i_mtime = inode->i_ctime = current_time(inode);
+ size_changed = true;
}
-
- size_changed = true;
}
__setattr_copy(inode, attr);
--
2.9.3
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] f2fs: skip filesystem level truncate when size isn't changed
2017-02-28 13:34 [PATCH] f2fs: skip filesystem level truncate when size isn't changed Kinglong Mee
@ 2017-03-01 2:08 ` Chao Yu
2017-03-01 4:18 ` Kinglong Mee
0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2017-03-01 2:08 UTC (permalink / raw)
To: Kinglong Mee, Jaegeuk Kim; +Cc: linux-f2fs-devel
On 2017/2/28 21:34, Kinglong Mee wrote:
> When size isn't changed, it's needless to do f2fs level truncate.
I think it needs to do this.
Please take a look at commit 3c4541452748 ("f2fs: do not trim preallocated
blocks when truncating after i_size") and generic/092 of fstests.
Thanks,
>
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
> fs/f2fs/file.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index c6ca00c..d144aa3 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -676,6 +676,7 @@ static void __setattr_copy(struct inode *inode, const struct iattr *attr)
> int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> + loff_t old_size = i_size_read(inode);
> int err;
> bool size_changed = false;
>
> @@ -688,12 +689,13 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
> fscrypt_get_encryption_info(inode))
> return -EACCES;
>
> - if (attr->ia_size <= i_size_read(inode)) {
> + if (attr->ia_size < old_size) {
> truncate_setsize(inode, attr->ia_size);
> err = f2fs_truncate(inode);
> if (err)
> return err;
> - } else {
> + size_changed = true;
> + } else if (attr->ia_size > old_size) {
> /*
> * do not trim all blocks after i_size if target size is
> * larger than i_size.
> @@ -707,9 +709,8 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
> return err;
> }
> inode->i_mtime = inode->i_ctime = current_time(inode);
> + size_changed = true;
> }
> -
> - size_changed = true;
> }
>
> __setattr_copy(inode, attr);
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] f2fs: skip filesystem level truncate when size isn't changed
2017-03-01 2:08 ` Chao Yu
@ 2017-03-01 4:18 ` Kinglong Mee
0 siblings, 0 replies; 3+ messages in thread
From: Kinglong Mee @ 2017-03-01 4:18 UTC (permalink / raw)
To: Chao Yu; +Cc: Jaegeuk Kim, linux-f2fs-devel
On 3/1/2017 10:08, Chao Yu wrote:
> On 2017/2/28 21:34, Kinglong Mee wrote:
>> When size isn't changed, it's needless to do f2fs level truncate.
>
> I think it needs to do this.
>
> Please take a look at commit 3c4541452748 ("f2fs: do not trim preallocated
> blocks when truncating after i_size") and generic/092 of fstests.
Got it, thanks!
thanks,
Kinglong Mee
> Thanks,
>
>>
>> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
>> ---
>> fs/f2fs/file.c | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index c6ca00c..d144aa3 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -676,6 +676,7 @@ static void __setattr_copy(struct inode *inode, const struct iattr *attr)
>> int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
>> {
>> struct inode *inode = d_inode(dentry);
>> + loff_t old_size = i_size_read(inode);
>> int err;
>> bool size_changed = false;
>>
>> @@ -688,12 +689,13 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
>> fscrypt_get_encryption_info(inode))
>> return -EACCES;
>>
>> - if (attr->ia_size <= i_size_read(inode)) {
>> + if (attr->ia_size < old_size) {
>> truncate_setsize(inode, attr->ia_size);
>> err = f2fs_truncate(inode);
>> if (err)
>> return err;
>> - } else {
>> + size_changed = true;
>> + } else if (attr->ia_size > old_size) {
>> /*
>> * do not trim all blocks after i_size if target size is
>> * larger than i_size.
>> @@ -707,9 +709,8 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
>> return err;
>> }
>> inode->i_mtime = inode->i_ctime = current_time(inode);
>> + size_changed = true;
>> }
>> -
>> - size_changed = true;
>> }
>>
>> __setattr_copy(inode, attr);
>>
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-01 4:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-28 13:34 [PATCH] f2fs: skip filesystem level truncate when size isn't changed Kinglong Mee
2017-03-01 2:08 ` Chao Yu
2017-03-01 4:18 ` Kinglong Mee
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.