lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 1 Jul 2020 09:19:27 -0700
From:   Jaegeuk Kim <jaegeuk@...nel.org>
To:     Chao Yu <yuchao0@...wei.com>
Cc:     linux-f2fs-devel@...ts.sourceforge.net,
        linux-kernel@...r.kernel.org, chao@...nel.org
Subject: Re: [PATCH RFC 2/5] f2fs: record average update time of segment

On 06/30, Chao Yu wrote:
> Previously, once we update one block in segment, we will update mtime of
> segment to last time, making aged segment becoming freshest, result in
> that GC with cost benefit algorithm missing such segment, So this patch
> changes to record mtime as average block updating time instead of last
> updating time.
> 
> It's not needed to reset mtime for prefree segment, as se->valid_blocks
> is zero, then old se->mtime won't take any weight with below calculation:
> 
> 	se->mtime = (se->mtime * se->valid_blocks + mtime) /
> 				(se->valid_blocks + 1);
> 
> Signed-off-by: Chao Yu <yuchao0@...wei.com>
> ---
>  fs/f2fs/segment.c | 21 ++++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 863ec6f1fb87..906c313835ad 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -2150,6 +2150,22 @@ static void __set_sit_entry_type(struct f2fs_sb_info *sbi, int type,
>  		__mark_sit_entry_dirty(sbi, segno);
>  }
>  
> +static void update_segment_mtime(struct f2fs_sb_info *sbi, block_t blkaddr)
> +{
> +	unsigned int segno = GET_SEGNO(sbi, blkaddr);
> +	struct seg_entry *se = get_seg_entry(sbi, segno);
> +	unsigned long long mtime = get_mtime(sbi, false);
> +
> +	if (!se->mtime) {

Don't need {}.

> +		se->mtime = mtime;
> +	} else {
> +		se->mtime = (se->mtime * se->valid_blocks + mtime) /
> +						(se->valid_blocks + 1);
> +	}
> +	if (mtime > SIT_I(sbi)->max_mtime)
> +		SIT_I(sbi)->max_mtime = mtime;
> +}
> +
>  static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
>  {
>  	struct seg_entry *se;
> @@ -2169,10 +2185,9 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
>  	f2fs_bug_on(sbi, (new_vblocks >> (sizeof(unsigned short) << 3) ||
>  				(new_vblocks > sbi->blocks_per_seg)));
>  
> +	update_segment_mtime(sbi, blkaddr);
> +
>  	se->valid_blocks = new_vblocks;
> -	se->mtime = get_mtime(sbi, false);
> -	if (se->mtime > SIT_I(sbi)->max_mtime)
> -		SIT_I(sbi)->max_mtime = se->mtime;
>  
>  	/* Update valid block bitmap */
>  	if (del > 0) {
> -- 
> 2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ