linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
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 v2] f2fs: allocate memory in batch in build_sit_info()
Date: Fri, 23 Aug 2019 09:10:22 +0800	[thread overview]
Message-ID: <4ce7de89-fafb-3796-ae90-8132d2c819cf@huawei.com> (raw)
In-Reply-To: <20190822174736.GA88722@jaegeuk-macbookpro.roam.corp.google.com>

On 2019/8/23 1:47, Jaegeuk Kim wrote:
> On 08/20, Jaegeuk Kim wrote:
>> On 08/20, Chao Yu wrote:
>>> On 2019/8/20 4:20, Jaegeuk Kim wrote:
>>>> On 07/26, Chao Yu wrote:
>>>>> build_sit_info() allocate all bitmaps for each segment one by one,
>>>>> it's quite low efficiency, this pach changes to allocate large
>>>>> continuous memory at a time, and divide it and assign for each bitmaps
>>>>> of segment. For large size image, it can expect improving its mount
>>>>> speed.
>>>>
>>>> Hmm, I hit a kernel panic when mounting a partition during fault injection test:
>>>>
>>>> 726 #ifdef CONFIG_F2FS_CHECK_FS
>>>> 727         if (f2fs_test_bit(offset, sit_i->sit_bitmap) !=
>>>> 728                         f2fs_test_bit(offset, sit_i->sit_bitmap_mir))
>>>> 729                 f2fs_bug_on(sbi, 1);
>>>> 730 #endif
>>>
>>> We didn't change anything about sit_i->sit_bitmap{_mir,}, it's so wired we panic
>>> here... :(
>>>
>>> I double check the change, but find nothing suspicious, btw, my fault injection
>>> testcase shows normal.
>>>
>>> Jaegeuk, do you have any idea about this issue?
>>
>> I'm bisecting. :P
> 
> It was caused by wrong bitmap size in "f2fs: Fix indefinite loop in f2fs_gc()".
> Fixed by:

Good catch! This alternative one looks good to me.

Thanks,

> ---
>  fs/f2fs/segment.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 9b20ce3b87cc..cc230fc829e1 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -3950,7 +3950,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
>  	struct sit_info *sit_i;
>  	unsigned int sit_segs, start;
>  	char *src_bitmap, *bitmap;
> -	unsigned int bitmap_size;
> +	unsigned int bitmap_size, main_bitmap_size, sit_bitmap_size;
>  
>  	/* allocate memory for SIT information */
>  	sit_i = f2fs_kzalloc(sbi, sizeof(struct sit_info), GFP_KERNEL);
> @@ -3966,8 +3966,8 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
>  	if (!sit_i->sentries)
>  		return -ENOMEM;
>  
> -	bitmap_size = f2fs_bitmap_size(MAIN_SEGS(sbi));
> -	sit_i->dirty_sentries_bitmap = f2fs_kvzalloc(sbi, bitmap_size,
> +	main_bitmap_size = f2fs_bitmap_size(MAIN_SEGS(sbi));
> +	sit_i->dirty_sentries_bitmap = f2fs_kvzalloc(sbi, main_bitmap_size,
>  								GFP_KERNEL);
>  	if (!sit_i->dirty_sentries_bitmap)
>  		return -ENOMEM;
> @@ -4016,19 +4016,21 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
>  	sit_segs = le32_to_cpu(raw_super->segment_count_sit) >> 1;
>  
>  	/* setup SIT bitmap from ckeckpoint pack */
> -	bitmap_size = __bitmap_size(sbi, SIT_BITMAP);
> +	sit_bitmap_size = __bitmap_size(sbi, SIT_BITMAP);
>  	src_bitmap = __bitmap_ptr(sbi, SIT_BITMAP);
>  
> -	sit_i->sit_bitmap = kmemdup(src_bitmap, bitmap_size, GFP_KERNEL);
> +	sit_i->sit_bitmap = kmemdup(src_bitmap, sit_bitmap_size, GFP_KERNEL);
>  	if (!sit_i->sit_bitmap)
>  		return -ENOMEM;
>  
>  #ifdef CONFIG_F2FS_CHECK_FS
> -	sit_i->sit_bitmap_mir = kmemdup(src_bitmap, bitmap_size, GFP_KERNEL);
> +	sit_i->sit_bitmap_mir = kmemdup(src_bitmap,
> +					sit_bitmap_size, GFP_KERNEL);
>  	if (!sit_i->sit_bitmap_mir)
>  		return -ENOMEM;
>  
> -	sit_i->invalid_segmap = f2fs_kvzalloc(sbi, bitmap_size, GFP_KERNEL);
> +	sit_i->invalid_segmap = f2fs_kvzalloc(sbi,
> +					main_bitmap_size, GFP_KERNEL);
>  	if (!sit_i->invalid_segmap)
>  		return -ENOMEM;
>  #endif
> @@ -4039,7 +4041,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
>  	sit_i->sit_base_addr = le32_to_cpu(raw_super->sit_blkaddr);
>  	sit_i->sit_blocks = sit_segs << sbi->log_blocks_per_seg;
>  	sit_i->written_valid_blocks = 0;
> -	sit_i->bitmap_size = bitmap_size;
> +	sit_i->bitmap_size = sit_bitmap_size;
>  	sit_i->dirty_sentries = 0;
>  	sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK;
>  	sit_i->elapsed_time = le64_to_cpu(sbi->ckpt->elapsed_time);
> 


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

      reply	other threads:[~2019-08-23  1:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26  7:41 [f2fs-dev] [PATCH v2] f2fs: allocate memory in batch in build_sit_info() Chao Yu
2019-08-19 20:20 ` Jaegeuk Kim
2019-08-20  9:12   ` Chao Yu
2019-08-20 17:41     ` Jaegeuk Kim
2019-08-22 17:47       ` Jaegeuk Kim
2019-08-23  1:10         ` 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=4ce7de89-fafb-3796-ae90-8132d2c819cf@huawei.com \
    --to=yuchao0@huawei.com \
    --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).