From: Li Nan <linan666@huaweicloud.com>
To: Ashok Raj <ashok_raj@linux.intel.com>
Cc: axboe@kernel.dk, dan.j.williams@intel.com,
vishal.l.verma@intel.com, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, yukuai3@huawei.com,
yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com,
Ashok Raj <ashok.raj@intel.com>,
linan122@huawei.com
Subject: Re: [PATCH v3 3/4] block/badblocks: fix badblocks loss when badblocks combine
Date: Sun, 25 Jun 2023 17:16:32 +0800 [thread overview]
Message-ID: <1f48c2d9-3e51-d8bf-466a-bb1fe9e07282@huaweicloud.com> (raw)
In-Reply-To: <ZJMEtGw+FYT8mRG+@araj-dh-work>
在 2023/6/21 22:09, Ashok Raj 写道:
> On Thu, Jun 22, 2023 at 01:20:51AM +0800, linan666@huaweicloud.com wrote:
>> From: Li Nan <linan122@huawei.com>
>>
>> badblocks will loss if we set it as below:
>>
>> # echo 1 1 > bad_blocks
>> # echo 3 1 > bad_blocks
>> # echo 1 5 > bad_blocks
>> # cat bad_blocks
>> 1 3
>>
>> In badblocks_set(), if there is an intersection between p[lo] and p[hi],
>> we will combine them. The end of new badblocks is p[hi]'s end now. but
>> p[lo] may cross p[hi] and new end should be the larger of p[lo] and p[hi].
>
> Reconsider rewriting the commit log. It seems you converted code to
> sentence ;-).
I will rewrite log.
>
> Also it might help to show after the patch how the above example would be
> for cat bad_blocks
>
after patch:
# cat bad_blocks
1 5
I will show it in next version. Thanks for your suggestion.
>>
>> Fixes: 9e0e252a048b ("badblocks: Add core badblock management code")
>> Signed-off-by: Li Nan <linan122@huawei.com>
>> ---
>> block/badblocks.c | 10 ++++------
>> 1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/block/badblocks.c b/block/badblocks.c
>> index 7e6ebe2ac12c..2c2ef8284a3f 100644
>> --- a/block/badblocks.c
>> +++ b/block/badblocks.c
>> @@ -267,16 +267,14 @@ int badblocks_set(struct badblocks *bb, sector_t s, int sectors,
>> if (sectors == 0 && hi < bb->count) {
>> /* we might be able to combine lo and hi */
>> /* Note: 's' is at the end of 'lo' */
>> - sector_t a = BB_OFFSET(p[hi]);
>> - int lolen = BB_LEN(p[lo]);
>> - int hilen = BB_LEN(p[hi]);
>> - int newlen = lolen + hilen - (s - a);
>> + sector_t a = BB_OFFSET(p[lo]);
>> + int newlen = max(s, BB_OFFSET(p[hi]) + BB_LEN(p[hi])) - a;
>>
>> - if (s >= a && newlen < BB_MAX_LEN) {
>> + if (s >= BB_OFFSET(p[hi]) && newlen < BB_MAX_LEN) {
>> /* yes, we can combine them */
>> int ack = BB_ACK(p[lo]) && BB_ACK(p[hi]);
>>
>> - p[lo] = BB_MAKE(BB_OFFSET(p[lo]), newlen, ack);
>> + p[lo] = BB_MAKE(a, newlen, ack);
>> memmove(p + hi, p + hi + 1,
>> (bb->count - hi - 1) * 8);
>> bb->count--;
>> --
>> 2.39.2
>>
>
> .
--
Thanks,
Nan
next prev parent reply other threads:[~2023-06-25 9:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-21 17:20 [PATCH v3 0/4] block/badblocks: fix badblocks setting error linan666
2023-06-21 13:32 ` Ashok Raj
2023-06-25 8:13 ` Li Nan
2023-06-21 17:20 ` [PATCH v3 1/4] block/badblocks: change some members of badblocks to bool linan666
2023-06-21 14:02 ` Ashok Raj
2023-06-25 9:11 ` Li Nan
2023-06-21 17:20 ` [PATCH v3 2/4] block/badblocks: only set bb->changed/unacked_exist when badblocks changes linan666
2023-06-21 17:20 ` [PATCH v3 3/4] block/badblocks: fix badblocks loss when badblocks combine linan666
2023-06-21 14:09 ` Ashok Raj
2023-06-25 9:16 ` Li Nan [this message]
2023-06-21 17:20 ` [PATCH v3 4/4] block/badblocks: fix the bug of reverse order linan666
2023-06-21 14:15 ` Ashok Raj
2023-06-25 9:22 ` Li Nan
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=1f48c2d9-3e51-d8bf-466a-bb1fe9e07282@huaweicloud.com \
--to=linan666@huaweicloud.com \
--cc=ashok.raj@intel.com \
--cc=ashok_raj@linux.intel.com \
--cc=axboe@kernel.dk \
--cc=dan.j.williams@intel.com \
--cc=houtao1@huawei.com \
--cc=linan122@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vishal.l.verma@intel.com \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.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
all inboxes | Powered by JetHome®