Skip to content

Commit

Permalink
BACKPORT: Revert "neonvm/runner: treat guest-side disk flush requests…
Browse files Browse the repository at this point in the history
… as no-ops" (#694)

Reverts #628.

`cache=unsafe` means that we rely on the kernel page cache more, which
increases IO speed _most of the time_, but can have catastrophic results
if the node's free memory runs out with all of it taken up by page
cache.

ref https://neondb.slack.com/archives/C03TN5G758R/p1702585801270379?thread_ts=1702577770.752879
ref https://neondb.slack.com/archives/C03F5SM1N02/p1702571133926869?thread_ts=1702558673.445669
  • Loading branch information
sharnoff committed Dec 14, 2023
1 parent 8cf814b commit 5e754ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions neonvm/runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ func main() {
}

// disk details
qemuCmd = append(qemuCmd, "-drive", fmt.Sprintf("id=rootdisk,file=%s,if=virtio,media=disk,index=0,cache=unsafe", rootDiskPath))
qemuCmd = append(qemuCmd, "-drive", fmt.Sprintf("id=runtime,file=%s,if=virtio,media=cdrom,readonly=on,cache=unsafe", runtimeDiskPath))
qemuCmd = append(qemuCmd, "-drive", fmt.Sprintf("id=rootdisk,file=%s,if=virtio,media=disk,index=0,cache=none", rootDiskPath))
qemuCmd = append(qemuCmd, "-drive", fmt.Sprintf("id=runtime,file=%s,if=virtio,media=cdrom,readonly=on,cache=none", runtimeDiskPath))
for _, disk := range vmSpec.Disks {
switch {
case disk.EmptyDisk != nil:
Expand All @@ -579,15 +579,15 @@ func main() {
if disk.EmptyDisk.Discard {
discard = ",discard=unmap"
}
qemuCmd = append(qemuCmd, "-drive", fmt.Sprintf("id=%s,file=%s,if=virtio,media=disk,cache=unsafe%s", disk.Name, dPath, discard))
qemuCmd = append(qemuCmd, "-drive", fmt.Sprintf("id=%s,file=%s,if=virtio,media=disk,cache=none%s", disk.Name, dPath, discard))
case disk.ConfigMap != nil || disk.Secret != nil:
dPath := fmt.Sprintf("%s/%s.qcow2", mountedDiskPath, disk.Name)
mnt := fmt.Sprintf("/vm/mounts%s", disk.MountPath)
logger.Info("creating iso9660 image", zap.String("diskPath", dPath), zap.String("diskName", disk.Name), zap.String("mountPath", mnt))
if err := createISO9660FromPath(logger, disk.Name, dPath, mnt); err != nil {
logger.Fatal("Failed to create ISO9660 image", zap.Error(err))
}
qemuCmd = append(qemuCmd, "-drive", fmt.Sprintf("id=%s,file=%s,if=virtio,media=cdrom,cache=unsafe", disk.Name, dPath))
qemuCmd = append(qemuCmd, "-drive", fmt.Sprintf("id=%s,file=%s,if=virtio,media=cdrom,cache=none", disk.Name, dPath))
default:
// do nothing
}
Expand Down

0 comments on commit 5e754ec

Please sign in to comment.