You cannot always stop the export: it is needed, just not during shop hours. You can tell it to give way on the disk to others.
Requests to the disk are queued by the kernel's I/O scheduler; for vda it is mq-deadline (cat /sys/block/vda/queue/scheduler). It takes into account the I/O class of a process, which the ionice command sets:
| Class | When the process gets the disk |
|---|---|
| realtime (1) | before everyone; only root sets it |
| best-effort (2) | on equal terms, the usual class |
| idle (3) | when nobody else needs the disk |
ionice -p <PID> shows the class of a process; none: prio 0 means no class is set and the process works as best-effort. sudo ionice -c3 -p <PID> moves a running process to idle until it ends. A new process of the service gets its class from the unit: the IOSchedulingClass=idle line in the [Service] section goes into a drop-in, like LimitNOFILE in the lesson on limits.
Changing the class will not lower wa: the disk is still busy. The class decides whose request goes first when several processes are waiting for the disk.
You moved the export process to idle with sudo ionice -c3 -p <PID>, and at night the service restarted. What will ionice -p show for its new process?
-
root sets realtime explicitly. By default a process gets
none: prio 0and works as best-effort. -
ionice changes the class of one process. systemd starts the new process, and it takes the class from the unit: without IOSchedulingClass it is
none: prio 0.
The class belongs to a process, and the service's new process takes it from the unit. The unit sets no class, so ionice -p shows none: prio 0. To make the class survive a restart, you write it into the unit as IOSchedulingClass=idle.
Key points
-
The I/O class decides whose disk request goes first; without a class a process shows
none: prio 0— the usual best-effort. -
sudo ionice -c3 -p <PID>moves a running process to idle until it ends. -
To make the class survive a service restart, set it in the unit:
IOSchedulingClass=idle.