8000
Skip to content

Storage: Fix ZFS zvol activation race when mounting a temporary XFS snapshot for export#17162

Merged
tomponline merged 2 commits intocanonical:mainfrom
tomponline:tp-zfs-race
Dec 4, 2025
Merged

Storage: Fix ZFS zvol activation race when mounting a temporary XFS snapshot for export#17162
tomponline merged 2 commits intocanonical:mainfrom
tomponline:tp-zfs-race

Conversation

@tomponline
Copy link
Copy Markdown
Member
@tomponline tomponline commented Dec 4, 2025

Fixes errors like:

lxc export c1
Error: Create backup: Backup create: Could not locate a zvol for zfs/containers/c1_snap0.lxdtmp

Activated ZFS volume dev=lxdtest-tev/containers/c4_snap0.lxdtmp driver=zfs pool=lxdtest-tev
Error: Create backup: Backup create: Error walking file during export: "/tmp/lxd-test.tmp.HPkQ/tev/storage-pools/lxdtest-tev/containers-snapshots/c4/snap0/backup.yaml": lstat /tmp/lxd-test.tmp.HPkQ/tev/storage-pools/lxdtest-tev/containers-snapshots/c4/snap0/backup.yaml: input/output error

…temporary volume in mountVolumeSnapshot

Otherwise it won't be readable from the caller.

This was causing intermittent I/O failures doing `lxc export` when using zfs.block_mode with xfs.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
…mDataset in mountVolumeSnapshot

This fixes a race where LXD was not waiting long enough for the zvol to appear after activating it.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
@tomponline tomponline self-assigned this Dec 4, 2025
@simondeziel simondeziel requested a review from Copilot December 4, 2025 14:57
Copy link
Copy Markdown
Member
@simondeziel simondeziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Copy link
Copy Markdown
Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a race condition that occurs when mounting temporary XFS snapshots for export in ZFS storage. The issue arises when the ZFS zvol block device hasn't yet appeared in /dev/ after being created, causing subsequent operations to fail.

Key Changes:

  • Replaced immediate call to getVolumeDiskPathFromDataset with a retry-capable tryGetVolumeDiskPathFromDataset that polls for the zvol device with a 30-second timeout
  • Removed the deferred volmode=none cleanup that could fail if the device hadn't appeared yet

Comment thread lxd/storage/drivers/driver_zfs_volumes.go
@tomponline tomponline merged commit 799d637 into canonical:main Dec 4, 2025
76 checks passed
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.

3 participants

0