From 0f04f72c2de2f5c42e62f23306bc106dddcdabb1 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Mon, 25 Sep 2017 10:55:39 -0700 Subject: [PATCH] init/reboot: call MNT_FORCE at the last umount(2) The last one will avoid errors=panic in ext4. Test: Build Bug: 63981945 Bug: 65481582 Change-Id: I9c86afcce441767e24fc43668ab1ff6230155a9f Signed-off-by: Jaegeuk Kim --- init/reboot.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/init/reboot.cpp b/init/reboot.cpp index d06dcc559..a4a20f343 100644 --- a/init/reboot.cpp +++ b/init/reboot.cpp @@ -86,8 +86,8 @@ class MountEntry { mnt_type_(entry.mnt_type), mnt_opts_(entry.mnt_opts) {} - bool Umount() { - int r = umount2(mnt_dir_.c_str(), 0); + bool Umount(bool force) { + int r = umount2(mnt_dir_.c_str(), force ? MNT_FORCE : 0); if (r == 0) { LOG(INFO) << "umounted " << mnt_fsname_ << ":" << mnt_dir_ << " opts " << mnt_opts_; return true; @@ -280,14 +280,15 @@ static UmountStat UmountPartitions(std::chrono::milliseconds timeout) { bool unmount_done = true; if (emulated_devices.size() > 0) { unmount_done = std::all_of(emulated_devices.begin(), emulated_devices.end(), - [](auto& entry) { return entry.Umount(); }); + [](auto& entry) { return entry.Umount(false); }); if (unmount_done) { sync(); } } - unmount_done = std::all_of(block_devices.begin(), block_devices.end(), - [](auto& entry) { return entry.Umount(); }) && - unmount_done; + unmount_done = + std::all_of(block_devices.begin(), block_devices.end(), + [&timeout](auto& entry) { return entry.Umount(timeout == 0ms); }) && + unmount_done; if (unmount_done) { return UMOUNT_STAT_SUCCESS; }