Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2485933lqo; Mon, 13 May 2024 23:10:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOt7MFXkklxKjoAyAHEtfMeImkBsUfNMMVX7QIhIUcWrdvAds57zwI+TzLfU/yzu0sd40n66JvHU6+qtPGbCqksTASSDJiu3rfiizbBQ== X-Google-Smtp-Source: AGHT+IHYOZQ0NqtZQFPItOtYJGAI+xWLif9U4PnG1dLF19lmmrIvH6aFdnQIg9sLrPxkemIT9M9C X-Received: by 2002:a05:690c:6102:b0:61b:91e3:f971 with SMTP id 00721157ae682-622b001ed89mr129837877b3.39.1715667050039; Mon, 13 May 2024 23:10:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715667050; cv=pass; d=google.com; s=arc-20160816; b=njYrNmpZ+231SjkQBz/R0qF5kPPE2cWwc1W90LVRWLbk4R/rnFt95F9rMsw4BP1Bfv P3s4XmAHaFx8vEoNk3kTcJj9ysdQ69b5Tur6xyZgTlEdHo9vdeTP6lpuaw2H4HdySm1E fWGw62YKuYEWVNXv+pfbv60wMLap42xbgA8OyUIyxVF/sk1fS2VoxM8CICDWIUxpGHKl B2Ey4MqSQuAphqQlqzRUfGKtkpPwI5M6K4yZRhkqLqmVf7LiAhder1Mb1e640D+HEqfh U3gJG0nDxCYfP1CUHvjidnN7Zc1ldoNF5l3YqEIJsPTFEN9seP7R7HGRGXyNjFtJuFk9 45mw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :references:cc:to:subject; bh=cVPntXmoa6l+nrU5GsRPq2+ks8DeqGN6KKKCZR4EPgw=; fh=7XeR3ua4fuc2ZoR6dl+kgTmgqTMQ8MgPFYYydJ9V4E8=; b=eILP18KB6I/fx2lNRpX+DRww0zuDh7OFAEw2NvPTq3OHVIjezKGqOgtrZzD6EHqghD UW+PTAG+hNrjXN58baZcHlC6XWr7wBuf2SPg8Eh0H2dnbKQCGgxc6pzk9jSlSlBCvoi/ vYHvxNGPpnYUtquNNMOUwjqWJUMIzW8FbXe5y8VAoL0CaGcy369Xv+ttTOWksPbAqx0K HHWMaz5TsrcHG9CMwVaD4OGZwZA/4O09qNE6cQuM9eW1AWCKWP3uj+gCBHICC5KceAPr B3VOZxP5JAy+ZEpIc/3LcV5+yyld73/6l0WeTSKs6xg4EL4gNrj+FSSoWHqAxP8NnlD5 rQjg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-178342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178342-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43df8d2e5a4si107239501cf.54.2024.05.13.23.10.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 23:10:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-178342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178342-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B1EF41C20FB6 for ; Tue, 14 May 2024 06:10:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 037F21D55D; Tue, 14 May 2024 06:10:39 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BC5E18643; Tue, 14 May 2024 06:10:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715667038; cv=none; b=seNwikCz1EKqI+iMp//k99gJFDuHHlG24Deq2M7G741+fXRtx2c2Aq/1Dy/EabyOJQsmI1J9Oar35gcI95QH/htGGBd2Fv7pp4sE9YHZqsolUW6f8JR6+aUkpwY36ncw31Xkeml4He7bBl0jFzOcf80MkBX3W1gZcu72aAsnaTw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715667038; c=relaxed/simple; bh=POgx0G3yJuUrfQT1wjeXgb2RlNIUmIDzVrU35Dl0hBI=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=AdjTok9SqdBXdlrsDHw5Ip/znwV3y5HG7AWoIxLNWjhh8RznkjvLX83SN4w4Gcu1b1EK5rAF1af01PlOfWNnqixBNwyOD/T2bTfUmgM6ROzWb0Hg/8sGIr8mC/2QYSFFxLjaWA2znHd8UN+hsA3CFKnzhzB8QE9mKpZC31OTEz8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VdmDd71qHz4f3jLc; Tue, 14 May 2024 14:10:25 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 7DD121A0F6F; Tue, 14 May 2024 14:10:31 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgAX5g5VAENmchh5Mg--.22041S3; Tue, 14 May 2024 14:10:31 +0800 (CST) Subject: Re: [PATCH md-6.10 1/9] md: rearrange recovery_flage To: Xiao Ni , Yu Kuai Cc: agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, "yukuai (C)" References: <20240509011900.2694291-1-yukuai1@huaweicloud.com> <20240509011900.2694291-2-yukuai1@huaweicloud.com> From: Yu Kuai Message-ID: Date: Tue, 14 May 2024 14:10:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgAX5g5VAENmchh5Mg--.22041S3 X-Coremail-Antispam: 1UD129KBjvJXoWxJF4fuF4kKFW7WrWkGF4rKrg_yoWrAw4rpF W8C3Z5Zr47Ary7ZrW7tas8X39Yy340yry5AF43W3s5JF9Yy3Z3Ar1UXw1DJFWkt3s3t3W7 XFn8JF13uF4Yk3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9F14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka 0xkIwI1lc7I2V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7x kEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E 67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCw CI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E 3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcS sGvfC2KfnxnUUI43ZEXa7VUbXdbUUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Hi, 在 2024/05/14 13:51, Xiao Ni 写道: > On Mon, May 13, 2024 at 9:57 AM Yu Kuai wrote: >> >> From: Yu Kuai >> >> Currently there are lots of flags and the names are confusing, since >> there are two main types of flags, sync thread runnng status and sync >> thread action, rearrange and update comment to improve code readability, >> there are no functional changes. >> >> Signed-off-by: Yu Kuai >> --- >> drivers/md/md.h | 52 ++++++++++++++++++++++++++++++++++++------------- >> 1 file changed, 38 insertions(+), 14 deletions(-) >> >> diff --git a/drivers/md/md.h b/drivers/md/md.h >> index 029dd0491a36..2a1cb7b889e5 100644 >> --- a/drivers/md/md.h >> +++ b/drivers/md/md.h >> @@ -551,22 +551,46 @@ struct mddev { >> }; >> >> enum recovery_flags { >> + /* flags for sync thread running status */ >> + >> + /* >> + * set when one of sync action is set and new sync thread need to be >> + * registered, or just add/remove spares from conf. >> + */ >> + MD_RECOVERY_NEEDED, >> + /* sync thread is running, or about to be started */ >> + MD_RECOVERY_RUNNING, >> + /* sync thread needs to be aborted for some reason */ >> + MD_RECOVERY_INTR, >> + /* sync thread is done and is waiting to be unregistered */ >> + MD_RECOVERY_DONE, >> + /* running sync thread must abort immediately, and not restart */ >> + MD_RECOVERY_FROZEN, >> + /* waiting for pers->start() to finish */ >> + MD_RECOVERY_WAIT, >> + /* interrupted because io-error */ >> + MD_RECOVERY_ERROR, >> + >> + /* flags determines sync action */ >> + >> + /* if just this flag is set, action is resync. */ >> + MD_RECOVERY_SYNC, >> + /* >> + * paired with MD_RECOVERY_SYNC, if MD_RECOVERY_CHECK is not set, >> + * action is repair, means user requested resync. >> + */ >> + MD_RECOVERY_REQUESTED, >> /* >> - * If neither SYNC or RESHAPE are set, then it is a recovery. >> + * paired with MD_RECOVERY_SYNC and MD_RECOVERY_REQUESTED, action is >> + * check. > > Hi Kuai > > I did a test as follows: > > echo check > /sys/block/md0/md/sync_action > I added some logs in md_do_sync to check these bits. It only prints > MD_RECOVERY_SYNC and MD_RECOVERY_CHECK without MD_RECOVERY_SYNC. So > the comment is not right? There is a typo, I'm not sure what you mean yet. Can you show how you add your logs? I think comment is right. From action_store: if (cmd_match(page, "check")) set_bit(MD_RECOVERY_CHECK, &mddev->recovery); else if (!cmd_match(page, "repair")) return -EINVAL; clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); set_bit(MD_RECOVERY_SYNC, &mddev->recovery); From md_do_sync: if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) { if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) { desc = "data-check"; action = "check"; } else if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { desc = "requested-resync"; action = "repair"; } else desc = "resync"; Thanks, Kuai > > Best Regards > Xiao > >> */ >> - MD_RECOVERY_RUNNING, /* a thread is running, or about to be started */ >> - MD_RECOVERY_SYNC, /* actually doing a resync, not a recovery */ >> - MD_RECOVERY_RECOVER, /* doing recovery, or need to try it. */ >> - MD_RECOVERY_INTR, /* resync needs to be aborted for some reason */ >> - MD_RECOVERY_DONE, /* thread is done and is waiting to be reaped */ >> - MD_RECOVERY_NEEDED, /* we might need to start a resync/recover */ >> - MD_RECOVERY_REQUESTED, /* user-space has requested a sync (used with SYNC) */ >> - MD_RECOVERY_CHECK, /* user-space request for check-only, no repair */ >> - MD_RECOVERY_RESHAPE, /* A reshape is happening */ >> - MD_RECOVERY_FROZEN, /* User request to abort, and not restart, any action */ >> - MD_RECOVERY_ERROR, /* sync-action interrupted because io-error */ >> - MD_RECOVERY_WAIT, /* waiting for pers->start() to finish */ >> - MD_RESYNCING_REMOTE, /* remote node is running resync thread */ >> + MD_RECOVERY_CHECK, >> + /* recovery, or need to try it */ >> + MD_RECOVERY_RECOVER, >> + /* reshape */ >> + MD_RECOVERY_RESHAPE, >> + /* remote node is running resync thread */ >> + MD_RESYNCING_REMOTE, >> }; >> >> enum md_ro_state { >> -- >> 2.39.2 >> > > > . >