Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp946680lqj; Mon, 3 Jun 2024 06:03:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXr6BkVWJEiBIa7roQzadhupXVJVWHGT8UXETTIdueJJjtN4gb/KpQcYLeYw52cgf5fvSgf2UQp+PSKC3NeHX7KDDgd0CGFa22RHqQUHA== X-Google-Smtp-Source: AGHT+IHRLRdzRf2q7K1RRaA5S9GWKg3Qo7WJX0CZZApfxqfXexAPz+nEOVh6MmqIoa1OQ5iMBmNS X-Received: by 2002:ac8:5916:0:b0:43e:3935:ad7f with SMTP id d75a77b69052e-43ff54c96b1mr113938941cf.68.1717419804738; Mon, 03 Jun 2024 06:03:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717419804; cv=pass; d=google.com; s=arc-20160816; b=bBsBLbbW13yQEgC0ZMOGsMRQj9byLz7ih5p7lm1BbQqH+j6vjQwFjtECMShy1AJuQ3 bVJI0PoTHfg9SMNo3viSGIJLcauVi78oSJ2Ky75O4PlI3btHlTmrSO7XmY9A8UNBkUkv 3bMy5szognOKj75xeurO6USrIRhlcT13rwi+QOwHAwO5qT2hGaZUaYFad3FlSqWkFMFJ FNabZ1bVXLWV3mKM9s5GQoM/QknznRCvlMz3q5yJWGwtEC/gNL/fbRqtu2tyvZZCvJCK DlmubgsHb1U/d89jx01QRRMLPw3/AxOg7cWmEMVmAkNULj4QMeUGvmfnLXzEhcUGFUMe 7iaA== 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=qzQ8KTutkc0L1lYWbKJryD6jZkfNuaL172kI04sgRcQ=; fh=1LhuwRtrwnHwkJ8SSfr9g2yPev2+fxl/FqZerKdeGVc=; b=O8rFMp0WFYR+Kjjlw3ohKi+G9ReAc95vp1imk9UhRaSqP6NZJQnqiRmYU9jxj6ptke Kv5ndH7bAidnB/7wu47h8AbwGk1CWHVR6RkItNJArn7Jiq0cQ9vKrR/0A5DngYh1ZjwC QOeQShAn2drVp3qlGbKpmajB/lukjQ6tKn2XJAlnycfIjqTDprYUO8LtHh6eAXJK3IMF dzqjpjh5w/OwEiW9us0UmQjD1V4ChDrDr/6mC2knkj//vzdDyDUuuwhNVWcOUuDvxF5w /tOyUAbZjaDWEw5JvBK2DlzrQmnvkN7oYf2/Oafwvep2MZTjP1hK49jug6VLjuuFVR1+ e9hQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-199157-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199157-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43ff25b6ed2si78783221cf.763.2024.06.03.06.03.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 06:03:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199157-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-199157-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199157-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com 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 2E8D61C23DC2 for ; Mon, 3 Jun 2024 13:01:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 784FF12D1FA; Mon, 3 Jun 2024 13:00:01 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 8AB0B12CD8F; Mon, 3 Jun 2024 12:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717419600; cv=none; b=OQVtz9SAbSiGWpGAyIAfo1MsANhAJTI1/JKuFj0pe5kvWF4iDBa260+me5quXsd8dKoxNm95lzznLzCvW6Gp6q/ajqBYpsTf+3yhfU/hXcCM2w/6QSPyQ0STRzfSd8uHB3GYfDWWGXSut6zFIL3mXywNbWx0bZowBsNxlb+DoDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717419600; c=relaxed/simple; bh=ZnrRWs3Bwqrx78eVopoiKrlxIXxIzL+fgWaWm9uO0kE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jOS+DQ6wA2NbFn6MK8ookmHCo8yskHDvtW3spWhIIBj0+SUdOQZ3Ih1IdgFU9Ro6dI4hwDJ8EEoX0k5F7ZGW9RAxw9yEmgRPXaTd7alcYSUr1l/kz8OzOo11fY2Nx7c19Q6MpiNf3hrd+KTYxZ2lXmE2KNI2/m6yZhBJ969Zc1Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VtDLL2Pn9zcl8Z; Mon, 3 Jun 2024 20:58:34 +0800 (CST) Received: from kwepemm600009.china.huawei.com (unknown [7.193.23.164]) by mail.maildlp.com (Postfix) with ESMTPS id 8C6E3140123; Mon, 3 Jun 2024 20:59:42 +0800 (CST) Received: from huawei.com (10.175.104.67) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 3 Jun 2024 20:58:16 +0800 From: Yu Kuai To: , , , , , , CC: , , , , , , Subject: [PATCH 08/12] md: use new helers in md_do_sync() Date: Mon, 3 Jun 2024 20:58:11 +0800 Message-ID: <20240603125815.2199072-9-yukuai3@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240603125815.2199072-1-yukuai3@huawei.com> References: <20240603125815.2199072-1-yukuai3@huawei.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 Content-Type: text/plain X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600009.china.huawei.com (7.193.23.164) Make code cleaner. and also use the action_name directly in kernel log: - "check" instead of "data-check" - "repair" instead of "requested-resync" Signed-off-by: Yu Kuai --- drivers/md/md.c | 21 +++++---------------- drivers/md/md.h | 2 +- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 3890ae86449a..e44016055b56 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8934,7 +8934,8 @@ void md_do_sync(struct md_thread *thread) sector_t last_check; int skipped = 0; struct md_rdev *rdev; - char *desc, *action = NULL; + enum sync_action action; + const char *desc; struct blk_plug plug; int ret; @@ -8965,21 +8966,9 @@ void md_do_sync(struct md_thread *thread) goto skip; } - 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"; - } else if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery)) - desc = "reshape"; - else - desc = "recovery"; - - mddev->last_sync_action = action ?: desc; + action = md_sync_action(mddev); + desc = md_sync_action_name(action); + mddev->last_sync_action = desc; /* * Before starting a resync we must have set curr_resync to diff --git a/drivers/md/md.h b/drivers/md/md.h index f7afc5a46031..614011651f79 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -432,7 +432,7 @@ struct mddev { * when the sync thread is "frozen" (interrupted) or "idle" (stopped * or finished). It is overwritten when a new sync operation is begun. */ - char *last_sync_action; + const char *last_sync_action; sector_t curr_resync; /* last block scheduled */ /* As resync requests can complete out of order, we cannot easily track * how much resync has been completed. So we occasionally pause until -- 2.39.2