diff options
author | Sarthak Kukreti <sarthakkukreti@google.com> | 2019-06-04 16:00:09 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-20 06:10:37 +0000 |
commit | 43ee19eb29d9bee8f1f69f997b93089a30199365 (patch) | |
tree | 0993d22a047354812e3f953da2dbfbaf6c7ab1f8 | |
parent | 2078b13f65ccd31b45376b1599a1d50f976605f5 (diff) | |
download | platform_external_libbrillo-43ee19eb29d9bee8f1f69f997b93089a30199365.tar.gz platform_external_libbrillo-43ee19eb29d9bee8f1f69f997b93089a30199365.tar.bz2 platform_external_libbrillo-43ee19eb29d9bee8f1f69f997b93089a30199365.zip |
libbrillo: enable direct I/O for loop devices on kernels > 4.4
Add IOCTL call to set direct I/O unconditionally
for loop devices opened via libbrillo.
BUG=chromium:968826
TEST=losetup on caroline with 4.19 shows direct I/O enabled.
Change-Id: I1c5f838182328da7cb967a4f421531db7d115f30
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/1644363
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Sarthak Kukreti <sarthakkukreti@chromium.org>
Commit-Queue: Sarthak Kukreti <sarthakkukreti@chromium.org>
Cr-Mirrored-From: https://chromium.googlesource.com/chromiumos/platform2
Cr-Mirrored-Commit: 18ae266de8530897d3e18fcf176a2a4308aa4620
-rw-r--r-- | brillo/blkdev_utils/loop_device.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/brillo/blkdev_utils/loop_device.cc b/brillo/blkdev_utils/loop_device.cc index 0ba485a..13c476c 100644 --- a/brillo/blkdev_utils/loop_device.cc +++ b/brillo/blkdev_utils/loop_device.cc @@ -5,6 +5,7 @@ #include <brillo/blkdev_utils/loop_device.h> #include <fcntl.h> +#include <linux/loop.h> #include <linux/major.h> #include <sys/ioctl.h> #include <sys/types.h> @@ -210,6 +211,11 @@ std::unique_ptr<LoopDevice> LoopDeviceManager::AttachDeviceToFile( return CreateLoopDevice(-1, base::FilePath()); } + // Set direct I/O mode for the backing file for the loop device, if supported. + if (loop_ioctl_.Run(CreateDevicePath(device_number), LOOP_SET_DIRECT_IO, 1, + kLoopDeviceIoctlFlags) != 0) + PLOG(WARNING) << "Direct I/O mode is not supported."; + // All steps of setting up the loop device succeeded. return CreateLoopDevice(device_number, backing_file); } |