linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org>
Cc: <linux-f2fs-devel@lists.sourceforge.net>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] f2fs: fix to align to section for fallocate() on pinned file
Date: Wed, 24 Mar 2021 09:23:29 +0800	[thread overview]
Message-ID: <d08a10bb-d6ac-1dde-7e61-836030c96f34@huawei.com> (raw)
In-Reply-To: <YFo0Tz1zl4tw7lUP@google.com>

On 2021/3/24 2:32, Jaegeuk Kim wrote:
> On 03/23, Chao Yu wrote:
>> On 2021/3/5 17:56, Chao Yu wrote:
>>> Now, fallocate() on a pinned file only allocates blocks which aligns
>>> to segment rather than section, so GC may try to migrate pinned file's
>>> block, and after several times of failure, pinned file's block could
>>> be migrated to other place, however user won't be aware of such
>>> condition, and then old obsolete block address may be readed/written
>>> incorrectly.
>>>
>>> To avoid such condition, let's try to allocate pinned file's blocks
>>> with section alignment.
>>>
>>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>>
>> Jaegeuk,
>>
>> Could you please check and apply below diff into original patch?
>>
>> ---
>>   fs/f2fs/file.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index 236f3f69681a..24fa68fdcaa0 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -1648,13 +1648,13 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
>>   		return 0;
>>
>>   	if (f2fs_is_pinned_file(inode)) {
>> -		block_t len = (map.m_len >> sbi->log_blocks_per_seg) <<
>> -					sbi->log_blocks_per_seg;
>> +		block_t sec_blks = BLKS_PER_SEC(sbi);
>> +		block_t len = rounddown(map.m_len, sec_blks);
> 
> len is declared above, so let me rephrase this as well.

Oh, right.

> 
>>
>> -		if (map.m_len % sbi->blocks_per_seg)
>> -			len += sbi->blocks_per_seg;
>> +		if (map.m_len % sec_blks)
>> +			len += sec_blks;
> 
> is this roundup()?

More clean.

> 
> Could you check this?
> https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev&id=e1175f02291141bbd924fc578299305fcde35855

Looks good to me. :)

Thanks,

> 
>>
>> -		map.m_len = sbi->blocks_per_seg;
>> +		map.m_len = sec_blks;
>>   next_alloc:
>>   		if (has_not_enough_free_secs(sbi, 0,
>>   			GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))) {
>> -- 
>> 2.22.1
>>
> .
> 

      reply	other threads:[~2021-03-24  1:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05  9:56 [PATCH] f2fs: fix to align to section for fallocate() on pinned file Chao Yu
2021-03-23 13:56 ` Chao Yu
2021-03-23 18:32   ` Jaegeuk Kim
2021-03-24  1:23     ` Chao Yu [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=d08a10bb-d6ac-1dde-7e61-836030c96f34@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).