Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1060471pxb; Thu, 4 Mar 2021 02:06:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHlFn6T3lXS2BCJwG7j3LW45ZKbryg+Ed2SeVzmnuQ9/PKs1O3jb9rg3nuH0UfTseh5UEX X-Received: by 2002:a50:e14d:: with SMTP id i13mr3449526edl.106.1614852412783; Thu, 04 Mar 2021 02:06:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614852412; cv=none; d=google.com; s=arc-20160816; b=lT8w89xM/ucbARis07obM3HbDjZZqxPHRzgwA6WcdgUhT0Q28mR9Qc93vHbfxpAaB2 JgbqDQh3Nz5j8AlH0b65OkERmPjuNXLx0zm/+9ERuSlUxHvWsctB8s8s2oGHnVtT38J4 a41eQYHeQlSv0ko/vkSUvC3ge7BlXLCTlgbwWjl5YO4NLLLdJarkmU1c43NKtIKGlwgl qpSt5AuNYCLheiOUVXwQUuR5tb1iaQzZg7cJnJxJDBxBvEcKSPnLKqDK4jsgXnf+DrQI +CQYDCm/idtmm9LgbU2CY0ZL4/0y20cAEA++rtcYSlJKnoymeWf1Cr5W7hDyC/rJdZk4 6Y0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=bzRy2aaSnkbIDpYnxkgojiXzhBa0bvbNAdpo57r7ueU=; b=gjvEDh/Pv7qeb6GA6aowCNrzsdrXVYHOuKLhBJUHwhbUoN1ookd5hmdSQvGrcBbUYY gIl9pJpsWMIhKkOcIxuSXiTudD7K3rInplT06xNc3ov1kPPwfdpmsAuM/fABZr/1goCY BrrIZmT78P7S0DROi5czhkFmy1TiWYRdp//M8NanENdqqc576UJaa2/d/uLxHRxdCvTJ HF8+5Al1d3EkWdJqhVB4Ai/2rbCYNEGfM6tclUStxO601ez+x7/11VsqOAgwNIl/tXqV 3jU4XIhxiF7091i5A/HHtRMliFL1ofweHWoUST3qh5GLwWH2CeDtNSSXP+ttCPlTmsxx 8Gkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc12si11503627edb.241.2021.03.04.02.06.30; Thu, 04 Mar 2021 02:06:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1452807AbhCCQTD (ORCPT + 99 others); Wed, 3 Mar 2021 11:19:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:54172 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242631AbhCCLqP (ORCPT ); Wed, 3 Mar 2021 06:46:15 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2929EAD2B; Wed, 3 Mar 2021 11:45:12 +0000 (UTC) Subject: Re: [RFC PATCH v1 1/6] badblocks: add more helper structure and routines in badblocks.h To: Hannes Reinecke Cc: antlists@youngman.org.uk, axboe@kernel.dk, linux-kernel@vger.kernel.org, dan.j.williams@intel.com, linux-raid@vger.kernel.org, vishal.l.verma@intel.com, linux-nvdimm@lists.01.org, linux-block@vger.kernel.org, neilb@suse.de References: <20210302040252.103720-1-colyli@suse.de> <20210302040252.103720-2-colyli@suse.de> <96a899a9-151e-ff8c-c61c-900df1122357@suse.de> From: Coly Li Message-ID: <01aee83b-89d6-6048-ebfc-d07be1aaea7e@suse.de> Date: Wed, 3 Mar 2021 19:45:07 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <96a899a9-151e-ff8c-c61c-900df1122357@suse.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/3/21 4:20 PM, Hannes Reinecke wrote: > On 3/2/21 5:02 AM, Coly Li wrote: >> This patch adds the following helper structure and routines into >> badblocks.h, >> - struct bad_context >> This structure is used in improved badblocks code for bad table >> iteration. >> - BB_END() >> The macro to culculate end LBA of a bad range record from bad >> table. >> - badblocks_full() and badblocks_empty() >> The inline routines to check whether bad table is full or empty. >> - set_changed() and clear_changed() >> The inline routines to set and clear 'changed' tag from struct >> badblocks. >> >> These new helper structure and routines can help to make the code more >> clear, they will be used in the improved badblocks code in following >> patches. >> >> Signed-off-by: Coly Li >> --- >> include/linux/badblocks.h | 32 ++++++++++++++++++++++++++++++++ >> 1 file changed, 32 insertions(+) >> >> diff --git a/include/linux/badblocks.h b/include/linux/badblocks.h >> index 2426276b9bd3..166161842d1f 100644 >> --- a/include/linux/badblocks.h >> +++ b/include/linux/badblocks.h >> @@ -15,6 +15,7 @@ >> #define BB_OFFSET(x) (((x) & BB_OFFSET_MASK) >> 9) >> #define BB_LEN(x) (((x) & BB_LEN_MASK) + 1) >> #define BB_ACK(x) (!!((x) & BB_ACK_MASK)) >> +#define BB_END(x) (BB_OFFSET(x) + BB_LEN(x)) >> #define BB_MAKE(a, l, ack) (((a)<<9) | ((l)-1) | ((u64)(!!(ack)) << 63)) >> >> /* Bad block numbers are stored sorted in a single page. >> @@ -41,6 +42,14 @@ struct badblocks { >> sector_t size; /* in sectors */ >> }; >> >> +struct bad_context { >> + sector_t start; >> + sector_t len; >> + int ack; >> + sector_t orig_start; >> + sector_t orig_len; >> +}; >> + > Maybe rename it to 'badblocks_context'. > It's not the context which is bad ... > Copied, I will modify it in next version. Thanks for the suggestion. Coly Li