Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3743893pxb; Mon, 27 Sep 2021 01:18:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNHE6wu9oacbl3EJg2kLM3lUjVnM9t0m/Mom8mPKPwzMIt9XeTC+zYsHHi8a3KLe3r77LE X-Received: by 2002:aa7:d5c3:: with SMTP id d3mr21589980eds.151.1632730739498; Mon, 27 Sep 2021 01:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632730739; cv=none; d=google.com; s=arc-20160816; b=IdoPqy6fD8fpVitDg3rxIRb2bEiKXJxrpestJkAFZty96e8oD4x8j9Zjo6muK3oWnO atgOZR2jPlBVLO2qia/LlS0qEzmXq5S0v7kZS4kSMRx9thr+3rSq7g3OZt8JzyYegY+o ww2/YrBwIMNKSzDRdM/+JCIglMZFKiAGkw3HAtSGyV9il1d5f7w/W9Rp/C61nOHmdFM6 71wrVggHbEvUBGeWJw7xGHD0/tzSamJcnL+ZUBytwEyGv9uQhYZe58TMNKUBtbwoQ8q/ 2CVoGvdk5mjFpNYkmhblKBLMzMLM8kZOMXs+4uc2eMwAazRYgcWAWl7fC2Hw6dw+DOcF 8SWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-signature; bh=EX5b2PoTJyve491JeLW2N7TfMIYrD37foMnGr9CA/0w=; b=v2ROcrIIk30z+hoD45HQ6fZKnQgXsWY3VoA2oJFmXrNQdR0xGLWLORkdR+JhLJ31Tn YcU96gPAPPrhKLA8Vatxzw6mw9b+v1Y985FOVWRmK2GdkNHg+tBdC86TLx/weESveTvH PlrP6M11AAqlUUNtQpaQg8WuQn1xKmPNfs6dS77dzi3v+rH3SjFWjbeGxL3RpF50Cem8 UV0Narxi9BMzsW/+2Yn3mHD7uQn3KAFUYg8wYjkQf8uudoIKWGffQOxCiO04MInP+XCM PbdhYpO+4vXk+61EyEvVQMnJk8Rf48BunKUsxDLG9IuSfTaz3WzYVkwDQ+vteOn/sqAW cKyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=rKyLH5uL; dkim=neutral (no key) header.i=@suse.de; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 29si14652621eje.659.2021.09.27.01.18.36; Mon, 27 Sep 2021 01:18:59 -0700 (PDT) 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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=rKyLH5uL; dkim=neutral (no key) header.i=@suse.de; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233470AbhI0ISL (ORCPT + 99 others); Mon, 27 Sep 2021 04:18:11 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:36946 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233478AbhI0ISK (ORCPT ); Mon, 27 Sep 2021 04:18:10 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A909F1FF54; Mon, 27 Sep 2021 08:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1632730591; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EX5b2PoTJyve491JeLW2N7TfMIYrD37foMnGr9CA/0w=; b=rKyLH5uL9Cj+5X6l5/QRZY/PiRqBJ6UzOmpYP9JzcNqrrqHcOeoCVYhbJl7TBs004Qdqua MSuqFPVfF0N7/YfniGlmwGi14iA3E6hEQlFg2ObxCUmQ31vQ3NvKubTC84FjuNlzRPoc2a 1RHgzsPF8Wt9JpJasJP6vrgajSAEhLY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1632730591; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EX5b2PoTJyve491JeLW2N7TfMIYrD37foMnGr9CA/0w=; b=VJUy5/syye5jIsbJ3kProycBldLTpI2ktTMoIrZxxKZk1/fykHONwU6+Bc7FaE4N8/BgOP xoBKI72jxh64cDBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 461EC13A42; Mon, 27 Sep 2021 08:16:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aiz+BN19UWEsRwAAMHmgww (envelope-from ); Mon, 27 Sep 2021 08:16:29 +0000 Subject: Re: [PATCH v3 3/6] badblocks: improvement badblocks_set() for multiple ranges handling To: Geliang Tang Cc: antlists@youngman.org.uk, Dan Williams , nvdimm@lists.linux.dev, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, Hannes Reinecke , linux-block@vger.kernel.org, Jens Axboe , NeilBrown , Richard Fan , Vishal L Verma References: <20210913163643.10233-1-colyli@suse.de> <20210913163643.10233-4-colyli@suse.de> <8efbe758-74e4-32ea-d41e-639b750b27c0@gmail.com> From: Coly Li Message-ID: <8c1f4bc4-20c9-4711-4038-c23be7ae9a80@suse.de> Date: Mon, 27 Sep 2021 16:16:27 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <8efbe758-74e4-32ea-d41e-639b750b27c0@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/27/21 3:30 PM, Geliang Tang wrote: > On 9/14/21 00:36, Coly Li wrote: [snipped] >> + * 2.1.1) If S and E are both acked or unacked range, the setting >> range S can >> + *    be merged into existing bad range E. The result is, >> + *        +-------------+ >> + *        |      S      | >> + *        +-------------+ >> + * 2.1.2) If S is uncked setting and E is acked, the setting will be >> dinied, and > > uncked -> unacked > dinied? > You are correct, it should be unacked. >> + *    the result is, >> + *        +-------------+ >> + *        |      E      | >> + *        +-------------+ >> + * 2.1.3) If S is acked setting and E is unacked, range S can >> overwirte on E. >> + *    An extra slot from the bad blocks table will be allocated for >> S, and head >> + *    of E will move to end of the inserted range E. The result is, >> + *        +--------+----+ >> + *        |    S   | E  | >> + *        +--------+----+ >> + * 2.2) The setting range size == already set range size >> + * 2.2.1) If S and E are both acked or unacked range, the setting >> range S can >> + *    be merged into existing bad range E. The result is, >> + *        +-------------+ >> + *        |      S      | >> + *        +-------------+ >> + * 2.2.2) If S is uncked setting and E is acked, the setting will be >> dinied, and > > uncked -> unacked Yes, thanks for pointing out the typo. I will fix them in next version. [snipped] >> +/* Do exact work to set bad block range into the bad block table */ >> +static int _badblocks_set(struct badblocks *bb, sector_t s, int >> sectors, >> +              int acknowledged) >> +{ >> +    u64 *p; >> +    struct badblocks_context bad; >> +    int prev = -1, hint = -1; >> +    int len = 0, added = 0; >> +    int retried = 0, space_desired = 0; >> +    int rv = 0; >> +    unsigned long flags; > > orig_start and orig_len are used in _badblocks_set() only, we can drop > them from struct badblocks_context, declare two local variables instead: > >         sector_t orig_start; >         int orig_len; > It's fair, let me change it in next version. [snipped] Thanks for your review! Coly Li