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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5a898849-999f-403b-8e1a-761033b3f7b5@vivo.com>
Date: Thu, 2 Jan 2025 10:52:49 +0000
From: Chunhai Guo <guochunhai@...o.com>
To: Chunhai Guo <guochunhai@...o.com>, "chao@...nel.org" <chao@...nel.org>,
	"jaegeuk@...nel.org" <jaegeuk@...nel.org>
CC: "linux-f2fs-devel@...ts.sourceforge.net"
	<linux-f2fs-devel@...ts.sourceforge.net>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] f2fs: fix missing discard for active segments

在 12/3/2024 2:51 PM, Chunhai Guo 写道:

Dear Chao & Jaegeuk,

Could you please help review this patch? Currently, this issue is quite 
easy to reproduce in some projects.

Thanks,

> locate_dirty_segment() does not set any current active segment as a
> prefree segment. Thus, the issue described below may occur:
>
> Step 1: During a checkpoint, add_discard_addrs() does not handle the
> current active 'segment X' with 0 valid blocks (and non-zero discard
> blocks). As a result, no struct discard_cmd is created for 'segment X'
> and the value of sbi->discard_blks cannot be reduced to 0 after the
> checkpoint.
>
> Step 2: f2fs is umounted without setting CP_TRIMMED_FLAG, as
> sbi->discard_blks is non-zero.
>
> Since add_discard_addrs() can handle active segments with non-zero valid
> blocks, it is reasonable to fix this issue by also handling active
> segments with 0 valid blocks in add_discard_addrs().
>
> Signed-off-by: Chunhai Guo <guochunhai@...o.com>
> ---
>   fs/f2fs/segment.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index eade36c5ef13..4fb1dc4aab97 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -2090,7 +2090,9 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
>   		return false;
>   
>   	if (!force) {
> -		if (!f2fs_realtime_discard_enable(sbi) || !se->valid_blocks ||
> +		if (!f2fs_realtime_discard_enable(sbi) ||
> +			(!se->valid_blocks &&
> +				!IS_CURSEG(sbi, cpc->trim_start)) ||
>   			SM_I(sbi)->dcc_info->nr_discards >=
>   				SM_I(sbi)->dcc_info->max_discards)
>   			return false;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ