[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e1becb07-00a2-db5a-e8a5-89db2fcd25ad@suse.de>
Date: Mon, 27 Sep 2021 16:17:47 +0800
From: Coly Li <colyli@...e.de>
To: Geliang Tang <geliangtang@...il.com>
Cc: antlists@...ngman.org.uk, linux-kernel@...r.kernel.org,
nvdimm@...ts.linux.dev, linux-raid@...r.kernel.org,
linux-block@...r.kernel.org,
Dan Williams <dan.j.williams@...el.com>,
Hannes Reinecke <hare@...e.de>, Jens Axboe <axboe@...nel.dk>,
NeilBrown <neilb@...e.de>, Richard Fan <richard.fan@...e.com>,
Vishal L Verma <vishal.l.verma@...el.com>
Subject: Re: [PATCH v3 2/6] badblocks: add helper routines for badblock ranges
handling
On 9/27/21 3:25 PM, Geliang Tang wrote:
> On 9/14/21 00:36, Coly Li wrote:
>> This patch adds several helper routines to improve badblock ranges
>> handling. These helper routines will be used later in the improved
>> version of badblocks_set()/badblocks_clear()/badblocks_check().
>>
>> - Helpers prev_by_hint() and prev_badblocks() are used to find the bad
>> range from bad table which the searching range starts at or after.
>>
>> - The following helpers are to decide the relative layout between the
>> manipulating range and existing bad block range from bad table.
>> - can_merge_behind()
>> Return 'true' if the manipulating range can backward merge with the
>> bad block range.
>> - can_merge_front()
>> Return 'true' if the manipulating range can forward merge with the
>> bad block range.
>> - can_combine_front()
>> Return 'true' if two adjacent bad block ranges before the
>> manipulating range can be merged.
>> - overlap_front()
>> Return 'true' if the manipulating range exactly overlaps with the
>> bad block range in front of its range.
>> - overlap_behind()
>> Return 'true' if the manipulating range exactly overlaps with the
>> bad block range behind its range.
>> - can_front_overwrite()
>> Return 'true' if the manipulating range can forward overwrite the
>> bad block range in front of its range.
>>
>> - The following helpers are to add the manipulating range into the bad
>> block table. Different routine is called with the specific relative
>> layout between the maniplating range and other bad block range in the
>> bad block table.
>> - behind_merge()
>> Merge the maniplating range with the bad block range behind its
>> range, and return the number of merged length in unit of sector.
>> - front_merge()
>> Merge the maniplating range with the bad block range in front of
>> its range, and return the number of merged length in unit of
>> sector.
>> - front_combine()
>> Combine the two adjacent bad block ranges before the manipulating
>> range into a larger one.
>> - front_overwrite()
>> Overwrite partial of whole bad block range which is in front of the
>> manipulating range. The overwrite may split existing bad block
>> range
>> and generate more bad block ranges into the bad block table.
>> - insert_at()
>> Insert the manipulating range at a specific location in the bad
>> block table.
>>
>> All the above helpers are used in later patches to improve the bad block
>> ranges handling for badblocks_set()/badblocks_clear()/badblocks_check().
>>
>> Signed-off-by: Coly Li <colyli@...e.de>
>> Cc: Dan Williams <dan.j.williams@...el.com>
>> Cc: Hannes Reinecke <hare@...e.de>
>> Cc: Jens Axboe <axboe@...nel.dk>
>> Cc: NeilBrown <neilb@...e.de>
>> Cc: Richard Fan <richard.fan@...e.com>
>> Cc: Vishal L Verma <vishal.l.verma@...el.com>
>> ---
>> block/badblocks.c | 374 ++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 374 insertions(+)
>>
>> diff --git a/block/badblocks.c b/block/badblocks.c
>> index d39056630d9c..efe316181e05 100644
>> --- a/block/badblocks.c
>> +++ b/block/badblocks.c
>> @@ -16,6 +16,380 @@
>> #include <linux/types.h>
>> #include <linux/slab.h>
>> +/*
>> + * Find the range starts at-or-before 's' from bad table. The search
>> + * starts from index 'hint' and stops at index 'hint_end' from the bad
>> + * table.
>> + */
>> +static int prev_by_hint(struct badblocks *bb, sector_t s, int hint)
>> +{
>> + u64 *p = bb->page;
>> + int ret = -1;
>> + int hint_end = hint + 2;
>
> How about declaring these variables following the "reverse Xmas tree"
> order.
>
It makes sense. I will do this in whole set for next version.
Thanks for your review.
Coly Li
Powered by blists - more mailing lists