Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mount-utils: don't reread mountinfo on newer kernels
1. Background. Since the dawn of times mount-utils package tries to work around the bug in the Linux kernel, which results in occasional incomplete read of mountinfo entries (from either /proc/mounts or /proc/PID/mountinfo). The workaround used is to read the whole file twice and compare the two blobs. If they differ, try again. The kernel bug is manifesting when mountinfo read is performed concurrently with an unmount, and can easily be reproduced by running lots of mounts and unmounts in parallel with the code reading mountinfo. For one such reproducer, see https://github.com/kolyshkin/procfs-test. On a Kubernetes node with lots of short-lived containers, mounts and unmounts are quite frequent. This leads to the occasional bug, and surely results in much more re-reads of mountinfo, because the workaround assumes its content is more-or-less static. The good news is, this bug was finally fixed by kernel commit 9f6c61f96f2d97, which made its way into Linux 5.8. 2. The issue. The code still read every file at least twice, and up to 10 times. The chance of re-reading is higher if there is a mount or unmount going on at the same time. The result is higher system and kernel load, and degraded performance. 3. The fix. As the re-reading is not necessary for newer kernels, let's check the kernel version and skip the workaround if running Linux >= 5.8. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> Kubernetes-commit: b690450e8462841a2b5ed6dc79a4cc23d548ecc2
- Loading branch information