[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d5dd72dd-41b4-ce66-6208-38ac6066acef@huaweicloud.com>
Date: Sat, 22 Feb 2025 09:14:41 +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 07/12] badblocks: try can_merge_front before overlap_front
在 2025/02/21 16:11, Zheng Qixing 写道:
> From: Li Nan <linan122@...wei.com>
>
> Regardless of whether overlap_front() returns true or false,
> can_merge_front() will be executed first. Therefore, move
> can_merge_front() in front of can_merge_front() to simplify code.
>
> Signed-off-by: Li Nan <linan122@...wei.com>
> ---
> block/badblocks.c | 48 ++++++++++++++++++++++-------------------------
> 1 file changed, 22 insertions(+), 26 deletions(-)
>
LGTM
Reviewed-by: Yu Kuai <yukuai3@...wei.com>
> diff --git a/block/badblocks.c b/block/badblocks.c
> index 87267bae6836..bb46bab7e99f 100644
> --- a/block/badblocks.c
> +++ b/block/badblocks.c
> @@ -905,39 +905,35 @@ static int _badblocks_set(struct badblocks *bb, sector_t s, int sectors,
> goto update_sectors;
> }
>
> + if (can_merge_front(bb, prev, &bad)) {
> + len = front_merge(bb, prev, &bad);
> + added++;
> + hint = prev;
> + goto update_sectors;
> + }
> +
> if (overlap_front(bb, prev, &bad)) {
> - if (can_merge_front(bb, prev, &bad)) {
> - len = front_merge(bb, prev, &bad);
> - added++;
> - } else {
> - int extra = 0;
> + int extra = 0;
>
> - if (!can_front_overwrite(bb, prev, &bad, &extra)) {
> - if (extra > 0)
> - goto out;
> + if (!can_front_overwrite(bb, prev, &bad, &extra)) {
> + if (extra > 0)
> + goto out;
>
> - len = min_t(sector_t,
> - BB_END(p[prev]) - s, sectors);
> - hint = prev;
> - goto update_sectors;
> - }
> + len = min_t(sector_t,
> + BB_END(p[prev]) - s, sectors);
> + hint = prev;
> + goto update_sectors;
> + }
>
> - len = front_overwrite(bb, prev, &bad, extra);
> - added++;
> - bb->count += extra;
> + len = front_overwrite(bb, prev, &bad, extra);
> + added++;
> + bb->count += extra;
>
> - if (can_combine_front(bb, prev, &bad)) {
> - front_combine(bb, prev);
> - bb->count--;
> - }
> + if (can_combine_front(bb, prev, &bad)) {
> + front_combine(bb, prev);
> + bb->count--;
> }
> - hint = prev;
> - goto update_sectors;
> - }
>
> - if (can_merge_front(bb, prev, &bad)) {
> - len = front_merge(bb, prev, &bad);
> - added++;
> hint = prev;
> goto update_sectors;
> }
>
Powered by blists - more mailing lists