cetrafs
How-to guideTask-oriented

Configure VM disks for cetrafs

Use raw images, cache=none, aio=threads, no preallocation and discard=on for VM disks on cetrafs, and see what each setting is worth.

These settings come from measurements on a Proxmox VE 7.0.14 cluster on HPE 3PAR storage over 32 Gb FC. They were taken on the same volume at the same time, with sequential 1 MiB O_DIRECT writes:

PathThroughput
Host writing straight to cetrafs550–600 MB/s
Guest, raw, aio=io_uring350 MB/s
Guest, raw, aio=threads~500 MB/s
Guest, qcow2, aio=io_uring90 MB/s
Guest, qcow2, aio=threads~400 MB/s

The short version

qm set <vmid> --scsi0 <storage>:<vmid>/<disk>,iothread=1,aio=threads,discard=on
  • Format: raw
  • Cache: none (cache=none, which is O_DIRECT)
  • Async IO: threads
  • Discard: on, so a guest’s TRIM frees space
  • Preallocation: off
  • IO thread: on, with the VirtIO SCSI single controller

Set aio=threads

Proxmox defaults to aio=io_uring when the kernel supports it. On this stack (pve 7.0.14, direct I/O) that costs about 30% on raw images and more than 4× on qcow2. The host’s own throughput is the same in every case, so the gap is in qemu’s I/O submission: cetrafs doesn’t advertise non-blocking direct I/O, so io_uring hands every request to a worker thread.

In the web UI: VM → Hardware → Hard Disk → Edit → Advanced → Async IO: threads.

Prefer raw images

qcow2 allocates in 64 KiB clusters and scatters them, so its backing file fragments badly. Under random guest I/O, a 32 GiB qcow2 image reached 28,659 extents; an 8 GiB raw image had 16. Every extent is metadata the filesystem has to store, look up and journal. The defragmenter can repair it, but a raw image with a handful of extents doesn’t need it.

If you must use qcow2, create it with 1 MiB clusters. That makes the L2 tables 16× smaller, so qemu’s default L2 cache covers the whole image, and cuts fragmentation by about the same factor:

qemu-img create -f qcow2 -o cluster_size=1M /mnt/cetra/images/<vmid>/vm-<vmid>-disk-0.qcow2 32G

Use cache=none

cache=none is Proxmox’s default for shared storage, the path cetrafs is built for, and the one the live-migration handoff is tested with. cache=writeback and cache=writethrough work on one node, but they put the host page cache between the guest and the shared LUN; use cache=none on any VM that migrates.

Turn preallocation off

Preallocation works, but it is slower for no benefit here. Preallocated space is made of uninitialized extents: the blocks are reserved and read back as zeroes, and the first write into each region has to mark it written, which changes the extent tree. With preallocation off, the allocator lays down long contiguous runs on first write instead: 16 extents for an 8 GiB image.

In the Proxmox storage config (/etc/pve/storage.cfg), set it for the whole cetrafs storage. With the storage plugin, run pvesm set <storage> --preallocation off, or edit its entry:

cetrafs: san1
    path /mnt/pve/san1
    base san-iscsi:0.0.1.scsi-36001405abc...
    content images,rootdir
    preallocation off

For a volume you mount yourself and register as directory storage:

dir: cetrafs
    path /mnt/cetra
    content images,rootdir
    shared 1
    is_mountpoint yes
    preallocation off

Turn discard on

With discard=on, a guest’s TRIM reaches the image as hole punches, and its write-zeroes requests as ZERO_RANGE, which cetrafs performs in place. The freed space goes back to the volume, and from there to a thin LUN. Proxmox defaults to discard=ignore. The guest has to send TRIM too: fstrim or its own discard mount option. See Return free space to a thin LUN.

Benchmark with detect_zeroes off

With detect_zeroes on, qemu drops all-zero writes entirely. A dd if=/dev/zero inside the guest then measures qemu’s zero detection rather than the storage: it returns at once, then stalls. That looks exactly like a filesystem fault and isn’t one. Benchmark with real data (/dev/urandom written to a file first) or with detect_zeroes off.

Last updated