diff --git a/scripts/tests/deploy/utils/filesystem/docker_dataroot.sh b/scripts/tests/deploy/utils/filesystem/docker_dataroot.sh index f3759350d4..19b45842ed 100755 --- a/scripts/tests/deploy/utils/filesystem/docker_dataroot.sh +++ b/scripts/tests/deploy/utils/filesystem/docker_dataroot.sh @@ -281,7 +281,7 @@ while [ -z "${LOOP}" ] && [ "${attempt}" -lt 16 ]; do if [ -n "${candidate}" ] && [ ! -b "${candidate}" ]; then mknod "${candidate}" b 7 "${candidate#/dev/loop}" 2>/dev/null || candidate="" fi - if attached="$(losetup --find --show "${IMAGE}" 2>/dev/null)"; then + if attached="$(losetup --direct-io=on --find --show "${IMAGE}" 2>/dev/null)"; then LOOP="${attached}" fi done diff --git a/tests/unit/python/scripts/tests/deploy/utils/filesystem/test_docker_dataroot.py b/tests/unit/python/scripts/tests/deploy/utils/filesystem/test_docker_dataroot.py index 2a2aa707e4..154227d6c9 100644 --- a/tests/unit/python/scripts/tests/deploy/utils/filesystem/test_docker_dataroot.py +++ b/tests/unit/python/scripts/tests/deploy/utils/filesystem/test_docker_dataroot.py @@ -122,5 +122,17 @@ class TestDockerDatarootLoopMount(unittest.TestCase): self.assertIn(("-o", option), list(pairwise(mounts[0]))) +class TestDockerDatarootLoopAttach(unittest.TestCase): + def test_the_loop_bypasses_the_page_cache_of_its_backing_image(self) -> None: + for fstype in (*DISCARD, "zfs"): + with self.subTest(fstype=fstype): + _, calls = apply(fstype) + attaches = [ + argv for argv in calls if argv[0] == "losetup" and "--show" in argv + ] + self.assertEqual(len(attaches), 1, calls) + self.assertIn("--direct-io=on", attaches[0]) + + if __name__ == "__main__": unittest.main()