Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1029689pxb; Thu, 4 Mar 2021 01:05:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8727LGGy+egX6pOxTY53kr2oO/kl3krIM33m8fYsHCKqqdvoM4p5sms8s1lqKrCZ+Dzgy X-Received: by 2002:aa7:d4d2:: with SMTP id t18mr3221151edr.342.1614848729809; Thu, 04 Mar 2021 01:05:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614848729; cv=none; d=google.com; s=arc-20160816; b=qHAhB/IAiDLI+N+4arCGeOwc1FY5uJBjsK0h7KuHuI1/FImQAq82KU4/lN+2njmozw Gl5koKgvwLfiK1IaJhUplKUacfBSHtnymSkg9upxnZefB7SGbavcQxwQQ1K4ngA/TcAB 1c1YbamI8J29yB96EEmMyLPdK1rsovZ7V8rovCpGTyJOJCYszl3SSi5UKXYD+GJorS20 W1m6KYEI0/4H+lSiVCwNf0NUuotFy5NFAyrOykp7lmJayu8tnzWJDcNwJRalQPWXkPWT zftxFT7pOA4HHC5+ph+n24j55ACedHAvRseC7VkkK/gx0xKlHA43gsY/saiwjnU7DuWJ Td2g== 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=mM/w5UhhsZiW9uIiChuo06d2F1t9mhBWXmYMYwWvyQU=; b=wHhI0xjyuFYL/J1FmoDZAJ+fDIjssjYrtyVXKzvJ0F0D3S2NAUxkrbwD10achO6MC+ SZtLmYJ18afCWrlwGBMnBftV+wMC7dTf5prmQLU0gYAiJLmktPYT5AQFUqoOTwASp0ep VMAvUtBaabsu/PqkyCNmJ9j+BGqdCZVH48P5huws1pcIU+DJGxCdYh9fCFkJqMaquXAm db2i1FbYfJvbp3PFt80FTeJuKA1FiFdZAmSsrrHHbrrOBPA/hfNB8suMTXeqXIN150u2 RIFdovG2ZYwLLK8twBw21foblubU2gVnMmPN4I68QkY2u0yDZ2bjJ3aNOl/N4woVbjrw JGsA== 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 z26si6165722ejw.136.2021.03.04.01.05.07; Thu, 04 Mar 2021 01:05:29 -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 S1382794AbhCCNb1 (ORCPT + 99 others); Wed, 3 Mar 2021 08:31:27 -0500 Received: from mx2.suse.de ([195.135.220.15]:32948 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379675AbhCCIVA (ORCPT ); Wed, 3 Mar 2021 03:21:00 -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 2075AAD57; Wed, 3 Mar 2021 08:20:18 +0000 (UTC) Subject: Re: [RFC PATCH v1 1/6] badblocks: add more helper structure and routines in badblocks.h To: Coly Li , linux-block@vger.kernel.org, axboe@kernel.dk, dan.j.williams@intel.com, vishal.l.verma@intel.com, neilb@suse.de Cc: antlists@youngman.org.uk, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-nvdimm@lists.01.org References: <20210302040252.103720-1-colyli@suse.de> <20210302040252.103720-2-colyli@suse.de> From: Hannes Reinecke Message-ID: <96a899a9-151e-ff8c-c61c-900df1122357@suse.de> Date: Wed, 3 Mar 2021 09:20:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210302040252.103720-2-colyli@suse.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ... Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer