Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2496699rbb; Wed, 28 Feb 2024 03:56:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV6tRJJ6oKuKUkSKQ4TWRuyb0Fs2CBqyYNTZ5nHvf2jpsVRH2VcidgWsbGPjtQBFKFzz+m1xkg9QJIWKP9OwwtiaTjhPHgHqFoBtJV7sA== X-Google-Smtp-Source: AGHT+IGX8IC/b8l7qBiU0/cA8NfCmMjiHwKv+8HAMptz/00SuRFcDu08flp8zUDG4BHH2fj6ehC+ X-Received: by 2002:a05:620a:14a5:b0:783:2a45:8329 with SMTP id x5-20020a05620a14a500b007832a458329mr4871068qkj.76.1709121362281; Wed, 28 Feb 2024 03:56:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709121362; cv=pass; d=google.com; s=arc-20160816; b=OtiDbC8c17ch3GmHAedJ6gp5cJBCirdm/O7G2S6h62f6Pa1DaWKqUJzsbjq9lxKv6S R4zeJg9lCP2JqX0+Bi73oyyLyeOuLx+OFG3j8Ipi/E4khyZnIYROF2uiCpVHuIf9YG35 1b4uSCRsx5PZNA3HAut6vXtGDzrRXUJWGPuC2W4eJSxIzQGAxOn0uvt2WGCPu39EZ37H 2N85kZe06TmqHJY/2U61ZQGZ8trQYFSlukWOL9eFrhA8PC8XtkJihx/2r202tBOxVIrc fCK2RE89QkVWFheP4N51mu8u70DwqYwzQlACdW7poQbLthup1ksO8LcVMVTonrXv32qZ GUsg== 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=h/zjLAreQSC3lmWxkYuavAxaGDZErt6v1OApuCPebxU=; fh=Ytj0OQL2yyVgRSgKlJizbwNzVtV64xy+1TGtb7SiHpY=; b=G5TTWETX8Wl5/OMqp+1Q1/5TeM6qkEzxvFjFTVykR+RsLfH4alkpMqRHB69pQ/bTci qP0gn/AWS8a9lm2zKeQI0nEOKnoMwdVNY6UuA/UEP84N51SkD2H4BCPS99mboAveb7WH +R9Oe20Aco2YqAkKvgZBKLF4A5Z+5Czq//OCnEle1ykr2AOja2QjLHQnzHLaXk9HyYZr gE8F0+C3NFJVuCCkeY1FRr1vZRQeZAluAni9s3LCvZGE4wJdsArGvE8X4oTfTb5FEQJq K5Cbeb3IPgemXlGHEQmqk6FtsB/qkGyZzkbpu1Kc8Suiqa+mx8rpiiQ8kRRxT4vYxl9+ J/7A==; 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-84970-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84970-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 wm15-20020a05620a580f00b00787b8f702besi9457134qkn.56.2024.02.28.03.56.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 03:56:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84970-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-84970-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84970-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 F3D421C20F56 for ; Wed, 28 Feb 2024 11:56:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6369515A4B1; Wed, 28 Feb 2024 11:49:44 +0000 (UTC) Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [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 C6B1F70CC6; Wed, 28 Feb 2024 11:49:40 +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=1709120983; cv=none; b=adw8I0wFC3jC8Hdbl65KbCvfq17klaRjUh6Nj1AuB4PLNXhsuCqCqYkeOCLWLhFFei9Exixwp/1WyXecXuCweHgUzanfjBLcEbbdi2XXaiy5F9XgJGm2l6+T7QLj8GVGmvV7Kx6Yn/VPvfZ/ix25Z9wqT3B/FCLI7Ihssn6kKaQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709120983; c=relaxed/simple; bh=l2G/1qEl98q1TYO9oqz/qk+59OES667Qv9XxJOAY2EE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=TEltry2n/OjLcQnTKn2zyfJHGS1rhT3UISBcy/L8IWDHxpEe7ro4lBHipt2nvtSFUuS1ONKyFh9tLxRYDgsvMHjrdx862cZeAJ9P/nEbR20ciShbaHXJPfR22iyqh07cIlqsKMdizsZ4LW4ICwcIpNE1EX7hTMqML/n933ciLgA= 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.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4TlCLt3lRhz4f3jd7; Wed, 28 Feb 2024 19:49:26 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id BD5B61A01B9; Wed, 28 Feb 2024 19:49:31 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAn9g7IHd9l+eamFQ--.6969S4; Wed, 28 Feb 2024 19:49:30 +0800 (CST) From: Yu Kuai To: xni@redhat.com, paul.e.luse@linux.intel.com, song@kernel.org, shli@fb.com, neilb@suse.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 v3 00/11] md/raid1: refactor read_balance() and some minor fix Date: Wed, 28 Feb 2024 19:43:22 +0800 Message-Id: <20240228114333.527222-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:cCh0CgAn9g7IHd9l+eamFQ--.6969S4 X-Coremail-Antispam: 1UD129KBjvJXoWxXr1xCFW7tr4rurWxZw15CFg_yoW5Jw4xp3 yavFyfXw4DZrW3AFn7Za18G34fJwn3JFWxJFn7tw4F9r1avrWUt3yfJrW8CFWDCry3trnr Wr43GrZ7uF1vyFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvj14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrV AFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCI c40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267 AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWU JVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUoO J5UUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai Changes in v3: - add patch 2, and fix that setup_conf() is missing in patch3; - add some review tag from Xiao Ni(other than patch 2,3); Changes in v2: - add new conter in conf for patch 2; - fix the case choose next idle while there is no other idle disk in patch 3; - add some review tag from Xiao Ni for patch 1, 4-8 The original idea is that Paul want to optimize raid1 read performance([1]), however, we think that the original 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 branches, it want to consider all the scenarios in one iteration. The idea of this patch is to divide 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 (11): md: add a new helper rdev_has_badblock() md/raid1: factor out helpers to add rdev to conf md/raid1: 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.h | 11 + drivers/md/raid1-10.c | 69 ++++++ drivers/md/raid1.c | 539 +++++++++++++++++++++++++----------------- drivers/md/raid1.h | 1 + drivers/md/raid10.c | 58 ++--- drivers/md/raid5.c | 35 +-- 6 files changed, 437 insertions(+), 276 deletions(-) -- 2.39.2