Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796408193; b=bVBgpEsAlgVUkQ6CGsJ8iSrJasLfFoxHaTlFCpUkQK4JBk4arwn5FJ2wdWEdBF6Tbimn 2qQepN0cviNBS7YEz3S9yFYMu2EaFYJJ0xfKU77XNQzr3LHsIwAKwzj3jmz4ovNDjwcdC c5rHma9HRrli8Dh0qYZaB+QbwzUFENK4TivN97rvvo2ej63r/XDREhL5lCsaRsVTghdpi 9nm6tfPJQjiEpmoITA43IRxNd57aXg05t0TloS5XZtnUq2aLk9o4L4uYLjLOP+PqkXj4U ETjcL6v8WP92QPS6EgZbcq9LgBqt7ORQValYFFdxKi4+kwbWu3j/CL89vMsWWxyEp+Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796408193; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=+DLsAJ30PDOe0250fY/thuXVhEm0LkRwTsYQpgB9uvU=; b=kjybnCZfSmGAL4U6V1p7xTiJTR5VEz+FGEup8SE0TJfy2NOgWjiCN7ELE1vHJrTqiBw8 l29gCgtO+mcYrLqbwPpbfKBb3nfMQqPESdbb/BiZdPizXZW6uZGeOasogADmlc5zz8s6y SbIBGb2vXiJnf3CecVO3ZkT5sHyg+PLMCxnbozkxEmqYgWptTyr7OLZcQ3tVad2PU+fQG u6N63EThIGmB5L+vwE0R1hs76ZMfFumrqvcoYDA+gjbE4+ixZd5lUT2iBM513JZIC2h+c ZZLm9zF9O2cMILzX0d5MzNta6bP+PZSR/0IhZ+/pba/XXf1ShsPhwApvzmpURoaeiEA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UIIMbIkb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35896606A338 for ; Fri, 4 Dec 2026 18:16:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UIIMbIkb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BEF71F00A1E; Fri, 4 Dec 2026 18:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796408192; bh=+DLsAJ30PDOe0250fY/thuXVhEm0LkRwTsYQpgB9uvU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=UIIMbIkbiqReCSKuKaifZ5VO/LAUGlNV1JWdkRwqw1xQHbGgXzsyCSfrDiPOZTKvY KJE/xbBQDaloHVp3lneRu14xLK+KvHMjiEl2GhC/IUA2Fz8aq1YUIto/2P5cWHxo/g l6ZQKUlDhXgizKCE30bpUrHzm44Jx2Z7iTOTX/IfY5gUIM9nGKE6LXYn+x0h5KroeA GFBaEmi5ArTgvZk2tnuEs78Lh3YleWxnFotMKTT66rhP2IBk3r3kvSw0K1A7ZpMtw2 MVumda/sTyJo6Mr0c6G7lJWV9Uk0asEthQRvdcfaFYJyam0JJHJJ5vVNbv8okg7/Bj FfsUVSlU45poQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH RESEND 2/3] md/raid10: re-arm in-progress bitmap chunks when recovery is interrupted Reply-To: sashiko-reviews@lists.linux.dev To: "Eric Hagberg" Cc: linux-raid@vger.kernel.org, yukuai@fygo.io In-Reply-To: <20261204174621.3475573-3-ehagberg@janestreet.com> References: <20261130193139.1401044-1-ehagberg@janestreet.com> <20261204174621.3475573-1-ehagberg@janestreet.com> <20261204174621.3475573-3-ehagberg@janestreet.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 18:16:32 +0000 X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] md/raid10: raid10_abort_sync_bitmap() permanently leaves NEEDED_MASK set - [Low] md/raid10: raid10_abort_sync_bitmap() couples to md-bitmap internals - [Low] md/raid10: misleading llbitmap abort rationale in raid10_classic_bitmap() -- commit 0d112aed9e653ad59e91dbedbc2614b80f007e0e Author: Jason Chu md/raid10: re-arm in-progress bitmap chunks when recovery is interrupted When a classic-bitmap raid10 recovery is aborted, this commit walks the bitmap from sector 0 and calls end_sync() on every chunk instead of calling bitmap_ops->close_sync(), so in-progress chunks with remaining copies keep NEEDED_MASK set. > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c > index 3ef0143acfd97..e42abe747d81b 100644 > --- a/drivers/md/raid10.c > +++ b/drivers/md/raid10.c > @@ -3071,6 +3071,51 @@ static void raid10_set_cluster_sync_high(struct r1= 0conf *conf) > conf->cluster_sync_high =3D conf->cluster_sync_low + window_size; > } > =20 > +/* > + * llbitmap's end_sync already aborts every syncing chunk from the given > + * offset to the end. The classic bitmap ends one chunk per call. > + */ > +static bool raid10_classic_bitmap(struct mddev *mddev) > +{ > + return mddev->bitmap_id =3D=3D ID_BITMAP && md_bitmap_enabled(mddev, fa= lse); > +} [Severity: Low] Is this rationale (and the matching note in the commit message) accurate for aborted recovery? On aborted recovery, raid10_sync_request() passes virtual offsets from raid10_find_virt(conf, mddev->curr_resync, i) rather than 0, so llbitmap_end_sync() only aborts chunks from those offsets to the end. llbitmap_close_sync() then transitions lower syncing chunks to BitDirty rather than BitNeedSync, so avoiding skipped copies depends on llbitmap's degraded-array BitDirty handling instead. > + > +/* > + * Re-arm the classic bitmap's in-progress chunks from @start to the end= of > + * the array, so that they are synced again. > + * > + * Recovery walks member sectors, but the bitmap tracks array sectors. A > + * chunk that was started for one copy can still cover copies that recov= ery > + * has not reached: on another returning member, or further into the same > + * member for the far layout. An aborted recovery therefore re-arms eve= ry > + * in-progress chunk (@start =3D=3D 0). A chunk whose copies are all do= ne may > + * stay dirty and be copied again, but an unfinished copy is not skipped. > + */ > +static void raid10_abort_sync_bitmap(struct mddev *mddev, sector_t start) > +{ > + /* The bitmap chunk size is a power of two. */ > + sector_t chunk_sectors =3D mddev->bitmap_info.chunksize >> SECTOR_SHIFT; > + sector_t limit =3D mddev->resync_max_sectors; > + sector_t sector =3D round_down(start, chunk_sectors); > + > + while (sector < limit) { > + sector_t blocks; > + > + mddev->bitmap_ops->end_sync(mddev, sector, &blocks); > + blocks =3D min(blocks, limit - sector); > + sector +=3D blocks; > + /* > + * Missing and hijacked counter pages report a whole page > + * span. A hijacked page has two counters, one for each > + * half. Visit the last sector of the span as well, in > + * case it uses the other counter. > + */ > + if (blocks > chunk_sectors) > + mddev->bitmap_ops->end_sync(mddev, sector - 1, &blocks); > + cond_resched(); > + } > +} [Severity: Low] Should this range-abort walk live behind struct bitmap_operations in drivers/md/md-bitmap.c instead of raid10.c? raid10_abort_sync_bitmap() checks mddev->bitmap_id =3D=3D ID_BITMAP and hardcodes classic bitmap's hijacked counter-page layout from md_bitmap_get_counter(), while md-bitmap.c already owns both that layout and the full-bitmap walk in bitmap_close_sync(). Separately, on aborted recovery raid10_sync_request() still runs the per-disk raid10_find_virt() and md_bitmap_end_sync() loop right before raid10_abort_sync_bitmap(mddev, 0) walks and ends every chunk from sector 0 again. [ ... ] > @@ -3182,8 +3229,16 @@ static sector_t raid10_sync_request(struct mddev *= mddev, sector_t sector_nr, > } > conf->fullsync =3D 0; > } > - if (md_bitmap_enabled(mddev, false)) > + if (aborted && raid10_classic_bitmap(mddev) && > + !test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) { > + /* > + * close_sync would clear in-progress chunks that > + * still have copies outstanding. > + */ > + raid10_abort_sync_bitmap(mddev, 0); > + } else if (md_bitmap_enabled(mddev, false)) { > mddev->bitmap_ops->close_sync(mddev); > + } > close_sync(conf); > *skipped =3D 1; > return 0; [Severity: Medium] Can calling raid10_abort_sync_bitmap(mddev, 0) and skipping close_sync() permanently leave NEEDED_MASK set on already-recovered chunks? When recovery resumes, md_sync_position() starts at rdev->recovery_offset, so chunks whose copies all lie below curr_resync are never revisited by md_bitmap_start_sync(). When recovery later finishes, bitmap_close_sync() only clears RESYNC_MASK and leaves NEEDED_MASK set. Because NEEDED_MASK keeps *bmc above 2, bitmap_daemon_work() never clears those on-disk bits or lets md_bitmap_checkfree() free their 4 KiB counter pages. Those pages stay pinned in memory while the array runs, and a later unclean shutdown or member re-add needlessly resyncs those chunks. Passing a layout-derived virtual lower bound for curr_resync as start (for example on near and offset layouts) and then calling close_sync() would close already-completed chunks cleanly. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204174621.3475= 573-1-ehagberg@janestreet.com?part=3D2