Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3247012ioa; Mon, 25 Apr 2022 22:48:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxcDScu5NfWWMFU+Jzb+9HS3a6NfCEMjQxPswMPbUlK12bM8jRfc3EKHRCoNsCVgzoWB5W X-Received: by 2002:a17:907:728f:b0:6f3:b55a:c330 with SMTP id dt15-20020a170907728f00b006f3b55ac330mr662098ejc.297.1650952096105; Mon, 25 Apr 2022 22:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650952096; cv=none; d=google.com; s=arc-20160816; b=Y7C4+qbpgqS7Yf/+7IICcQfjQCTDscFde4TXX2eIh4p/kcHAKqkR/gICuDx4N3Wgaq U/JDHOaYD2UcWqGdqsFxntHNtvWWcx4IA+KOAlfqE7rgJynRI1/fY6a+xzK/CVJIWxw3 xt8+3r7K9n2P3+TWDioAUfe0nSg4Iv2qmQQXvGC+kqJGtQoBUw2guKSPInQjzsLxqJsa FVkfXoiAElXjmOg5ZtSdY3t12nr8TZpfJaYmyuMh2n87TKDr+J39T0LGl6G9ws94eRFw HV3gnwQ23Gzk58sSx8P7GmzE/gWzhileeS6wXkj4IZihaPLv1WXXG6UamgJCF9poDQDy N1vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hJpEHj89mhIBilz3/nz0wFxp4bOMeEdUxbSKZhw0rBc=; b=doSvEk0+CT7CNAu2QkdAXvaKVoKkvVjQRg3A9ex7U6VojbVZpWAvzSsz17d0sWUXBd xwmQrvLqMcsKQIgprLTqExN8HjdvDCb/fGggTEMKT3yRQulyxXGNLVBS5F0WbCfKm1Ds N30DhvWYt/ZhLqUeQK0TrbP9aOqECXZo1iR9g33n7+Uohyrc3qd+uwuuVUXZzH22+AJQ lgJ+u2jqwn399MpX28HFBpGMKeg7l2wr3d58QDm1Fi18cyu4aOCbthXOV1WAITyWwNXQ 1xiLo/V6N9TKMHdOcVCqGEAOXHAOmhYagb0ToKrptzU019NzXdJFPGyFK7y8cYw9kMi7 n9Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="E/JcjnDm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot13-20020a170906cccd00b006f38758b266si5641848ejb.160.2022.04.25.22.47.52; Mon, 25 Apr 2022 22:48:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="E/JcjnDm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229854AbiDYWZQ (ORCPT + 99 others); Mon, 25 Apr 2022 18:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232405AbiDYVYF (ORCPT ); Mon, 25 Apr 2022 17:24:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76AEC8BF5D; Mon, 25 Apr 2022 14:21:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0FCA161422; Mon, 25 Apr 2022 21:21:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B989C385A7; Mon, 25 Apr 2022 21:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650921659; bh=yeW9+BBUV3mLk/jfmzfFnnmQesZ+9KRuhHEuOliabrk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=E/JcjnDmi7uOq5bko2zU6SjHLd+HzINwHPRYwmO9Gp0hKeaMyU1dxx9ZmrEOsf7Zj pIEW7sM6WK2FbIV/zrXyRju9itO4v7kfA4YUtVR7YRq0ogeDwPDsZSduI6gyqAynkM 6+hoAgKuLvu9CXOOLyq/V+VIIs6ASajy7LDcx8lpWHipD89wNms2zwFjMBIeYpahuu cnMBtBCYdPAee6EVicQpPLLhoG8TccCTbBG/wetCvdki0dmUZOKfS/pyCP95jBMqkA X6ioiWzvNJ2dRltuNo5uLSf+DExXSHn3aZg9HC1nCRXd7GCxkGFURSpczrBLiH8Qxo K+k8Ys/6UzJhA== Received: by mail-yb1-f177.google.com with SMTP id r189so29435566ybr.6; Mon, 25 Apr 2022 14:20:59 -0700 (PDT) X-Gm-Message-State: AOAM532D1L70MPCgiEa466nVhgk3bkILwVvwn1ckPI7QwS0DUNGpkOMK 90VxGDR8EQS8O2EalmgleKAGU0VajX5sNNFibSo= X-Received: by 2002:a05:6902:114c:b0:641:87a7:da90 with SMTP id p12-20020a056902114c00b0064187a7da90mr18971886ybu.561.1650921658476; Mon, 25 Apr 2022 14:20:58 -0700 (PDT) MIME-Version: 1.0 References: <20220421194558.59667-1-david.sloan@eideticom.com> In-Reply-To: <20220421194558.59667-1-david.sloan@eideticom.com> From: Song Liu Date: Mon, 25 Apr 2022 14:20:47 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] md: Replace role magic numbers with defined constants To: David Sloan Cc: linux-raid , open list , Logan Gunthorpe Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 21, 2022 at 12:46 PM David Sloan wrote: > > There are several instances where magic numbers are used in md.c instead > of the defined constants in md_p.h. This patch set improves code > readability by replacing all occurrences of 0xffff, 0xfffe, and 0xfffd when > relating to md roles with their equivalent defined constant. > > Signed-off-by: David Sloan > Reviewed-by: Logan Gunthorpe Thanks for the clean up! > --- > drivers/md/md.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/drivers/md/md.c b/drivers/md/md.c > index 309b3af906ad..b34b72fc5887 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -2645,11 +2645,12 @@ static bool does_sb_need_changing(struct mddev *mddev) > rdev_for_each(rdev, mddev) { > role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]); > /* Device activated? */ > - if (role == 0xffff && rdev->raid_disk >=0 && > + if (role == MD_DISK_ROLE_SPARE && rdev->raid_disk >= 0 && > !test_bit(Faulty, &rdev->flags)) > return true; > /* Device turned faulty? */ > - if (test_bit(Faulty, &rdev->flags) && (role < 0xfffd)) > + if (test_bit(Faulty, &rdev->flags) && > + role < MD_DISK_ROLE_JOURNAL) I changed this to role < MD_DISK_ROLE_MAX. Also made some minor style changes, and applied it to md-next. Thanks, Song > return true; > } [...]