From 2cca7deb7272b3fcbd38fea2a655f1f52694709d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 29 Nov 2026 02:19:09 -0800 Subject: [PATCH] fix(sw-block): placement reads the published line; abort checks the local install; backup needs --name - The placement step reads the publisher's line (QueryVolumeStatus), which exists before any lease is granted on it, with the bindings (QueryWorkspace). A placement refused because the line was published in between is read again: this exact placement counts as done. - --abort also checks this host's settings for the target (volume, master, layout id) before any change; another installation, or a running unit without settings, refuses with nothing changed. - volume backup requires --name: a name the command chose would be lost with its terminal, and the same command could not resume it. - The fake master answers a deleting or tombstoned target as the master does (FailedPrecondition, not_admitted) and grants no lease, so every re-run test runs in the published-before-lease interval. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/cmd/sw-block/volume_backup.go | 78 +++++++++-- .../cmd/sw-block/volume_backup_test.go | 122 ++++++++++++++++-- seaweed-block/cmd/sw-block/volume_verbs.go | 8 +- seaweed-block/docs/standalone-deployment.md | 11 +- 4 files changed, 186 insertions(+), 33 deletions(-) diff --git a/seaweed-block/cmd/sw-block/volume_backup.go b/seaweed-block/cmd/sw-block/volume_backup.go index 8d75f2d4ad..966b3f6e60 100644 --- a/seaweed-block/cmd/sw-block/volume_backup.go +++ b/seaweed-block/cmd/sw-block/volume_backup.go @@ -44,11 +44,11 @@ type backupOpts struct { Timeout time.Duration } -func parseVolumeBackup(args []string, now time.Time, stderr io.Writer) (backupOpts, error) { +func parseVolumeBackup(args []string, stderr io.Writer) (backupOpts, error) { fs := flag.NewFlagSet("sw-block volume backup", flag.ContinueOnError) fs.SetOutput(stderr) var o backupOpts - fs.StringVar(&o.Name, "name", "", "snapshot name (default backup-, printed; give it again to resume)") + fs.StringVar(&o.Name, "name", "", "snapshot name (required: the same --name resumes this backup)") fs.DurationVar(&o.Timeout, "timeout", 5*time.Minute, "bound on the snapshot") if err := fs.Parse(volumeArgsFirst(args)); err != nil { return o, err @@ -59,7 +59,11 @@ func parseVolumeBackup(args []string, now time.Time, stderr io.Writer) (backupOp } o.Volume = fs.Arg(0) if o.Name == "" { - o.Name = "backup-" + now.UTC().Format("20060102T150405Z") + // No generated default: a name chosen by the command is lost with + // its terminal, and the same command could not find that snapshot + // again. The operator's name is what a re-run resumes. + fmt.Fprintln(stderr, "sw-block volume backup: --name is required (the same command with the same --name resumes the backup)") + return o, errors.New("--name is required") } return o, nil } @@ -309,6 +313,18 @@ func volumeRestore(ctx context.Context, env verbEnv, o restoreOpts, args []strin fmt.Fprintln(stdout, " already placed (an earlier run of this command)") default: if step, err := workspaceBindPlace(ctx, master, binding, v.ReplicaID); err != nil { + if status.Code(err) == codes.FailedPrecondition { + // The line may have been published between the read and the + // placement: this exact placement counts as done; anything + // else keeps the refusal. + if again, why2, qerr := restorePlaced(ctx, master, binding, v.ReplicaID); qerr == nil && again { + fmt.Fprintln(stdout, " placed (published while placing)") + break + } else if qerr == nil && why2 != "" { + fmt.Fprintf(stderr, "sw-block volume restore: place: refused: %s; to undo it: %s\n", why2, abort) + return ops.VolumeStatusExitInvalid + } + } switch status.Code(err) { case codes.FailedPrecondition, codes.InvalidArgument, codes.AlreadyExists, codes.PermissionDenied: fmt.Fprintf(stderr, "sw-block volume restore: %s: refused: %v; the new volume exists but is not placed; to undo it: %s\n", step, err, abort) @@ -370,6 +386,26 @@ func volumeRestoreAbort(ctx context.Context, env verbEnv, o restoreOpts, stdout, t, rec.GetSourceVolume(), rec.GetSourceSnapshot(), rec.GetCreateRequestId()) return ops.VolumeStatusExitInvalid } + // And this host's T must be that target: its settings name this volume, + // this master and the record's layout id. Settings that name anything + // else are another installation; a running unit without settings cannot + // be confirmed. Either refuses with nothing changed. No settings and a + // stopped unit is an abort already past its settings step. + envPath := filepath.Join(env.EtcDir, t+".env") + if local, lerr := readEnvFile(envPath); lerr == nil { + if local["SWB_VOLUME_ID"] != t || local["SWB_MASTER_ADDR"] != master || !strings.Contains(" "+local["SWB_VOLUME_EXTRA_ARGS"]+" ", " --layout-id "+rec.GetLayoutId()+" ") { + fmt.Fprintf(stderr, "sw-block volume restore --abort: verify: refused: %s on this host is another installation (settings name volume %q, master %q, %q; the target is layout %s at %s); nothing was changed\n", + envPath, local["SWB_VOLUME_ID"], local["SWB_MASTER_ADDR"], local["SWB_VOLUME_EXTRA_ARGS"], rec.GetLayoutId(), master) + return ops.VolumeStatusExitInvalid + } + } else if !errors.Is(lerr, os.ErrNotExist) { + return fail("verify", fmt.Errorf("read %s: %w (nothing was changed)", envPath, lerr)) + } else if st, serr := unitState(ctx, env, unit); serr != nil { + return fail("verify", fmt.Errorf("%s's state: %w (nothing was changed)", unit, serr)) + } else if !unitStopped(st) { + fmt.Fprintf(stderr, "sw-block volume restore --abort: verify: refused: %s is %s but has no settings, so it cannot be confirmed as this restore's target; nothing was changed\n", unit, st) + return ops.VolumeStatusExitInvalid + } if err := env.step(stdout, "unit", "stop and disable "+unit); err != nil { return fail("unit", err) } @@ -458,22 +494,27 @@ func restoreRefusal(err error) string { return "" } -// restorePlaced reads the volume's placement at the master -// (QueryWorkspace): placed when its authority line is this replica's and a -// live binding names this server and these addresses; why is set when a -// line exists for anything else; neither when no line exists yet (an -// identical placement is then accepted again). +// restorePlaced reads the volume's published authority line at the master +// (QueryVolumeStatus: the publisher's line itself, which exists before any +// lease is granted on it) and its bindings (QueryWorkspace): placed when +// the line is this replica's and a live binding names this server and +// these addresses; why is set when a line exists for anything else; +// neither when no line is published yet (an identical placement is then +// accepted again). func restorePlaced(ctx context.Context, master string, b *control.WorkspaceBinding, replica string) (placed bool, why string, err error) { - st, err := workspaceQuery(ctx, master, b.VolumeId) + line, err := volumeStatusQuery(ctx, master, b.VolumeId) if err != nil { return false, "", err } - lease := st.GetLease() - if lease == nil { + if line.GetReplicaId() == "" || line.GetEpoch() == 0 { return false, "", nil } - if lease.GetReplicaId() != replica { - return false, fmt.Sprintf("%s's authority line is replica %q, not %q", b.VolumeId, lease.GetReplicaId(), replica), nil + if line.GetReplicaId() != replica { + return false, fmt.Sprintf("%s's authority line is replica %q, not %q", b.VolumeId, line.GetReplicaId(), replica), nil + } + st, err := workspaceQuery(ctx, master, b.VolumeId) + if err != nil { + return false, "", err } for _, have := range st.GetBindings() { if have.GetServerId() == b.ServerId && have.GetDataAddr() == b.DataAddr && have.GetCtrlAddr() == b.CtrlAddr && !have.GetRetired() { @@ -483,6 +524,17 @@ func restorePlaced(ctx context.Context, master string, b *control.WorkspaceBindi return false, fmt.Sprintf("%s's authority line has no live binding for server %s at %s/%s", b.VolumeId, b.ServerId, b.DataAddr, b.CtrlAddr), nil } +// volumeStatusQuery is the master's QueryVolumeStatus: the publisher's +// current authority line for the volume. +var volumeStatusQuery = func(ctx context.Context, master, volume string) (*control.StatusResponse, error) { + conn, err := link.DialMasterFromEnv(master) + if err != nil { + return nil, err + } + defer conn.Close() + return control.NewEvidenceServiceClient(conn).QueryVolumeStatus(ctx, &control.StatusRequest{VolumeId: volume}) +} + // workspaceQuery is the master's QueryWorkspace. var workspaceQuery = func(ctx context.Context, master, volume string) (*control.WorkspaceStatus, error) { conn, err := link.DialMasterFromEnv(master) diff --git a/seaweed-block/cmd/sw-block/volume_backup_test.go b/seaweed-block/cmd/sw-block/volume_backup_test.go index f1363eadae..21d1df57b6 100644 --- a/seaweed-block/cmd/sw-block/volume_backup_test.go +++ b/seaweed-block/cmd/sw-block/volume_backup_test.go @@ -107,6 +107,7 @@ func newSnapHolder(t *testing.T) *snapHolder { type restoreMaster struct { control.UnimplementedLifecycleServiceServer control.UnimplementedWorkspaceServiceServer + control.UnimplementedEvidenceServiceServer mu sync.Mutex vols map[string]*restoreRec ids map[string]layout.VolumeID // layout ids the master minted @@ -142,8 +143,10 @@ func (m *restoreMaster) CreateVolume(ctx context.Context, q *control.CreateVolum } r, ok := m.vols[q.VolumeId] switch { - case ok && (r.req != q.CreateRequestId || r.deleted): - return nil, status.Error(codes.AlreadyExists, "the name exists (another request, or deleted)") + case ok && r.req != q.CreateRequestId: + return nil, status.Error(codes.AlreadyExists, "create volume: vol-r is bound to another restore request") + case ok && r.deleted: // as the master answers a deleting target + return nil, status.Error(codes.FailedPrecondition, "restore target: "+layout.ErrVolumeDeleting.Error()) case !ok: r = &restoreRec{source: q.SourceVolume, snap: q.SourceSnapshot, req: q.CreateRequestId} m.vols[q.VolumeId] = r @@ -166,8 +169,8 @@ func (m *restoreMaster) CreateVolume(ctx context.Context, q *control.CreateVolum // The store and the dependent: the catalog's own restore. A tombstoned // or existing target is the catalog's refusal. if _, err := m.cat.Restore(ctx, m.src, "s1", chunkstore.VolumeRef{Name: q.VolumeId, ID: m.ids[q.VolumeId]}); err != nil { - if errors.Is(err, layout.ErrExists) { - return nil, status.Error(codes.AlreadyExists, "restore target: "+err.Error()) + if errors.Is(err, layout.ErrExists) || errors.Is(err, layout.ErrVolumeDeleting) { + return nil, status.Error(codes.FailedPrecondition, "restore target: "+err.Error()) // the master's mapping } return nil, status.Error(codes.Internal, err.Error()) } @@ -246,6 +249,14 @@ func (m *restoreMaster) PlaceWorkspace(_ context.Context, q *control.WorkspacePl m.mu.Lock() defer m.mu.Unlock() m.places++ + if m.failNext == "publish-race" || m.failNext == "publish-race-other" { // the line is published just before this placement lands + rep := q.ReplicaId + if m.failNext == "publish-race-other" { + rep = "r1" + } + m.failNext = "" + m.placed[q.VolumeId], m.published[q.VolumeId] = rep, true + } if m.published[q.VolumeId] { // RecordWorkspacePlacement once a line exists return nil, status.Error(codes.FailedPrecondition, "workspace placement: volume already assigned; use move") } @@ -263,12 +274,23 @@ func (m *restoreMaster) PlaceWorkspace(_ context.Context, q *control.WorkspacePl func (m *restoreMaster) QueryWorkspace(_ context.Context, q *control.WorkspaceVolume) (*control.WorkspaceStatus, error) { m.mu.Lock() defer m.mu.Unlock() + // Bindings only: no holder ever renews here, so no lease is granted, + // the interval a published line spends before its first lease. out := &control.WorkspaceStatus{} if b, ok := m.bound[q.GetVolumeId()]; ok { out.Bindings = append(out.Bindings, b) } + return out, nil +} + +// QueryVolumeStatus is the publisher's line: present once published, +// whether or not a lease was granted on it. +func (m *restoreMaster) QueryVolumeStatus(_ context.Context, q *control.StatusRequest) (*control.StatusResponse, error) { + m.mu.Lock() + defer m.mu.Unlock() + out := &control.StatusResponse{VolumeId: q.GetVolumeId()} if m.published[q.GetVolumeId()] { - out.Lease = &control.WorkspaceLeaseFact{VolumeId: q.GetVolumeId(), ReplicaId: m.placed[q.GetVolumeId()], Epoch: 1} + out.ReplicaId, out.Epoch, out.Assigned = m.placed[q.GetVolumeId()], 1, true } return out, nil } @@ -295,6 +317,7 @@ func serveRestoreMaster(t *testing.T) (*restoreMaster, string) { server := grpc.NewServer() control.RegisterLifecycleServiceServer(server, m) control.RegisterWorkspaceServiceServer(server, m) + control.RegisterEvidenceServiceServer(server, m) go func() { _ = server.Serve(lis) }() t.Cleanup(server.Stop) return m, lis.Addr().String() @@ -357,7 +380,7 @@ func sourceEnv(t *testing.T, env verbEnv, master, status string, chunk bool) { func runBackup(env verbEnv, args ...string) (int, string, string) { var out, errb bytes.Buffer - o, err := parseVolumeBackup(args, env.Now(), &errb) + o, err := parseVolumeBackup(args, &errb) if err != nil { return 2, out.String(), errb.String() } @@ -430,7 +453,12 @@ func TestVolumeBackupTakesOneSnapshotAndRerunReplays(t *testing.T) { env := h.env(t) sh := newSnapHolder(t) sourceEnv(t, env, "127.0.0.1:1", strings.TrimPrefix(sh.srv.URL, "http://"), true) - code, out, errs := runBackup(env, "vol-a") + // No generated default: without --name the command refuses before + // any request (a name it chose would be lost with its terminal). + if code, _, errs := runBackup(env, "vol-a"); code != 2 || !strings.Contains(errs, "--name is required") || sh.posts != 0 { + t.Fatalf("no --name: %d %s (posts %d)", code, errs, sh.posts) + } + code, out, errs := runBackup(env, "vol-a", "--name", "backup-20261128T230000Z") if code != 0 || !strings.Contains(out, "snapshot backup-20261128T230000Z of vol-a") || !strings.Contains(out, "sudo sw-block volume restore vol-a --snapshot backup-20261128T230000Z --as ") { t.Fatalf("backup: %d\n%s\n%s", code, out, errs) } @@ -502,16 +530,16 @@ func TestVolumeBackupRefusals(t *testing.T) { h := newFakeHost(t) env := h.env(t) sh := newSnapHolder(t) - if code, _, errs := runBackup(env, "vol-a"); code != 2 || !strings.Contains(errs, "was vol-a started") { + if code, _, errs := runBackup(env, "vol-a", "--name", "n1"); code != 2 || !strings.Contains(errs, "was vol-a started") { t.Fatalf("unknown volume: %d %s", code, errs) } sourceEnv(t, env, "127.0.0.1:1", strings.TrimPrefix(sh.srv.URL, "http://"), false) - if code, _, errs := runBackup(env, "vol-a"); code != 2 || !strings.Contains(errs, "is walstore") || sh.posts != 0 { + if code, _, errs := runBackup(env, "vol-a", "--name", "n1"); code != 2 || !strings.Contains(errs, "is walstore") || sh.posts != 0 { t.Fatalf("walstore: %d %s", code, errs) } sourceEnv(t, env, "127.0.0.1:1", strings.TrimPrefix(sh.srv.URL, "http://"), true) sh.mode = "refuse" - if code, _, errs := runBackup(env, "vol-a"); code != 2 || !strings.Contains(errs, "not_primary") { + if code, _, errs := runBackup(env, "vol-a", "--name", "n1"); code != 2 || !strings.Contains(errs, "not_primary") { t.Fatalf("refused: %d %s", code, errs) } sh.mode = "" @@ -650,8 +678,10 @@ func TestVolumeRestoreCrashTableBothWays(t *testing.T) { if rec.ready && strings.Contains(firstAbortOut, "not-ready restore record") { t.Fatalf("a deleted target is not a kept not-ready record: %s", firstAbortOut) } - // After an abort the name is never created again. - if code, _, errs := runRestore(env, restoreArgs(h)...); code != 2 || !strings.Contains(errs, "target_exists") { + // After an abort the name is never created again: the master + // refuses the deleting target, and the catalog's tombstone + // refuses a target that never had HEAD (FailedPrecondition). + if code, _, errs := runRestore(env, restoreArgs(h)...); code != 2 || !strings.Contains(errs, "not_admitted") || !strings.Contains(errs, "restore target:") { t.Fatalf("restore after abort: %d %s", code, errs) } }) @@ -838,6 +868,74 @@ func TestVolumeRestorePlacementOfAnotherLineRefuses(t *testing.T) { } } +// The line published between the placement read and the placement: the +// master refuses the placement as already assigned; this exact placement +// counts as done and the restore starts, another replica's refuses. +func TestVolumeRestorePublicationDuringThePlacement(t *testing.T) { + h, env, m, _ := restoreSetup(t) + m.failNext = "publish-race" + code, out, errs := runRestore(env, restoreArgs(h)...) + if code != 0 || !strings.Contains(out, "published while placing") || h.called("enable") == 0 { + t.Fatalf("own publication during the placement: %d %s %s", code, out, errs) + } + h2, env2, m2, _ := restoreSetup(t) + m2.failNext = "publish-race-other" + code, _, errs = runRestore(env2, restoreArgs(h2)...) + if code != 2 || !strings.Contains(errs, `authority line is replica "r1"`) || h2.called("enable") != 0 { + t.Fatalf("another replica's publication during the placement: %d %s", code, errs) + } +} + +// --abort leaves another installation of the same name on this host alone: +// settings naming another master or layout, or a running unit with no +// settings, refuse before any change (no systemctl, settings kept, no +// delete or release), even though the master's record is this restore's. +func TestVolumeRestoreAbortRefusesAnotherLocalInstallation(t *testing.T) { + for _, c := range []struct { + name string + settings func(master, layoutID string) string // "" = no settings file + unit string + want string + }{ + {"another master", func(_, id string) string { + return "SWB_VOLUME_ID=vol-r\nSWB_MASTER_ADDR=10.9.9.9:9180\nSWB_VOLUME_EXTRA_ARGS=\"--layout-id " + id + "\"\n" + }, "active", "is another installation"}, + {"another layout", func(master, _ string) string { + return "SWB_VOLUME_ID=vol-r\nSWB_MASTER_ADDR=" + master + "\nSWB_VOLUME_EXTRA_ARGS=\"--layout-id ffffffffffffffffffffffffffffffff\"\n" + }, "active", "is another installation"}, + {"running unit, no settings", nil, "active", "has no settings, so it cannot be confirmed"}, + } { + t.Run(c.name, func(t *testing.T) { + h, env, m, order := restoreSetup(t) + if code, _, errs := runRestore(env, restoreArgs(h)...); code != 0 { + t.Fatal(errs) + } + src, _ := readEnvFile(filepath.Join(env.EtcDir, "vol-a.env")) + settings := filepath.Join(env.EtcDir, "vol-r.env") + if c.settings == nil { + _ = os.Remove(settings) + } else if err := os.WriteFile(settings, []byte(c.settings(src["SWB_MASTER_ADDR"], m.ids["vol-r"].String())), 0o640); err != nil { + t.Fatal(err) + } + h.mu.Lock() + h.unit, h.calls = c.unit, nil + h.mu.Unlock() + code, _, errs := runRestore(env, "vol-a", "--snapshot", "s1", "--as", "vol-r", "--abort") + if code != 2 || !strings.Contains(errs, c.want) || !strings.Contains(errs, "nothing was changed") { + t.Fatalf("%s: %d %s", c.name, code, errs) + } + if h.called("disable") != 0 || h.called("stop") != 0 || len(*order) != 0 || m.reserves != 0 { + t.Fatalf("changed another installation: systemctl %v, chunk steps %v", h.calls, *order) + } + if c.settings != nil { + if _, err := os.Stat(settings); err != nil { + t.Fatalf("removed another installation's settings: %v", err) + } + } + }) + } +} + // An abort for a target the master never recorded (the restore was refused // before it wrote anything) has nothing to delete. func TestVolumeRestoreAbortOfANeverCreatedTarget(t *testing.T) { diff --git a/seaweed-block/cmd/sw-block/volume_verbs.go b/seaweed-block/cmd/sw-block/volume_verbs.go index ec4e443b26..cebffb632c 100644 --- a/seaweed-block/cmd/sw-block/volume_verbs.go +++ b/seaweed-block/cmd/sw-block/volume_verbs.go @@ -33,7 +33,7 @@ const stopRecoveryPoint = "recovery point in the object store: the cut at %s; wr const volumeUsage = `usage: sudo sw-block volume start [flags] sudo sw-block volume stop [--force] [--no-cut] [--timeout 2m] - sudo sw-block volume backup [--name S] + sudo sw-block volume backup --name S sudo sw-block volume restore --snapshot S --as [start flags for ] sudo sw-block volume restore --snapshot S --as --abort @@ -48,8 +48,8 @@ stop: refuses while a guest is connected (unless --force), takes a cut, refuses when the cut failed or its outcome is unknown (unless --no-cut), stops the unit, and ends with: "` + stopRecoveryPoint + `". -backup: a named snapshot of a running walstore-chunk volume (the name is -printed; the same command with the same --name resumes it, never a second). +backup: a named snapshot of a running walstore-chunk volume (--name is +required; the same command with the same --name resumes it, never a second). restore: the snapshot into a new volume on this host (same master and chunk filer as the source), then volume start for it. Interrupted anywhere, the @@ -116,7 +116,7 @@ func runVolume(args []string, stdout, stderr io.Writer) int { defer cancel() switch args[0] { case "backup": - o, err := parseVolumeBackup(args[1:], env.Now(), stderr) + o, err := parseVolumeBackup(args[1:], stderr) if err != nil { return ops.VolumeStatusExitInvalid } diff --git a/seaweed-block/docs/standalone-deployment.md b/seaweed-block/docs/standalone-deployment.md index cd1bd56c0a..aa0c679f6e 100644 --- a/seaweed-block/docs/standalone-deployment.md +++ b/seaweed-block/docs/standalone-deployment.md @@ -514,19 +514,22 @@ A walstore volume (no `--chunk-filer`) has no object store; its stop says so. `s Both are whole-job commands over existing calls, for walstore-chunk volumes started with `volume start`. Neither keeps state of its own: every request id is derived from the command's arguments and every step checks before it acts. A command interrupted anywhere, a host power loss included, is finished by running it again unchanged. Every failure message names the exact command to run next. -**`sudo sw-block volume backup [--name S]`** takes a named snapshot of the running volume through its holder (the call `ops chunk snapshot` makes). The name defaults to `backup-` and is printed before the request is sent. The snapshot carries the label `sw-block-backup` with the request's id. The holder answers an existing name with the snapshot already there, so the same command with the same `--name` finds its own snapshot and never takes a second one. A snapshot of that name that this command did not take (another backup's, or one from `ops chunk snapshot` or the schedule) is refused as `snapshot_name_taken`. An answer missing the HEAD generation, cut LSN or time is an unknown outcome, and the message names the same command. The output names the snapshot's HEAD generation, cut LSN and time, and the restore command for it. +**`sudo sw-block volume backup --name S`** takes a named snapshot of the running volume through its holder (the call `ops chunk snapshot` makes). `--name` is required: the operator's name is what a re-run resumes (a name the command chose itself would be lost with its terminal). The snapshot carries the label `sw-block-backup` with the request's id. The holder answers an existing name with the snapshot already there, so the same command with the same `--name` finds its own snapshot and never takes a second one. A snapshot of that name that this command did not take (another backup's, or one from `ops chunk snapshot` or the schedule) is refused as `snapshot_name_taken`. An answer missing the HEAD generation, cut LSN or time is an unknown outcome, and the message names the same command. The output names the snapshot's HEAD generation, cut LSN and time, and the restore command for it. **`sudo sw-block volume restore --snapshot S --as --replica-id R --data-addr A --ctrl-addr A --status-addr 127.0.0.1:P --nvme-listen A`** restores the snapshot into a new volume on this host: 1. **Restore.** It runs the master's restore create (the call `ops chunk restore` makes), with the request id derived from ``, the source and the snapshot. The master journals the operation, so a re-run of the same request completes it, and a request with another id for the same name is refused (`target_exists`). -2. **Place.** It records the new volume's binding and placement on this host (the calls `ops volume create` makes). This step runs only after the master confirms the new volume store-ready. Once the volume serves, the master refuses any placement, an identical one included, so the step first reads the placement (`QueryWorkspace`): - - an authority line for this replica, with this server's binding, is this restore's placement, and the step is done (a re-run after a finished restore); +2. **Place.** It records the new volume's binding and placement on this host (the calls `ops volume create` makes). This step runs only after the master confirms the new volume store-ready. Once the volume's authority line is published (even before any lease is granted on it), the master refuses any placement, an identical one included. So the step first reads the published line (`QueryVolumeStatus`) and the bindings (`QueryWorkspace`): + - a line for this replica, with this server's binding, is this restore's placement, and the step is done (a re-run after a finished restore); - a line for anything else refuses, naming the abort. + - A placement refused because the line was published in between is read again: this exact placement counts as done, anything else refuses. 3. **Start.** It runs `volume start`'s steps for ``, with the source's master, server id and chunk filer and the restored size. The source is never touched, and `` must be a new name. Refusals keep their typed codes (`snapshot_not_found`, `target_exists`, `restore_source_not_own`). **`sudo sw-block volume restore --snapshot S --as --abort`** is the way back from a restore, finished or not: -1. Before anything changes, it reads the master's record of `` and checks that `` is this restore's target: the source, snapshot and request id the master recorded must be this command's. Another restore's target, a plain volume, or a record with no restore tuple (a blockmaster before v1.0.1 does not report it) is refused with nothing changed. +1. Before anything changes, it checks that `` is this restore's target, both at the master and on this host: + - The source, snapshot and request id the master recorded must be this command's. Another restore's target, a plain volume, or a record with no restore tuple (a blockmaster before v1.0.1 does not report it) is refused with nothing changed. + - This host's `` settings must name ``, the source's master and the record's layout id. Settings that name anything else belong to another installation; a running unit without settings cannot be confirmed. Either is refused with nothing changed. Missing settings with a stopped unit is an abort already past its settings step. 2. It stops and disables ``'s unit. 3. It removes ``'s settings. 4. It deletes ``. A `` with a HEAD goes through `ops chunk volume-delete`; one that never got its first HEAD goes through `ops chunk release`, which tombstones it.