All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kinglong Mee <kinglongmee@gmail.com>
To: Chao Yu <yuchao0@huawei.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [PATCH] f2fs: skip filesystem level truncate when size isn't changed
Date: Wed, 1 Mar 2017 12:18:43 +0800	[thread overview]
Message-ID: <854d7650-b64b-2621-cff6-ca5ba93efa36@gmail.com> (raw)
In-Reply-To: <c0e5299b-b115-19b7-9b24-5306976eceb1@huawei.com>

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

      reply	other threads:[~2017-03-01  4:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=854d7650-b64b-2621-cff6-ca5ba93efa36@gmail.com \
    --to=kinglongmee@gmail.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.