Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp349628lqp; Tue, 11 Jun 2024 06:33:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqgsb3z9tKko66CBP/MZjFljkDsjXHLmDocESm6YPwjOpy9YcvhFRmrGoKjxWbS6F0ND+doAOb1D/hZYHr6kwSng4KJeS/PNgDKAJxsQ== X-Google-Smtp-Source: AGHT+IEmJH1eRHVcm6sRQJKLPDyNX69If714pXhkuWAb0J8C4s3sNB9PFMbUtBeGziM5azApLftA X-Received: by 2002:a17:903:22c7:b0:1f4:5c81:ba97 with SMTP id d9443c01a7336-1f6d02c0681mr142343825ad.9.1718112831475; Tue, 11 Jun 2024 06:33:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718112831; cv=pass; d=google.com; s=arc-20160816; b=n1VckWqQTzc3l+SHchQQxF8rSCMcs4KHmOQlebavobAsJoN2MIIWItg7Rmlrf2WmOr sqko6FIFNkiuWqT2nLBU7PcJpAIEgt4XBL671ckg7IbwGZr0FHLcTTGZYGHTqClXb9aH Y+EY/LbcCQ0npzFW8pKuaPLtzgUbo8Yz+t6am9Qp+V4O+mH0DulQ9eEWT3x8Ab42cQYo wc4D4yLXruchIyF8Rv0mm2ygxqB+iq4WSD4hqZf7gi36AEfziyJ++ZGE9khrImJGsnl9 fqWglZcHm2ljvpniofdC4iSlusyk0EktPDQQtWtls+uU8JhBbaZf96Nl415sLpxz5WpW HpLQ== 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=suklqP8zNmbtR2JcbiKeV7leHj3SK9uPZDUCwlWQGug=; fh=5CvOjWMpU7g0bv0AN7OuJ4aUxjdf2f33Q5i6Tq91Ftk=; b=y9Im7oTheNyTDn5fZ/RU7DS4YiT/LcV5KwgVHsHXt17MCfKQ/DxOOOfx3r0YGz05R8 /SsoIVNNEd3SxB5VhfoR1Ip8EY6P9ULAEojeNjk6WFBpa3PY0kyqnSlhs/ypon1tgM+H 2oIdaLQPjv8Rzc8mh4UfwSz832BbAs5j4mirnLO9/DIdd67HGaaksgC/0fRArtq8cceG qFhAIP+HuS+/jwueydTAA9rD7mfKqI6aRMNBxYlBr5uTNv2jCIBXTjuYQ+e75E6O/o5K CxlgYJXgUta9Bltx0l/wcK9oQeGejjDRWXWDac324v+HXOxdLgZC+D1R/2z82Cva/bil Jdeg==; 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-209956-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209956-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd7e4300si62569105ad.367.2024.06.11.06.33.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 06:33:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209956-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-209956-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209956-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A727A286F52 for ; Tue, 11 Jun 2024 13:30:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08CB917D341; Tue, 11 Jun 2024 13:30:18 +0000 (UTC) Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (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 D8326172BDB; Tue, 11 Jun 2024 13:30:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718112617; cv=none; b=R9QqbZPc9oKKuj1/S8M5xUD7lqoiG0BOsUXlj7E8zN9v2NfLqW8V7WmdGEYdeKXCycgn87GNlBt6XFU4iN7HzF0yYdgVZWoK5/0wL1nfl2FqNFeJ23H2MmmJA1qGHvlT4fUlgpxQNZIvVG/jKMwvm6bFsrMj6+/9CoPIKBbUlhU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718112617; c=relaxed/simple; bh=H20fbMfgohGyo4yey5vALGzeXJ8MBMbZ1q9Hn9FTCfw=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=iW1+uyskNIdhnz3/AD25R+MOj2pTRIZAhZ/ZcLYow5kuAdPrDOxM7jxA91oidtNFN65RhVnqYHyqfPsLwlnz0oHimB4QsHRvI9SiOROfAlJ2AyiQrRx1KWPr42Wyfz4UMmoVlXhrAPqq+f4Y81aE6WIs3YOuTOUWDwcnBT+0yXg= 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.56 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.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Vz8fy3FFpz4f3jsW; Tue, 11 Jun 2024 21:30:02 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 6E5ED1A0181; Tue, 11 Jun 2024 21:30:12 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgAn9g5iUWhmdMbEPA--.26115S3; Tue, 11 Jun 2024 21:30:12 +0800 (CST) Subject: Re: [PATCH 02/12] md: add a new enum type sync_action To: Mariusz Tkaczyk Cc: agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, xni@redhat.com, l@damenly.org, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com, "yukuai (C)" References: <20240603125815.2199072-1-yukuai3@huawei.com> <20240603125815.2199072-3-yukuai3@huawei.com> <20240611103126.00003ee0@linux.intel.com> From: Yu Kuai Message-ID: <4e8fcdc7-3494-df1d-8654-28ce248850df@huaweicloud.com> Date: Tue, 11 Jun 2024 21:30:10 +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: <20240611103126.00003ee0@linux.intel.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgAn9g5iUWhmdMbEPA--.26115S3 X-Coremail-Antispam: 1UD129KBjvJXoWxAF43XFWkuFW7Xr48KFWxZwb_yoW5CFWfpF W8Ga4rJr4DArn7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usz Tkaczyk ะด??: > On Mon, 3 Jun 2024 20:58:05 +0800 > Yu Kuai wrote: > >> 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 170412a65b63..6b9d9246f260 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, >> +}; > > I like if counter is keep in same style as rest enum values, like ACTION_COUNT. Thanks for the review, however, I didn't find this style "xxx_COUNT" in md code, AFAIK, "NR_xxx" style is used more, for example: enum stat_group { STAT_READ, STAT_WRITE, STAT_DISCARD, STAT_FLUSH, NR_STAT_GROUPS }; Just to let you know, I'll keep this style in the next version. :) Thanks, Kuai > > Anyway LGTM. > > Mariusz > . >