10.27. Switching Ploop I/O Engines

A ploop I/O engine is a driver that maps block device requests (REQ_XXX) to operations on an image file.

Virtuozzo Hybrid Server supports two ploop I/O engines: io_kaio and io_direct. The former, io_kaio, is used by default for virtual disk images on both local ext4 file systems and Virtuozzo Storage FUSE file systems. The latter, io_direct, is deprecated and will be dropped in the future versions of Virtuozzo Hybrid Server.

The advantage of io_kaio compared to io_direct is in the better usage of storage space on the host file system achieved by the default discard granularity that is a factor of 4 KB versus the default 1 MB of io_direct. In other words, by default io_kaio makes it possible to free up blocks smaller than 1 MB from mounted virtual disks.

The disadvantage of io_kaio compared to io_direct is in the increasing defragmentation of host physical disks. It reduces disk write speeds, as each request needs to be split into smaller fragments. It also leads to higher memory usage, because fragment data is cached, and the more fragments, the more memory is needed for the cache. This disadvantage affects HDDs much more than SSDs.

For the io_kaio ploop engine, you can manually switch the discard granularity between 4 KB and 1 MB for ploop images on both local ext4 and Virtuozzo Storage FUSE file systems. In addition to the pros and cons of each discard granularity mentioned early in this section, it is recommended to use 4 KB for ploop images residing on SSD drives and 1 MB for ploops on HDD drives.

To change the discard granularity:

  1. Set the desired value in /etc/vz/ploop.conf. For example:

    EXT4_DISCARD_GRANULARITY=4096
    FUSE_DISCARD_GRANULARITY=1048576
    

    Warning

    Only use the values 4096 and 1048576.

  2. As this parameter is read at ploop mount, re-mount the ploop images, e.g., by restarting the virtual environments.

    The newly created and started virtual environments will use the new discard granularity as well.

The discard granularity currently used by a mounted ploop image is reported in /sys/block/ploop<N>/ptune/discard_granularity. For example:

# cat /sys/block/ploop64959/ptune/discard_granularity
1048576

If you need to switch to the io_direct ploop engine, do the following:

  1. Set USE_KAIO_FOR_EXT4=no in /etc/vz/ploop.conf.

  2. As this parameter is read at ploop mount, re-mount the ploop images, e.g., by restarting the virtual environments.

    The newly created and started virtual environments will use the new ploop I/O engine as well.

To switch back to io_kaio, set USE_KAIO_FOR_EXT4=yes in /etc/vz/ploop.conf and remount the ploop images.

The engine currently used by a mounted ploop image is reported in /sys/block/ploop<N>/pdelta/<highest_number>/io. For example:

# cat /sys/block/ploop61324/pdelta/0/io
kaio