Loading fs_mgr/fs_mgr.cpp +8 −2 Original line number Original line Diff line number Diff line Loading @@ -96,6 +96,7 @@ using android::base::Basename; using android::base::Basename; using android::base::GetBoolProperty; using android::base::GetBoolProperty; using android::base::GetUintProperty; using android::base::Readlink; using android::base::Readlink; using android::base::Realpath; using android::base::Realpath; using android::base::SetProperty; using android::base::SetProperty; Loading Loading @@ -1566,11 +1567,16 @@ int fs_mgr_umount_all(android::fs_mgr::Fstab* fstab) { return ret; return ret; } } static std::chrono::milliseconds GetMillisProperty(const std::string& name, std::chrono::milliseconds default_value) { auto value = GetUintProperty(name, static_cast<uint64_t>(default_value.count())); return std::chrono::milliseconds(std::move(value)); } static bool fs_mgr_unmount_all_data_mounts(const std::string& block_device) { static bool fs_mgr_unmount_all_data_mounts(const std::string& block_device) { LINFO << __FUNCTION__ << "(): about to umount everything on top of " << block_device; LINFO << __FUNCTION__ << "(): about to umount everything on top of " << block_device; Timer t; Timer t; // TODO(b/135984674): should be configured via a read-only property. auto timeout = GetMillisProperty("init.userspace_reboot.userdata_remount.timeoutmillis", 5s); std::chrono::milliseconds timeout = 5s; while (true) { while (true) { bool umount_done = true; bool umount_done = true; Fstab proc_mounts; Fstab proc_mounts; Loading init/reboot.cpp +18 −8 Original line number Original line Diff line number Diff line Loading @@ -72,6 +72,7 @@ using namespace std::literals; using android::base::boot_clock; using android::base::boot_clock; using android::base::GetBoolProperty; using android::base::GetBoolProperty; using android::base::GetUintProperty; using android::base::SetProperty; using android::base::SetProperty; using android::base::Split; using android::base::Split; using android::base::Timer; using android::base::Timer; Loading Loading @@ -732,6 +733,12 @@ static Result<void> UnmountAllApexes() { return Error() << "'/system/bin/apexd --unmount-all' failed : " << status; return Error() << "'/system/bin/apexd --unmount-all' failed : " << status; } } static std::chrono::milliseconds GetMillisProperty(const std::string& name, std::chrono::milliseconds default_value) { auto value = GetUintProperty(name, static_cast<uint64_t>(default_value.count())); return std::chrono::milliseconds(std::move(value)); } static Result<void> DoUserspaceReboot() { static Result<void> DoUserspaceReboot() { LOG(INFO) << "Userspace reboot initiated"; LOG(INFO) << "Userspace reboot initiated"; auto guard = android::base::make_scope_guard([] { auto guard = android::base::make_scope_guard([] { Loading Loading @@ -769,10 +776,13 @@ static Result<void> DoUserspaceReboot() { sync(); sync(); LOG(INFO) << "sync() took " << sync_timer; LOG(INFO) << "sync() took " << sync_timer; } } // TODO(b/135984674): do we need shutdown animation for userspace reboot? auto sigterm_timeout = GetMillisProperty("init.userspace_reboot.sigterm.timeoutmillis", 5s); // TODO(b/135984674): control userspace timeout via read-only property? auto sigkill_timeout = GetMillisProperty("init.userspace_reboot.sigkill.timeoutmillis", 10s); StopServicesAndLogViolations(stop_first, 10s, true /* SIGTERM */); LOG(INFO) << "Timeout to terminate services : " << sigterm_timeout.count() << "ms" if (int r = StopServicesAndLogViolations(stop_first, 20s, false /* SIGKILL */); r > 0) { << "Timeout to kill services: " << sigkill_timeout.count() << "ms"; StopServicesAndLogViolations(stop_first, sigterm_timeout, true /* SIGTERM */); if (int r = StopServicesAndLogViolations(stop_first, sigkill_timeout, false /* SIGKILL */); r > 0) { // TODO(b/135984674): store information about offending services for debugging. // TODO(b/135984674): store information about offending services for debugging. return Error() << r << " post-data services are still running"; return Error() << r << " post-data services are still running"; } } Loading @@ -782,8 +792,8 @@ static Result<void> DoUserspaceReboot() { if (auto result = CallVdc("volume", "reset"); !result.ok()) { if (auto result = CallVdc("volume", "reset"); !result.ok()) { return result; return result; } } if (int r = StopServicesAndLogViolations(GetDebuggingServices(true /* only_post_data */), 5s, if (int r = StopServicesAndLogViolations(GetDebuggingServices(true /* only_post_data */), false /* SIGKILL */); sigkill_timeout, false /* SIGKILL */); r > 0) { r > 0) { // TODO(b/135984674): store information about offending services for debugging. // TODO(b/135984674): store information about offending services for debugging. return Error() << r << " debugging services are still running"; return Error() << r << " debugging services are still running"; Loading Loading @@ -827,8 +837,8 @@ static void UserspaceRebootWatchdogThread() { return; return; } } LOG(INFO) << "Starting userspace reboot watchdog"; LOG(INFO) << "Starting userspace reboot watchdog"; // TODO(b/135984674): this should be configured via a read-only sysprop. auto timeout = GetMillisProperty("init.userspace_reboot.watchdog.timeoutmillis", 5min); std::chrono::milliseconds timeout = 60s; LOG(INFO) << "UserspaceRebootWatchdog timeout: " << timeout.count() << "ms"; if (!WaitForProperty("sys.boot_completed", "1", timeout)) { if (!WaitForProperty("sys.boot_completed", "1", timeout)) { LOG(ERROR) << "Failed to boot in " << timeout.count() << "ms. Switching to full reboot"; LOG(ERROR) << "Failed to boot in " << timeout.count() << "ms. Switching to full reboot"; // In this case device is in a boot loop. Only way to recover is to do dirty reboot. // In this case device is in a boot loop. Only way to recover is to do dirty reboot. Loading Loading
fs_mgr/fs_mgr.cpp +8 −2 Original line number Original line Diff line number Diff line Loading @@ -96,6 +96,7 @@ using android::base::Basename; using android::base::Basename; using android::base::GetBoolProperty; using android::base::GetBoolProperty; using android::base::GetUintProperty; using android::base::Readlink; using android::base::Readlink; using android::base::Realpath; using android::base::Realpath; using android::base::SetProperty; using android::base::SetProperty; Loading Loading @@ -1566,11 +1567,16 @@ int fs_mgr_umount_all(android::fs_mgr::Fstab* fstab) { return ret; return ret; } } static std::chrono::milliseconds GetMillisProperty(const std::string& name, std::chrono::milliseconds default_value) { auto value = GetUintProperty(name, static_cast<uint64_t>(default_value.count())); return std::chrono::milliseconds(std::move(value)); } static bool fs_mgr_unmount_all_data_mounts(const std::string& block_device) { static bool fs_mgr_unmount_all_data_mounts(const std::string& block_device) { LINFO << __FUNCTION__ << "(): about to umount everything on top of " << block_device; LINFO << __FUNCTION__ << "(): about to umount everything on top of " << block_device; Timer t; Timer t; // TODO(b/135984674): should be configured via a read-only property. auto timeout = GetMillisProperty("init.userspace_reboot.userdata_remount.timeoutmillis", 5s); std::chrono::milliseconds timeout = 5s; while (true) { while (true) { bool umount_done = true; bool umount_done = true; Fstab proc_mounts; Fstab proc_mounts; Loading
init/reboot.cpp +18 −8 Original line number Original line Diff line number Diff line Loading @@ -72,6 +72,7 @@ using namespace std::literals; using android::base::boot_clock; using android::base::boot_clock; using android::base::GetBoolProperty; using android::base::GetBoolProperty; using android::base::GetUintProperty; using android::base::SetProperty; using android::base::SetProperty; using android::base::Split; using android::base::Split; using android::base::Timer; using android::base::Timer; Loading Loading @@ -732,6 +733,12 @@ static Result<void> UnmountAllApexes() { return Error() << "'/system/bin/apexd --unmount-all' failed : " << status; return Error() << "'/system/bin/apexd --unmount-all' failed : " << status; } } static std::chrono::milliseconds GetMillisProperty(const std::string& name, std::chrono::milliseconds default_value) { auto value = GetUintProperty(name, static_cast<uint64_t>(default_value.count())); return std::chrono::milliseconds(std::move(value)); } static Result<void> DoUserspaceReboot() { static Result<void> DoUserspaceReboot() { LOG(INFO) << "Userspace reboot initiated"; LOG(INFO) << "Userspace reboot initiated"; auto guard = android::base::make_scope_guard([] { auto guard = android::base::make_scope_guard([] { Loading Loading @@ -769,10 +776,13 @@ static Result<void> DoUserspaceReboot() { sync(); sync(); LOG(INFO) << "sync() took " << sync_timer; LOG(INFO) << "sync() took " << sync_timer; } } // TODO(b/135984674): do we need shutdown animation for userspace reboot? auto sigterm_timeout = GetMillisProperty("init.userspace_reboot.sigterm.timeoutmillis", 5s); // TODO(b/135984674): control userspace timeout via read-only property? auto sigkill_timeout = GetMillisProperty("init.userspace_reboot.sigkill.timeoutmillis", 10s); StopServicesAndLogViolations(stop_first, 10s, true /* SIGTERM */); LOG(INFO) << "Timeout to terminate services : " << sigterm_timeout.count() << "ms" if (int r = StopServicesAndLogViolations(stop_first, 20s, false /* SIGKILL */); r > 0) { << "Timeout to kill services: " << sigkill_timeout.count() << "ms"; StopServicesAndLogViolations(stop_first, sigterm_timeout, true /* SIGTERM */); if (int r = StopServicesAndLogViolations(stop_first, sigkill_timeout, false /* SIGKILL */); r > 0) { // TODO(b/135984674): store information about offending services for debugging. // TODO(b/135984674): store information about offending services for debugging. return Error() << r << " post-data services are still running"; return Error() << r << " post-data services are still running"; } } Loading @@ -782,8 +792,8 @@ static Result<void> DoUserspaceReboot() { if (auto result = CallVdc("volume", "reset"); !result.ok()) { if (auto result = CallVdc("volume", "reset"); !result.ok()) { return result; return result; } } if (int r = StopServicesAndLogViolations(GetDebuggingServices(true /* only_post_data */), 5s, if (int r = StopServicesAndLogViolations(GetDebuggingServices(true /* only_post_data */), false /* SIGKILL */); sigkill_timeout, false /* SIGKILL */); r > 0) { r > 0) { // TODO(b/135984674): store information about offending services for debugging. // TODO(b/135984674): store information about offending services for debugging. return Error() << r << " debugging services are still running"; return Error() << r << " debugging services are still running"; Loading Loading @@ -827,8 +837,8 @@ static void UserspaceRebootWatchdogThread() { return; return; } } LOG(INFO) << "Starting userspace reboot watchdog"; LOG(INFO) << "Starting userspace reboot watchdog"; // TODO(b/135984674): this should be configured via a read-only sysprop. auto timeout = GetMillisProperty("init.userspace_reboot.watchdog.timeoutmillis", 5min); std::chrono::milliseconds timeout = 60s; LOG(INFO) << "UserspaceRebootWatchdog timeout: " << timeout.count() << "ms"; if (!WaitForProperty("sys.boot_completed", "1", timeout)) { if (!WaitForProperty("sys.boot_completed", "1", timeout)) { LOG(ERROR) << "Failed to boot in " << timeout.count() << "ms. Switching to full reboot"; LOG(ERROR) << "Failed to boot in " << timeout.count() << "ms. Switching to full reboot"; // In this case device is in a boot loop. Only way to recover is to do dirty reboot. // In this case device is in a boot loop. Only way to recover is to do dirty reboot. Loading