Skip to content

feat(jm): rebuild the journal raid when a node's devices change - #1705

Open
wmousa wants to merge 5 commits into
feat/lblk-journal-raidfrom
feat/jm-raid-reshape
Open

wmousa wants to merge 5 commits into
feat/lblk-journal-raidfrom
feat/jm-raid-reshape

Conversation

@wmousa

@wmousa wmousa commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #1689 (base branch feat/lblk-journal-raid). Review and merge that one first.

What this changes

The journal raid of a node follows its devices. The raid is built over the journal partitions of the node's devices and used to keep that member list for life. A device migrated out after a failure left the raid degraded for good, and a device with a journal partition the raid did not use never joined it.

A raid0 leg cannot take a member in or give one up, and the raid has no superblock. So the raid is built anew, empty, over the members the node's devices call for, and the journal is resynchronised from the node's other journal copies. A jm_raid_reshape task does it, on the existing restart runner (no new service to deploy):

  • queued when a device reaches failed_and_migrated, or a device is added;
  • started only on an active cluster with every node online, no migration or restart open, and every journal in sync;
  • one node at a time;
  • finished once the rebuilt JM holds every journal it is a copy of and jc_get_jm_status reports them in sync on three consecutive polls.

A device that is only missing keeps its member, as in #1689: the JM runs on the other legs and the leg is rebuilt when the device returns.

Raid legs are capped at four devices (decision from the design discussion): 1 device no raid, 2 devices raid1, 3-8 devices raid1 over two raid0 legs, 9-12 over three, and so on. Up to eight devices the split is the one every existing RAID 0+1 JM was built with.

A JM that holds a journal is rebuilt from the legs recorded for it, never from the planner. Without this, a node of more than eight devices built as two halves would be re-read as three legs after the upgrade and its journal would be unreadable.

Block-device nodes: the journal partition is --jm-percent of the node's smallest device, on every device. #1689 sized it from the node's total capacity and the number of devices. The size no longer depends on the device count, so a device that joins later is split to the same size. This must not be released after #1689 alone: the partition size cannot be changed on disks that hold data.

Clusters pinned to the legacy mirror-over-all-devices layout keep it, also through a rebuild.

Found on the lab and fixed here

The first lab run reported "journals in sync" on a node whose rebuilt JM held two of its three journals. The LVS leader re-levels a JM it reaches over the network when it reconnects; it does not for its own local JM, and jc_get_jm_status still reports that JM ready. The task now asks the JM itself (bdev_jm_get_status) and starts a missing journal with jc_explicit_synchronization on the confirmed LVS leader, never on a follower.

Tested

Unit: 79 new test functions (tests/unit/test_jm_raid_reshape.py), existing planner and sizing tests updated. Lint clean.

Lab (Talos, 3 nodes, 4 emulated NVMe drives each, 1+1, verified fio randrw running throughout):

  • one drive of the node hosting the volume removed for good, device set failed, data migrated;
  • raid rebuilt from 4 members (2+2) to 3 (2+1), journal resynchronised;
  • all three nodes hold all three journals with identical record counts;
  • node restarted afterwards: the journal loaded from the rebuilt raid at the record count it was synchronised to;
  • fio without errors, cluster active, no open tasks.

Not tested, and known gaps

  • Growth has no trigger yet. A block-device node records its devices only at add-node, and a new NVMe drive is used whole with no journal partition, so a device added later brings no journal partition the node knows. The rebuild handles added members; nothing produces one today.
  • Block-device nodes and the per-device sizing: unit tests only (the lab run was on NVMe).
  • More than eight devices (three legs): unit tests only.
  • During the explicit synchronisation SPDK logs helper_sync_setter: jfi_w_set_crossjm_sync_id failed, JM is excluded from further operation once, in both lab runs. The JM kept receiving records and read back after a restart; to be confirmed as harmless by the data-plane team.

🤖 Generated with Claude Code

wmousa and others added 5 commits November 23, 2026 17:13
The journal raid of a node is built over the journal partitions of its
devices and kept that member list for life: a device migrated out after a
failure left the raid degraded for good, and a device with a journal
partition the raid did not use never joined it.

A raid0 leg cannot take a member in or give one up, and the raid has no
superblock, so the raid is now built anew, empty, over the members the
node's devices call for, and the journal coordinator of the LVS leader
resynchronises it from the node's other journal copies. A jm_raid_reshape
task does it on the restart runner: queued when a device reaches
failed_and_migrated or is added, started only on an active cluster with
every node online, no migration or restart open and every journal in sync,
one node at a time, and finished once jc_get_jm_status reports the journals
in sync on three consecutive polls. A device that is only missing keeps its
member, as before.

Raid legs are capped at four devices: two legs up to eight devices, three
from nine to twelve, and so on. A JM that holds a journal is rebuilt from
the legs recorded for it and never from the planner, so a node of more than
eight devices built as two halves keeps reading its journal.

On block-device nodes every device now gives a journal partition of
--jm-percent of the node's smallest device, where it was sized from the
node's total capacity and the number of devices. The size no longer depends
on the device count, so a device that joins later is split to the same
size.

The journal partition of a device that left the raid is not offered as a
new data device by a restart. The planner helpers that assumed exactly two
legs and had no caller are removed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The jm_raid_reshape task trusted jc_get_jm_status to tell when the rebuilt,
empty JM was back in sync. On the lab the LVS leader reported every JM of
its journal ready while the leader's own rebuilt JM did not hold that
journal at all: the journal coordinator re-levels a JM it reaches over the
network when it reconnects, and does not for its local one. The task
reported "journals in sync" on a node whose JM held two of three journals.

The JM itself is now asked whether it holds each journal it is a copy of
(bdev_jm_get_status), and a journal it lacks that nobody replicates is
started with jc_explicit_synchronization on the confirmed LVS leader, never
on a follower. A journal that still does not arrive after ten
synchronisations costs the task retries instead of an endless wait.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The rebuild, its task and the journal resync read and write node and task
records, so their tests belong to the integration tier: 36 cases drive the
restart runner's spec over seeded clusters in FoundationDB, with only the
SPDK RPC client, the leadership probe and the device-status fan-out
replaced. The unit file keeps what is pure logic.

Writing them showed the task marking itself as rebuilding before it knew
the rebuild could start: a member that was absent then cost a retry and,
worse, let every later attempt skip the quiet-cluster checks although
nothing had been taken down. Whether the raid can be rebuilt is now asked
with the other preconditions, before the phase is recorded.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The task synchronised a journal to the rebuilt JM only when the JM reported
that it did not hold it. On the lab that report was wrong more often than
right: after a rebuild the leader's own JM answered bdev_jm_get_status with
the journal as held while nothing had been replicated to it, and a restart
of the node then found that journal not on its disks and had it replicated
from the peers. The journals that were replicated (SPDK logs the start and
the end of the replication) did read back after an immediate restart.

Neither status RPC proves a rebuilt JM was brought up to date, so every
journal the JM is a copy of is now synchronised explicitly on its LVS
leader once after the rebuild, and again while the JM reports it missing.
A journal whose replication is already running is synchronised when that
is over, not on top of it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
failed_and_migrated says a device's data was moved elsewhere and its place
in the cluster given up; a replacement enters as a new record
(new_device_from_failed). Nothing enforced that. device_set_state treated
only "failed" as a state with restricted exits, and the node monitor's
re-admit of a recovered node's devices skipped the online, removed and
failed ones and set every other device ONLINE.

On the lab a node was marked unreachable for a moment while a peer
restarted, and was cleared back to ONLINE. The monitor set the three
devices of that node that had been migrated out ONLINE again. SPDK could
open none of them, each was walked through unavailable to removed, and with
the peer still restarting the cluster was suspended and client IO failed.

device_set_state now refuses every transition out of failed_and_migrated,
whatever the cause, and the re-admit names the states it leaves alone,
failed_and_migrated and new (a device that is not part of the cluster yet)
among them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
(cherry picked from commit 40a572f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant