Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp342866lqp; Tue, 11 Jun 2024 06:24:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUxodbAmANtueSEao/2giQwlwaDkvuHwGToXD6HoZZ4lbH5iT0O2CIsn0JpuMrHHBAapNQKFqclyFxnXtpq69q3OmWU8j5cG61+f4iLQQ== X-Google-Smtp-Source: AGHT+IEEiKTCoRUhRCtW2ELPMUBl+Jln4rYQtMDRLkehttfsIX1O4hDLZiK+ZJ98LUbt252t7+bx X-Received: by 2002:a17:906:fb11:b0:a68:c5b0:9890 with SMTP id a640c23a62f3a-a6cd7a80f9dmr829473266b.42.1718112241789; Tue, 11 Jun 2024 06:24:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718112241; cv=pass; d=google.com; s=arc-20160816; b=cdyO0zW3+zthqrfUyZC7vew24+ERCLlBj9Sm9A9i5ZrChy7O5GUVluf+Wk17D7Efzs W0+uY6OgthXzhs0MfMwLcMH9734YX6xPtsuajkVjAIN7GI8zOUOVcByunzPDToytxgTF osyekFB9FBYPzY1koa9b4410fSbhAfxytIeA6LQjaJNI8FxqExgesmZJbQw1Oc0sjuVF 0ECAhYey8Y3xsCv0CvzsUasMzABzy+qonDg0w2LkiQBStMNbfLqVhpdhfo7/I3tXX8Aw 8rAuu8zwlS0PNehnSC6HxD5CBWSdMhh36xOYP6w+3+CqKnVTC2igxHSctR9b401bKzIg uP2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=jdnXBcMZG9V/+kYtFdn0lflmalmeBktEPmkXqiSkI0E=; fh=qYmHH2yscViSqYE1LkQo68/ffbmBKrgoX902AVnPECQ=; b=cAYktwbbGLabnE0dvUyQyWZP8C9XfBEYXhLN+AB7+P8kVQ+r9rgmKOh2runfSNhTJN DsnkuPC0PRq1wyiW9LAxot8urI3/fKUF80odC8c+jDxCYELhErFQazowuDQ/vDrD4toG 2XbQCLv/pJJZ46ZTuq1EhqsCuHGs8T5OYDL1Fss47/zktnUsqiQ66BiJYj9Nxm1kbV7M LkATMD1LdtwAmqGPw43pxYLjK49Xpi/Zz98i6vpYnseOzzRkscccGFk2ifbVGJ3No7qu dhxmxGZ2pAIs4YEfsS4CT86KaZ4oDe+gJdPYTbcUrhkjUYwWNpaYGsEqHOqpS6s/1MLr rCPQ==; 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-209932-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209932-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f1f148b91si199074166b.76.2024.06.11.06.24.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 06:24:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209932-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-209932-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209932-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5B1781F22306 for ; Tue, 11 Jun 2024 13:24:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 556C517D88B; Tue, 11 Jun 2024 13:23:23 +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 EA1CA17C9FA; Tue, 11 Jun 2024 13:23:19 +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=1718112202; cv=none; b=IvgPD25W80j9exS6QYvJUNvMqcZALpc780cLyRDzRnp4LvpCeZy4TbbvIamJmKTL3XlKipYjhLXhqwK7ogjrejnC1sMWqYe5rXliMn2J9heUVO1lmKc0VcOday7r3WTrVigt01CbsiCvNkygrZLG78u//YdRDgOyghlPoh2c7cQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718112202; c=relaxed/simple; bh=Y71BHiOOnVRfHmnzmD7aEmu6FN/FsBGXqLMcD8ZaSUA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jjAcUIxeQMQGuNEUUUSAUY6zEOTXZbQegKNRE0In9XH9cdvVPwRRZ9nVKPtZ3e33j+T4SxzQz6/8mL1ASLWg1bp/41IIltvmXbrdq8u/LJ04HlccWn28MIwMvMIQ0eQQbvfld/kb48x2BHK6mwNldWaHKLiL3yhLbNCSc08SoV0= 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 4Vz8W22hR0z4f3jHh; Tue, 11 Jun 2024 21:23:10 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id DFBC31A0C0E; Tue, 11 Jun 2024 21:23:16 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDHlxDBT2hmsVPEPA--.1557S6; Tue, 11 Jun 2024 21:23:16 +0800 (CST) From: Yu Kuai To: agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, xni@redhat.com, mariusz.tkaczyk@linux.intel.com Cc: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH v2 md-6.11 02/12] md: add a new enum type sync_action Date: Tue, 11 Jun 2024 21:22:41 +0800 Message-Id: <20240611132251.1967786-3-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240611132251.1967786-1-yukuai1@huaweicloud.com> References: <20240611132251.1967786-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgDHlxDBT2hmsVPEPA--.1557S6 X-Coremail-Antispam: 1UD129KBjvJXoWxAryUJr13WrW8XFyDAF47Arb_yoW5Xw4rpF s7Cas5Jr1DAF4xA39ava47J393Za10q3y3JrW3WryrAa4Yyas7AFnxJ347AayDKr15Ka4U uFZ0k3Z8uFWkZ3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBK14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04 v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_ Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x 0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8 JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIx AIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbdOz7UUUUU= = X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai In order to make code related to sync_thread cleaner in following patches, also add detail comment about each sync action. And also prepare to remove the related recovery_flags in the fulture. Signed-off-by: Yu Kuai --- drivers/md/md.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/drivers/md/md.h b/drivers/md/md.h index 1ee129c6f98f..e5001d39c82d 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -34,6 +34,61 @@ */ #define MD_FAILFAST (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT) +/* Status of sync thread. */ +enum sync_action { + /* + * Represent by MD_RECOVERY_SYNC, start when: + * 1) after assemble, sync data from first rdev to other copies, this + * must be done first before other sync actions and will only execute + * once; + * 2) resize the array(notice that this is not reshape), sync data for + * the new range; + */ + ACTION_RESYNC, + /* + * Represent by MD_RECOVERY_RECOVER, start when: + * 1) for new replacement, sync data based on the replace rdev or + * available copies from other rdev; + * 2) for new member disk while the array is degraded, sync data from + * other rdev; + * 3) reassemble after power failure or re-add a hot removed rdev, sync + * data from first rdev to other copies based on bitmap; + */ + ACTION_RECOVER, + /* + * Represent by MD_RECOVERY_SYNC | MD_RECOVERY_REQUESTED | + * MD_RECOVERY_CHECK, start when user echo "check" to sysfs api + * sync_action, used to check if data copies from differenct rdev are + * the same. The number of mismatch sectors will be exported to user + * by sysfs api mismatch_cnt; + */ + ACTION_CHECK, + /* + * Represent by MD_RECOVERY_SYNC | MD_RECOVERY_REQUESTED, start when + * user echo "repair" to sysfs api sync_action, usually paired with + * ACTION_CHECK, used to force syncing data once user found that there + * are inconsistent data, + */ + ACTION_REPAIR, + /* + * Represent by MD_RECOVERY_RESHAPE, start when new member disk is added + * to the conf, notice that this is different from spares or + * replacement; + */ + ACTION_RESHAPE, + /* + * Represent by MD_RECOVERY_FROZEN, can be set by sysfs api sync_action + * or internal usage like setting the array read-only, will forbid above + * actions. + */ + ACTION_FROZEN, + /* + * All above actions don't match. + */ + ACTION_IDLE, + NR_SYNC_ACTIONS, +}; + /* * The struct embedded in rdev is used to serialize IO. */ @@ -571,7 +626,7 @@ enum recovery_flags { /* interrupted because io-error */ MD_RECOVERY_ERROR, - /* flags determines sync action */ + /* flags determines sync action, see details in enum sync_action */ /* if just this flag is set, action is resync. */ MD_RECOVERY_SYNC, -- 2.39.2