From b8c48765fb4db68b4ed4ad555da99a4026f46fe2 Mon Sep 17 00:00:00 2001 From: Thales Maciel Date: Sun, 26 Apr 2026 21:37:14 -0300 Subject: [PATCH] daemon: skip fsck_snapshot on freshly-created system overlays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- internal/daemon/vm_lifecycle_steps.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/daemon/vm_lifecycle_steps.go b/internal/daemon/vm_lifecycle_steps.go index f932a15..6fcf27f 100644 --- a/internal/daemon/vm_lifecycle_steps.go +++ b/internal/daemon/vm_lifecycle_steps.go @@ -237,12 +237,18 @@ func (s *VMService) buildStartSteps(op *operationLog, sc *startContext) []startS }, }, { - // See the comment in the prior inline version: stale - // bitmaps from a reused COW make e2cp/e2rm refuse to - // touch the snapshot. e2fsck -fy is a no-op on a fresh - // snapshot. Exit codes 0 + 1 are both "ok" here. + // e2fsck protects against stale bitmaps in a COW reused + // from a prior aborted start — without it, e2cp/e2rm in + // patch_root_overlay refuse to touch the snapshot. On a + // 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", run: func(ctx context.Context, sc *startContext) error { + if sc.systemOverlayCreated { + return nil + } return s.privOps().FsckSnapshot(ctx, sc.live.DMDev) }, },