Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=64.215.233.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796406390; b=WKso47HvP4Zpr71pvXCMtowx8eZCkkOmmOI/iJbuuIOihu3TEW6v1DqnLCgiOit8G2+x pCwopLEX4eIm1F7bb/Uaz+jSQiEsqsnSYfrDOTFZMAOCqpBcRnEtXOqveZkpWQVp9eFbx jIoIrlwueFQxwAgEhqfGVpGNd+SidisFxTlCNtLhnV4n08wd5L0/Q8yRcDe+wmYSMMV3P AN334m9OZmuBtSChvTel0f1nNYL4ym5Ql9GJyig58o6joY+P3ABvhGPq0d39GKYZ8W3hW E1nR1PPVKIuf2ox1NuanYbFWgWcNrdZKtm+QWqHsNcYofOlCezJFsKHkjsOErvlD0rQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796406390; h=DMARC-Filter:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=as+VssU3VKaE/QcRGjt1/vTRN1SyvSefLJ7VeCIkduY=; b=fDIHGp0HUx91JIkojQ7d+PBoVnrFk+6AUSiVokHnZOeIzI0kwdGvLLtj20up5PVDCLJF xP4Ipof7fWflBeODp293SK3KyJT9eML37ZPN3LGSjOrDIaIMBY07jCqUPMP7mWveE9cgt c8c4WbYs7aoTXIdcS5oE+SJ1IGRwhwxjl1rQIDw0OrVFdiNyLXnV6g8+4fPX2ocDbjoSw P7pE9kcQR29n8Ii/DTKfd42CZkbLWdIdyv0KzydCcJQjsMXyLx6pbbe8re8FVyyoKij7P 4nJ4OYplsjVyl4ziZq3ePEMUoUvUaRzhtuEvyHgLPhJitgoBJb84wXME8PDOhOJiYvg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=janestreet.com; spf=pass smtp.mailfrom=janestreet.com; dkim=pass header.d=janestreet.com header.i=@janestreet.com header.a=rsa-sha256 header.s=waixah header.b="yy2Cmc/X"; arc=none smtp.remote-ip=64.215.233.18 Received: from mxout5.mail.janestreet.com (mxout5.mail.janestreet.com [64.215.233.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28095606A32D for ; Fri, 4 Dec 2026 17:46:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 28095606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=janestreet.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=janestreet.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=janestreet.com header.i=@janestreet.com header.a=rsa-sha256 header.s=waixah header.b=yy2Cmc/X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1796406382; bh=as+VssU3VKaE/QcRGjt1/vTRN1SyvSefLJ7VeCIkduY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yy2Cmc/XHeepXU7lmP0W7E3e19yEOIyNe+4TENlP8cjW31mzVp/5VBF1n/0JTE16T K3mIqtDU/cau5tn2dfsMRdg/SNTWPoVuVrNzDOSinqlWjJASgTvTREGdxgLCGXVXBZ JTlfnDZqNm28MfM3uMVIA4BTaf9dBgArcx+ZMTHRwY03+hi1gOU4JbeJlBr0kVrIog QUBkxca9TexCGi8mTVQ7KdFbX2IOZZzlb7clrzRgBaysSkHCD78F5oDnYofPfKXhto cgjq7FFRJJc7BCu6Abs3DNj2PUE0HdCpk7ixAl1swraOiHcFQbakIOvJg6ngFhnCig Kx4Mw0ENzDZkQ== From: Eric Hagberg To: Song Liu , Yu Kuai Cc: Jason Chu , Li Nan , Xiao Ni , linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Hagberg Subject: [PATCH RESEND 1/3] md/raid10: do not skip past the range that sync_request examined Date: Fri, 4 Dec 2026 12:46:18 -0500 Message-ID: <20261204174621.3475573-2-ehagberg@janestreet.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20261204174621.3475573-1-ehagberg@janestreet.com> References: <20261130193139.1401044-1-ehagberg@janestreet.com> <20261204174621.3475573-1-ehagberg@janestreet.com> X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jason Chu When a range needs no I/O, raid10_sync_request() returns the number of sectors that md may skip. Before it looks at a range it lowers max_sector to resync_max and, if near_copies < raid_disks, to the end of the current chunk, because the mapping between member sectors and array sectors changes at every chunk boundary. The bitmap and the bad block lists are then consulted for that range only. Since commit 7435b73f05fb ("md/raid10: cleanup skip handling in raid10_sync_request") the two "nothing to do here" paths return max_sync. max_sync is limited by what the bitmap says about the array sector that sector_nr maps to, and by bad blocks, but not by max_sector. It can be as large as RESYNC_BLOCK_SIZE, which is 64KiB. During recovery of an array with near_copies < raid_disks and a chunk size below 64KiB, one clean chunk therefore makes md advance over the following chunks of the same member. Those chunks hold other array sectors, and the bitmap is never asked about them. If they are dirty their copies are not rebuilt, the member is still marked In_sync, and reads from it return old data. Before that commit the giveup path limited the skip to the examined range: if (sector_nr + max_sync < max_sector) max_sector = sector_nr + max_sync; sectors_skipped += (max_sector - sector_nr); Reproduced on v7.4-rc5 in a KVM guest with the "recovery-small-chunk" test of the script in the cover letter: 3 members, near=2, 4KiB chunks, 64KiB bitmap chunks; member 1 is removed, eight 64KiB regions are written, and member 1 is re-added. Recovery is not interrupted. before: verdict=FAIL stale_regions_read_without_member0=8/8 mismatch_cnt=320 after: verdict=PASS stale_regions_read_without_member0=0/8 mismatch_cnt=0 The same test passes on 6.12.117, which does not have 7435b73f05fb. Return the smaller of max_sync and the examined range from the recovery path. Do the same in the resync path that is taken when fewer than two copies are readable: its bad block lookups are for the member addresses of the current chunk, and it must not pass resync_max either. The resync path was changed by reading the code; the reproducer covers the recovery path only. Two other returns are not changed. The clean-bitmap return in the resync path ("We can skip this block") can still move the cursor past resync_max, without doing I/O there. The return after a failed bio_add_page() still returns max_sync. Fixes: 7435b73f05fb ("md/raid10: cleanup skip handling in raid10_sync_request") Cc: stable@vger.kernel.org Signed-off-by: Jason Chu Signed-off-by: Eric Hagberg --- drivers/md/raid10.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 066c431..3ef0143 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3457,8 +3457,14 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, rb2->master_bio = NULL; put_buf(rb2); } + /* + * Only this range was examined: it ends at + * resync_max and at the chunk boundary where the + * mapping changes. + */ *skipped = 1; - return max_sync; + return min_t(sector_t, max_sync, + max_sector - sector_nr); } } else { /* resync. Schedule a read for every block at this virt offset */ @@ -3575,7 +3581,8 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, } put_buf(r10_bio); *skipped = 1; - return max_sync; + return min_t(sector_t, max_sync, + max_sector - sector_nr); } } -- 2.43.7