linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Coly Li <colyli@suse.de>
To: Geliang Tang <geliangtang@gmail.com>
Cc: antlists@youngman.org.uk, linux-kernel@vger.kernel.org,
	nvdimm@lists.linux.dev, linux-raid@vger.kernel.org,
	linux-block@vger.kernel.org,
	Dan Williams <dan.j.williams@intel.com>,
	Hannes Reinecke <hare@suse.de>, Jens Axboe <axboe@kernel.dk>,
	NeilBrown <neilb@suse.de>, Richard Fan <richard.fan@suse.com>,
	Vishal L Verma <vishal.l.verma@intel.com>
Subject: Re: [PATCH v3 2/6] badblocks: add helper routines for badblock ranges handling
Date: Mon, 27 Sep 2021 16:17:47 +0800	[thread overview]
Message-ID: <e1becb07-00a2-db5a-e8a5-89db2fcd25ad@suse.de> (raw)
In-Reply-To: <eab6a9b0-d934-77e4-519c-cefc510b183a@gmail.com>

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@suse.de>
>> Cc: Dan Williams <dan.j.williams@intel.com>
>> Cc: Hannes Reinecke <hare@suse.de>
>> Cc: Jens Axboe <axboe@kernel.dk>
>> Cc: NeilBrown <neilb@suse.de>
>> Cc: Richard Fan <richard.fan@suse.com>
>> Cc: Vishal L Verma <vishal.l.verma@intel.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


  reply	other threads:[~2021-09-27  8:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13 16:36 [PATCH v3 0/7] badblocks improvement for multiple bad block ranges Coly Li
2021-09-13 16:36 ` [PATCH v3 1/6] badblocks: add more helper structure and routines in badblocks.h Coly Li
2021-09-27  7:23   ` Geliang Tang
2021-09-27  8:23     ` Coly Li
2021-09-13 16:36 ` [PATCH v3 2/6] badblocks: add helper routines for badblock ranges handling Coly Li
2021-09-27  7:25   ` Geliang Tang
2021-09-27  8:17     ` Coly Li [this message]
2021-09-13 16:36 ` [PATCH v3 3/6] badblocks: improvement badblocks_set() for multiple " Coly Li
2021-09-27  7:30   ` Geliang Tang
2021-09-27  8:16     ` Coly Li
2021-09-13 16:36 ` [PATCH v3 4/6] badblocks: improve badblocks_clear() " Coly Li
2021-09-13 16:36 ` [PATCH v3 5/6] badblocks: improve badblocks_check() " Coly Li
2021-09-13 16:36 ` [PATCH v3 6/6] badblocks: switch to the improved badblock handling code Coly Li
2021-09-13 16:36 ` [PATCH] test: user space code to test badblocks APIs Coly Li
2021-09-23  5:59 ` Too large badblocks sysfs file (was: [PATCH v3 0/7] badblocks improvement for multiple bad block ranges) Coly Li
2021-09-23  6:08   ` Greg Kroah-Hartman
2021-09-23  6:14     ` Coly Li
2021-09-23  6:47       ` Greg Kroah-Hartman
2021-09-23  7:13         ` Coly Li
2021-09-23  9:40   ` Hannes Reinecke
2021-09-23  9:57     ` Greg Kroah-Hartman
2021-09-23 10:09   ` NeilBrown
2021-09-23 10:39     ` Greg Kroah-Hartman
2021-09-23 12:55     ` Coly Li
2021-12-02 12:52 [PATCH v4 0/6] badblocks improvement for multiple bad block ranges Coly Li
2021-12-02 12:52 ` [PATCH v3 2/6] badblocks: add helper routines for badblock ranges handling Coly Li
2021-12-09  7:22   ` Geliang Tang
2021-12-10  6:57     ` Coly Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e1becb07-00a2-db5a-e8a5-89db2fcd25ad@suse.de \
    --to=colyli@suse.de \
    --cc=antlists@youngman.org.uk \
    --cc=axboe@kernel.dk \
    --cc=dan.j.williams@intel.com \
    --cc=geliangtang@gmail.com \
    --cc=hare@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=nvdimm@lists.linux.dev \
    --cc=richard.fan@suse.com \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).