daemon: skip fsck_snapshot on freshly-created system overlays

The fsck_snapshot lifecycle step exists to repair stale bitmaps in
a COW file reused from a prior aborted start — without it, the
later e2cp/e2rm calls in patch_root_overlay refuse to touch the
snapshot. On a freshly-created COW there are no stale bitmaps to
repair, so e2fsck -fy is pure overhead.

system_overlay already tracks whether it created the file this run
(sc.systemOverlayCreated, used to drive the rollback path). Reuse
that flag to skip e2fsck entirely on the create-fresh path. The
reused-COW path keeps the fsck for safety. Saves a few hundred ms
per VM create — small absolute win on top of the lazy-mkfs change,
but free.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Thales Maciel 2026-04-26 21:37:14 -03:00
parent 74a2d064fd
commit b8c48765fb
No known key found for this signature in database
GPG key ID: 33112E6833C34679

View file

@ -237,12 +237,18 @@ func (s *VMService) buildStartSteps(op *operationLog, sc *startContext) []startS
}, },
}, },
{ {
// See the comment in the prior inline version: stale // e2fsck protects against stale bitmaps in a COW reused
// bitmaps from a reused COW make e2cp/e2rm refuse to // from a prior aborted start — without it, e2cp/e2rm in
// touch the snapshot. e2fsck -fy is a no-op on a fresh // patch_root_overlay refuse to touch the snapshot. On a
// snapshot. Exit codes 0 + 1 are both "ok" here. // freshly-created COW (system_overlay just truncated +
// created the file this run) there are no stale bitmaps
// to repair and e2fsck is pure overhead. Skip it in that
// case. Exit codes 0 + 1 are both "ok" when we do run it.
name: "fsck_snapshot", name: "fsck_snapshot",
run: func(ctx context.Context, sc *startContext) error { run: func(ctx context.Context, sc *startContext) error {
if sc.systemOverlayCreated {
return nil
}
return s.privOps().FsckSnapshot(ctx, sc.live.DMDev) return s.privOps().FsckSnapshot(ctx, sc.live.DMDev)
}, },
}, },