All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: <linux-f2fs-devel@lists.sourceforge.net>,
	<linux-kernel@vger.kernel.org>, <chao@kernel.org>
Subject: Re: [PATCH] f2fs: fix to cover allocate_segment() with lock
Date: Tue, 20 Apr 2021 09:52:47 +0800	[thread overview]
Message-ID: <03dc1c69-9215-1b5f-b1cc-c38454f3b90a@huawei.com> (raw)
In-Reply-To: <YH22a55sexxwmGCe@google.com>

On 2021/4/20 0:57, Jaegeuk Kim wrote:
> On 04/14, Chao Yu wrote:
>> As we did for other cases, in fix_curseg_write_pointer(), let's
>> change as below:
>> - use callback function s_ops->allocate_segment() instead of
>> raw function allocate_segment_by_default();
>> - cover allocate_segment() with curseg_lock and sentry_lock.
>>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>>   fs/f2fs/segment.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>> index b2ee6b7791b0..daf9531ec58f 100644
>> --- a/fs/f2fs/segment.c
>> +++ b/fs/f2fs/segment.c
>> @@ -4848,7 +4848,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
>>   
>>   	f2fs_notice(sbi, "Assign new section to curseg[%d]: "
>>   		    "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff);
>> -	allocate_segment_by_default(sbi, type, true);
>> +
>> +	down_read(&SM_I(sbi)->curseg_lock);
>> +	down_write(&SIT_I(sbi)->sentry_lock);
>> +	SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
>> +	up_write(&SIT_I(sbi)->sentry_lock);
>> +	up_read(&SM_I(sbi)->curseg_lock);
> 
> Seems f2fs_allocate_new_section()?

f2fs_allocate_new_section() will allocate new section only when current
section has been initialized and has valid block/ckpt_block.

It looks fix_curseg_write_pointer() wants to force migrating current segment
to new section whenever write pointer and curseg->next_blkoff is inconsistent.

So how about adding a parameter to force f2fs_allocate_new_section() to
allocate new section?

Thanks,

> 
>>   
>>   	/* check consistency of the zone curseg pointed to */
>>   	if (check_zone_write_pointer(sbi, zbd, &zone))
>> -- 
>> 2.29.2
> .
> 

WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu <yuchao0@huawei.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: fix to cover allocate_segment() with lock
Date: Tue, 20 Apr 2021 09:52:47 +0800	[thread overview]
Message-ID: <03dc1c69-9215-1b5f-b1cc-c38454f3b90a@huawei.com> (raw)
In-Reply-To: <YH22a55sexxwmGCe@google.com>

On 2021/4/20 0:57, Jaegeuk Kim wrote:
> On 04/14, Chao Yu wrote:
>> As we did for other cases, in fix_curseg_write_pointer(), let's
>> change as below:
>> - use callback function s_ops->allocate_segment() instead of
>> raw function allocate_segment_by_default();
>> - cover allocate_segment() with curseg_lock and sentry_lock.
>>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>>   fs/f2fs/segment.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>> index b2ee6b7791b0..daf9531ec58f 100644
>> --- a/fs/f2fs/segment.c
>> +++ b/fs/f2fs/segment.c
>> @@ -4848,7 +4848,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
>>   
>>   	f2fs_notice(sbi, "Assign new section to curseg[%d]: "
>>   		    "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff);
>> -	allocate_segment_by_default(sbi, type, true);
>> +
>> +	down_read(&SM_I(sbi)->curseg_lock);
>> +	down_write(&SIT_I(sbi)->sentry_lock);
>> +	SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
>> +	up_write(&SIT_I(sbi)->sentry_lock);
>> +	up_read(&SM_I(sbi)->curseg_lock);
> 
> Seems f2fs_allocate_new_section()?

f2fs_allocate_new_section() will allocate new section only when current
section has been initialized and has valid block/ckpt_block.

It looks fix_curseg_write_pointer() wants to force migrating current segment
to new section whenever write pointer and curseg->next_blkoff is inconsistent.

So how about adding a parameter to force f2fs_allocate_new_section() to
allocate new section?

Thanks,

> 
>>   
>>   	/* check consistency of the zone curseg pointed to */
>>   	if (check_zone_write_pointer(sbi, zbd, &zone))
>> -- 
>> 2.29.2
> .
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2021-04-20  1:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-14  1:21 [PATCH] f2fs: fix to cover allocate_segment() with lock Chao Yu
2021-04-14  1:21 ` [f2fs-dev] " Chao Yu
2021-04-19 16:57 ` Jaegeuk Kim
2021-04-19 16:57   ` [f2fs-dev] " Jaegeuk Kim
2021-04-20  1:52   ` Chao Yu [this message]
2021-04-20  1:52     ` Chao Yu
2021-04-20 18:26     ` Jaegeuk Kim
2021-04-20 18:26       ` [f2fs-dev] " Jaegeuk Kim

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=03dc1c69-9215-1b5f-b1cc-c38454f3b90a@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 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.