Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp192161rdb; Thu, 22 Feb 2024 00:04:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWK7NIhWsc6idfwvKnneiEIFkLmG2CAIF2D2r/DYJnwziuWETKBXAOfYlWKW/u1K5i2pXS3XZrYcVuk6OVnKqfB/kSkJ6CqTL1UdQjztg== X-Google-Smtp-Source: AGHT+IHku3pzcOO5YONlvbJbrQObnoPn+FaCu7yerIptKAI5JTZZSPOzy2lcO4EEgDaH4N44ROUq X-Received: by 2002:a05:6512:48c1:b0:512:b00f:a566 with SMTP id er1-20020a05651248c100b00512b00fa566mr8021202lfb.29.1708589094682; Thu, 22 Feb 2024 00:04:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708589094; cv=pass; d=google.com; s=arc-20160816; b=OxaNc+jjToDHQAIN7y6wKq9sAZLgXBaCa8OiWvlew18B6b2Tia2smNp11Ms8L5HnPP 3C+keTGWIa4mhj5xghrQCm1Sb4rE3xTPPSXOraWoohkziOp8u3z6wbIP5ojURF2qdY0b L5DlM55vGEegMbgEixYMq2HmD7qwpN9VhmDV2F+CW/PaaIxgy67cd4fUdfL44jDLX9DS YUXy7DqQVd56GsB0PyiUPr5cBV7+lLvvbJgjIRkEa4Ta39FJ6Lg3x/Uh3p5WcMJdgher w1Efr38mfijxwfubez3n2pTo7FWDCGpjU7YRjRxj0pYWbBNPZxARJZHn7nTsTylrbtzF LRgg== 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:message-id:date:subject:cc:to :from; bh=U64p6vNRMg8PztUZCfWW8rpfDtm4s42lOoVO6i3xDCE=; fh=5pFDn0/OhEinqiskZflJb/MnGts2EKkuL30fOGsymHI=; b=P2H4eTTnz8caDPsDwWp0ymIadF3/JE5UYkPOW5ZbYQgrEdvBb7bPhF6s0iIgaid69A Rver03dFrV4bmfr/kVsmbKmA9MkgcEyHOkp6b17J8Pv8aC7F1FeX7b34n216BHUxGwHL NNY1BJROpEX0ilMt7rBwqiOSrdo6MSuMFehQZmKbgqoBclkya+8+5AFkDDBF5MB8B+iQ ePvFIEBD9KJA63Nb0b3ycOVibKr9uXu32Vk79HP2VHX6I9AzQKoNj1xXeCG7tJgwNgnN pQ2KqFSYVMCR/0Jfmv+cVWroM1sZBXfKGbF0n1owY4kROm+U3gkc8F93hu+untA/XbJf hXKQ==; 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-76050-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76050-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gt31-20020a1709072d9f00b00a3f7d24f4ccsi426106ejc.521.2024.02.22.00.04.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 00:04:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76050-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-76050-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76050-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 6C0D41F2271E for ; Thu, 22 Feb 2024 08:04:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1889E1BC44; Thu, 22 Feb 2024 08:03:58 +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 7423017BB6; Thu, 22 Feb 2024 08:03:55 +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=1708589037; cv=none; b=TfbTFTR8mRkF7W677+uX0SzUBVeXwDaKskeRSTi8D6AS7hRPfTh5va0DQLaueEKZ1spw0r2cvAxu3kPofD/NaKtaQsSN8ihV/2hyzrxQtWXzVni96vTBwDgbszU1j2ei9KURcwRqV0hnUbn1GLeo/SWws9k0zJNnln1Fk6kVU7o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708589037; c=relaxed/simple; bh=Z0n7pAD254UYraghApQ4/8UxVK58E9XO9dLVWzyEbwg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=m1TVIboKt1IWxZ4NRdMY4PHQiJAOlylC+IfeslCLkIQUMbCTGgUQdwOuAhe3WAZAKFS5PM4UIFBWxBunjn3ceHThWsVM4q6AWbrKvYk59wvovqCNLm6OT5oTWovLmbrV33/O4WKhtcz9QoJYTfMzRUdVXVlkLeJz/Di3jv5RUXo= 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.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TgQdB3CcQz4f3kq8; Thu, 22 Feb 2024 16:03:42 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id A1FA51A0176; Thu, 22 Feb 2024 16:03:45 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBHc_9ZlnaUhEw--.37287S4; Thu, 22 Feb 2024 16:03:42 +0800 (CST) From: Yu Kuai To: paul.e.luse@linux.intel.com, song@kernel.org, neilb@suse.com, shli@fb.com Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH md-6.9 00/10] md/raid1: refactor read_balance() and some minor fix Date: Thu, 22 Feb 2024 15:57:56 +0800 Message-Id: <20240222075806.1816400-1-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 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:cCh0CgBXKBHc_9ZlnaUhEw--.37287S4 X-Coremail-Antispam: 1UD129KBjvJXoW7Wry3ZFyxJF17WF1kJw17GFg_yoW8tr1Up3 yavFy3Zwn8ZrW3AFn3Zw48G343twn3JFWxJas7Jw4F9r1avFWUA397JrW8CFWDCFy5trn7 Xr17GrZ7uF1FyFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUv014x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2 Y2ka0xkIwI1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4 xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43 MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I 0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v2 6r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUb XdbUUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai The orignial idea is that Paul want to optimize raid1 read performance([1]), however, we think that the orignial code for read_balance() is quite complex, and we don't want to add more complexity. Hence we decide to refactor read_balance() first, to make code cleaner and easier for follow up. Before this patchset, read_balance() has many local variables and many braches, it want to consider all the scenarios in one iteration. The idea of this patch is to devide them into 4 different steps: 1) If resync is in progress, find the first usable disk, patch 5; Otherwise: 2) Loop through all disks and skipping slow disks and disks with bad blocks, choose the best disk, patch 10. If no disk is found: 3) Look for disks with bad blocks and choose the one with most number of sectors, patch 8. If no disk is found: 4) Choose first found slow disk with no bad blocks, or slow disk with most number of sectors, patch 7. Note that step 3) and step 4) are super code path, and performance should not be considered. And after this patchset, we'll continue to optimize read_balance for step 2), specifically how to choose the best rdev to read. [1] https://lore.kernel.org/all/20240102125115.129261-1-paul.e.luse@linux.intel.com/ Yu Kuai (10): md: add a new helper rdev_has_badblock() md: record nonrot rdevs while adding/removing rdevs to conf md/raid1: fix choose next idle in read_balance() md/raid1-10: add a helper raid1_check_read_range() md/raid1-10: factor out a new helper raid1_should_read_first() md/raid1: factor out read_first_rdev() from read_balance() md/raid1: factor out choose_slow_rdev() from read_balance() md/raid1: factor out choose_bb_rdev() from read_balance() md/raid1: factor out the code to manage sequential IO md/raid1: factor out helpers to choose the best rdev from read_balance() drivers/md/md.c | 28 ++- drivers/md/md.h | 12 ++ drivers/md/raid1-10.c | 69 +++++++ drivers/md/raid1.c | 454 ++++++++++++++++++++++++------------------ drivers/md/raid10.c | 66 ++---- drivers/md/raid5.c | 35 ++-- 6 files changed, 402 insertions(+), 262 deletions(-) -- 2.39.2