summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHuang Jianan <huangjianan@oppo.com>2021-09-18 20:17:06 +0800
committeralk3pInjection <webmaster@raspii.tech>2021-09-27 21:17:05 +0800
commitf60c1c33d6a91f2fa7bb6e52a4293eab8aeddc72 (patch)
tree8553264842be80c8c75f0f0ab3263c619c1d1284
parent179d99746c9ee0e8f71d82cf3009f2ab26c2b9be (diff)
apexd: fallback to buffered IO when filesystem doesn't support DIO
The new LOOP_CONFIGURE ioctl set LO_FLAGS_DIRECT_IO flag even when apex file opening failure with O_DIRECT flag, fix this. Bug: 200339094 Test: boot normal with EROFS system image after adb remount Signed-off-by: Huang Jianan <huangjianan@oppo.com> Change-Id: I55e63ebbba0c3a51c8c9640beb18209142b1fe90
-rw-r--r--apexd/apexd_loop.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/apexd/apexd_loop.cpp b/apexd/apexd_loop.cpp
index d97ab34..bfff51b 100644
--- a/apexd/apexd_loop.cpp
+++ b/apexd/apexd_loop.cpp
@@ -143,6 +143,7 @@ Result<void> configureLoopDevice(const int device_fd, const std::string& target,
const int32_t imageOffset,
const size_t imageSize) {
static bool useLoopConfigure;
+ static bool use_buffered_IO;
static std::once_flag onceFlag;
std::call_once(onceFlag, [&]() {
// LOOP_CONFIGURE is a new ioctl in Linux 5.8 (and backported in Android
@@ -178,6 +179,7 @@ Result<void> configureLoopDevice(const int device_fd, const std::string& target,
return Error(saved_errno) << "Failed to open " << target;
}
LOG(WARNING) << "Fallback to buffered I/O for " << target;
+ use_buffered_IO = true;
target_fd.reset(open(target.c_str(), O_RDONLY | O_CLOEXEC));
if (target_fd.get() == -1) {
return ErrnoError() << "Failed to open " << target;
@@ -193,7 +195,7 @@ Result<void> configureLoopDevice(const int device_fd, const std::string& target,
if (useLoopConfigure) {
struct loop_config config;
memset(&config, 0, sizeof(config));
- li.lo_flags |= LO_FLAGS_DIRECT_IO;
+ if (!use_buffered_IO) li.lo_flags |= LO_FLAGS_DIRECT_IO;
config.fd = target_fd.get();
config.info = li;
config.block_size = 4096;