From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A563F24C08D; Tue, 29 Apr 2025 17:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745947422; cv=none; b=STHzjP8OwrXdpNO0ROcAo2c1xAW8+v/FVQzlN05xm7MbJnvhIXH+JYZHx0WOnUEnoIGDYP7t1AGn9zSiGV0EXKKu6Ubc3HLe88fHPtBI1WR8zHw0vPTKUL02dKC3L1HL9z9eOxCL6tqjZNMaNi/BMYLy/sQvQYTIEyFveaZwPf0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745947422; c=relaxed/simple; bh=VoigsAe7tcpzVyOQ7rxWbgAfq/oIALGo9/imFusVKbw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G8p40VPCnhE0ps74gOVYrMQIHRUK6DwCAfFi+KU2oWg8HgVgmPxlAz2KjABZ46H5XpJJJgzfLbT2OnaAFE9gnN+kjEqRlN3/8K6f/dg9ArHfn5AUDspylgck1C1F8cSifza/bmPT67ordpNHzrkvGqM86BqXPlXWya32D/+wXOY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Tu3UZX+r; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Tu3UZX+r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1515FC4CEE3; Tue, 29 Apr 2025 17:23:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745947422; bh=VoigsAe7tcpzVyOQ7rxWbgAfq/oIALGo9/imFusVKbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tu3UZX+rlbnmGlsFhY9B1pyQ66sDr3KXAG3ps24qG6Ggan3um5jD+VZq0Js9WTLZU Mj8ePtAm2HA9tX6rDHqLdWSimbS8jHStgxeGVu5BWOj/ymGrTmR6EtzfnGR+Ft2r/R MW2XNW0aIrBJqsHWMlb2gX+B2bg5iU0TPQeziQmg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Meir Elisha , Yu Kuai , Sasha Levin Subject: [PATCH 5.10 276/286] md/raid1: Add check for missing source disk in process_checks() Date: Tue, 29 Apr 2025 18:43:00 +0200 Message-ID: <20250429161119.269227446@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161107.848008295@linuxfoundation.org> References: <20250429161107.848008295@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Meir Elisha [ Upstream commit b7c178d9e57c8fd4238ff77263b877f6f16182ba ] During recovery/check operations, the process_checks function loops through available disks to find a 'primary' source with successfully read data. If no suitable source disk is found after checking all possibilities, the 'primary' index will reach conf->raid_disks * 2. Add an explicit check for this condition after the loop. If no source disk was found, print an error message and return early to prevent further processing without a valid primary source. Link: https://lore.kernel.org/linux-raid/20250408143808.1026534-1-meir.elisha@volumez.com Signed-off-by: Meir Elisha Suggested-and-reviewed-by: Yu Kuai Signed-off-by: Yu Kuai Signed-off-by: Sasha Levin --- drivers/md/raid1.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 3619db7e382a0..dada9b2258a61 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2034,14 +2034,9 @@ static int fix_sync_read_error(struct r1bio *r1_bio) if (!rdev_set_badblocks(rdev, sect, s, 0)) abort = 1; } - if (abort) { - conf->recovery_disabled = - mddev->recovery_disabled; - set_bit(MD_RECOVERY_INTR, &mddev->recovery); - md_done_sync(mddev, r1_bio->sectors, 0); - put_buf(r1_bio); + if (abort) return 0; - } + /* Try next page */ sectors -= s; sect += s; @@ -2181,10 +2176,21 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio) int disks = conf->raid_disks * 2; struct bio *wbio; - if (!test_bit(R1BIO_Uptodate, &r1_bio->state)) - /* ouch - failed to read all of that. */ - if (!fix_sync_read_error(r1_bio)) + if (!test_bit(R1BIO_Uptodate, &r1_bio->state)) { + /* + * ouch - failed to read all of that. + * No need to fix read error for check/repair + * because all member disks are read. + */ + if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery) || + !fix_sync_read_error(r1_bio)) { + conf->recovery_disabled = mddev->recovery_disabled; + set_bit(MD_RECOVERY_INTR, &mddev->recovery); + md_done_sync(mddev, r1_bio->sectors, 0); + put_buf(r1_bio); return; + } + } if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) process_checks(r1_bio); -- 2.39.5