Skip to content

Commit c12b0f6

Browse files
authored
Merge pull request #1729 from stgraber/main
incusd/storage: Don't use sparse writer on thick LVM
2 parents 61b6f3c + f7258c1 commit c12b0f6

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

internal/server/storage/drivers/driver_lvm.go

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func (d *lvm) Info() Info {
143143
MountedRoot: false,
144144
Buckets: !d.isRemote(),
145145
Deactivate: d.isRemote(),
146+
ZeroUnpack: !d.usesThinpool(),
146147
}
147148
}
148149

internal/server/storage/drivers/driver_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Info struct {
1919
IOUring bool // Whether the driver supports io_uring.
2020
MountedRoot bool // Whether the pool directory itself is a mount.
2121
Deactivate bool // Whether an unmount action is required prior to removing the pool.
22+
ZeroUnpack bool // Whether to write zeroes (no discard) during unpacking.
2223
}
2324

2425
// VolumeFiller provides a struct for filling a volume.

internal/server/storage/drivers/generic_vfs.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,12 @@ func genericVFSCreateVolumeFromMigration(d Driver, initVolume func(vol Volume) (
351351
d.Logger().Debug("Receiving block volume started", logger.Ctx{"volName": volName, "path": path})
352352
defer d.Logger().Debug("Receiving block volume stopped", logger.Ctx{"volName": volName, "path": path})
353353

354-
_, err = io.Copy(NewSparseFileWrapper(to), fromPipe)
354+
toPipe := io.Writer(to)
355+
if !d.Info().ZeroUnpack {
356+
toPipe = NewSparseFileWrapper(to)
357+
}
358+
359+
_, err = io.Copy(toPipe, fromPipe)
355360
if err != nil {
356361
return fmt.Errorf("Error copying from migration connection to %q: %w", path, err)
357362
}
@@ -827,8 +832,13 @@ func genericVFSBackupUnpack(d Driver, sysOS *sys.OS, vol Volume, snapshots []str
827832
}
828833

829834
// Copy the data.
835+
toPipe := io.Writer(to)
836+
if !d.Info().ZeroUnpack {
837+
toPipe = NewSparseFileWrapper(to)
838+
}
839+
830840
d.Logger().Debug(logMsg, logger.Ctx{"source": srcFile, "target": targetPath})
831-
_, err = io.Copy(NewSparseFileWrapper(to), tr)
841+
_, err = io.Copy(toPipe, tr)
832842
if err != nil {
833843
return err
834844
}

0 commit comments

Comments
 (0)