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]
Message-ID: <cfad3954-0572-1da8-38a3-85c8b1164371@huaweicloud.com>
Date: Fri, 21 Feb 2025 17:07:25 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: Zheng Qixing <zhengqixing@...weicloud.com>, axboe@...nel.dk,
 song@...nel.org, colyli@...nel.org, dan.j.williams@...el.com,
 vishal.l.verma@...el.com, dave.jiang@...el.com, ira.weiny@...el.com,
 dlemoal@...nel.org, yanjun.zhu@...ux.dev, kch@...dia.com, hare@...e.de,
 zhengqixing@...wei.com, john.g.garry@...cle.com, geliang@...nel.org,
 xni@...hat.com, colyli@...e.de
Cc: linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-raid@...r.kernel.org, nvdimm@...ts.linux.dev, yi.zhang@...wei.com,
 yangerkun@...wei.com, "yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH 02/12] badblocks: factor out a helper try_adjacent_combine

在 2025/02/21 16:10, Zheng Qixing 写道:
> From: Li Nan <linan122@...wei.com>
> 
> Factor out try_adjacent_combine(), and it will be used in the later patch.
> 
> Signed-off-by: Li Nan <linan122@...wei.com>
> ---
>   block/badblocks.c | 40 ++++++++++++++++++++++++++--------------
>   1 file changed, 26 insertions(+), 14 deletions(-)
> 
LGTM
Reviewed-by: Yu Kuai <yukuai3@...wei.com>
> diff --git a/block/badblocks.c b/block/badblocks.c
> index bcee057efc47..f069c93e986d 100644
> --- a/block/badblocks.c
> +++ b/block/badblocks.c
> @@ -855,6 +855,31 @@ static void badblocks_update_acked(struct badblocks *bb)
>   		bb->unacked_exist = 0;
>   }
>   
> +/*
> + * Return 'true' if the range indicated by 'bad' is exactly backward
> + * overlapped with the bad range (from bad table) indexed by 'behind'.
> + */
> +static bool try_adjacent_combine(struct badblocks *bb, int prev)
> +{
> +	u64 *p = bb->page;
> +
> +	if (prev >= 0 && (prev + 1) < bb->count &&
> +	    BB_END(p[prev]) == BB_OFFSET(p[prev + 1]) &&
> +	    (BB_LEN(p[prev]) + BB_LEN(p[prev + 1])) <= BB_MAX_LEN &&
> +	    BB_ACK(p[prev]) == BB_ACK(p[prev + 1])) {
> +		p[prev] = BB_MAKE(BB_OFFSET(p[prev]),
> +				  BB_LEN(p[prev]) + BB_LEN(p[prev + 1]),
> +				  BB_ACK(p[prev]));
> +
> +		if ((prev + 2) < bb->count)
> +			memmove(p + prev + 1, p + prev + 2,
> +				(bb->count -  (prev + 2)) * 8);
> +		bb->count--;
> +		return true;
> +	}
> +	return false;
> +}
> +
>   /* Do exact work to set bad block range into the bad block table */
>   static int _badblocks_set(struct badblocks *bb, sector_t s, int sectors,
>   			  int acknowledged)
> @@ -1022,20 +1047,7 @@ static int _badblocks_set(struct badblocks *bb, sector_t s, int sectors,
>   	 * merged. (prev < 0) condition is not handled here,
>   	 * because it's already complicated enough.
>   	 */
> -	if (prev >= 0 &&
> -	    (prev + 1) < bb->count &&
> -	    BB_END(p[prev]) == BB_OFFSET(p[prev + 1]) &&
> -	    (BB_LEN(p[prev]) + BB_LEN(p[prev + 1])) <= BB_MAX_LEN &&
> -	    BB_ACK(p[prev]) == BB_ACK(p[prev + 1])) {
> -		p[prev] = BB_MAKE(BB_OFFSET(p[prev]),
> -				  BB_LEN(p[prev]) + BB_LEN(p[prev + 1]),
> -				  BB_ACK(p[prev]));
> -
> -		if ((prev + 2) < bb->count)
> -			memmove(p + prev + 1, p + prev + 2,
> -				(bb->count -  (prev + 2)) * 8);
> -		bb->count--;
> -	}
> +	try_adjacent_combine(bb, prev);
>   
>   	if (space_desired && !badblocks_full(bb)) {
>   		s = orig_start;
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ