Merge remote-tracking branch 'origin/sm7225_r_fp4' into fp4-r-rebase
Change-Id: Ib8765dd8e7321364c7e8026c1ab943445e3a88da
diff --git a/cryptfs.cpp b/cryptfs.cpp
index 5028829..d3cafe7 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -263,8 +263,6 @@
struct crypt_persist_entry persist_entry[0];
};
-static int wait_and_unmount(const char* mountpoint, bool kill);
-
typedef int (*kdf_func)(const char* passwd, const unsigned char* salt, unsigned char* ikey,
void* params);
@@ -1751,12 +1749,12 @@
}
}
-static int wait_and_unmount(const char* mountpoint, bool kill) {
+static int wait_and_unmount(const char* mountpoint) {
int i, err, rc;
// Subdirectory mount will cause a failure of umount.
ensure_subdirectory_unmounted(mountpoint);
-#define WAIT_UNMOUNT_COUNT 200
+#define WAIT_UNMOUNT_COUNT 20
/* Now umount the tmpfs filesystem */
for (i = 0; i < WAIT_UNMOUNT_COUNT; i++) {
@@ -1773,15 +1771,19 @@
err = errno;
- /* If allowed, be increasingly aggressive before the last 2 seconds */
- if (kill) {
- if (i == (WAIT_UNMOUNT_COUNT - 30)) {
- SLOGW("sending SIGHUP to processes with open files\n");
- android::vold::KillProcessesWithOpenFiles(mountpoint, SIGTERM);
- } else if (i == (WAIT_UNMOUNT_COUNT - 20)) {
- SLOGW("sending SIGKILL to processes with open files\n");
- android::vold::KillProcessesWithOpenFiles(mountpoint, SIGKILL);
- }
+ // If it's taking too long, kill the processes with open files.
+ //
+ // Originally this logic was only a fail-safe, but now it's relied on to
+ // kill certain processes that aren't stopped by init because they
+ // aren't in the main or late_start classes. So to avoid waiting for
+ // too long, we now are fairly aggressive in starting to kill processes.
+ static_assert(WAIT_UNMOUNT_COUNT >= 4);
+ if (i == 2) {
+ SLOGW("sending SIGTERM to processes with open files\n");
+ android::vold::KillProcessesWithOpenFiles(mountpoint, SIGTERM);
+ } else if (i >= 3) {
+ SLOGW("sending SIGKILL to processes with open files\n");
+ android::vold::KillProcessesWithOpenFiles(mountpoint, SIGKILL);
}
usleep(100000);
@@ -1927,7 +1929,6 @@
SLOGE("fs_crypto_blkdev not set\n");
return -1;
}
- if (!(rc = wait_and_unmount(DATA_MNT_POINT, true))) {
#endif
#else
crypto_blkdev = android::base::GetProperty("ro.crypto.fs_crypto_blkdev", "");
@@ -1935,9 +1936,8 @@
SLOGE("fs_crypto_blkdev not set\n");
return -1;
}
-
- if (!(rc = wait_and_unmount(DATA_MNT_POINT, true))) {
#endif
+ if (!(rc = wait_and_unmount(DATA_MNT_POINT))) {
/* If ro.crypto.readonly is set to 1, mount the decrypted
* filesystem readonly. This is used when /data is mounted by
* recovery mode.
@@ -2025,9 +2025,7 @@
/* Give it a few moments to get started */
sleep(1);
-#ifndef CONFIG_HW_DISK_ENCRYPT_PERF
}
-#endif
if (rc == 0) {
restart_successful = 1;
@@ -2757,31 +2755,6 @@
fclose(breadcrumb);
}
- /* Do extra work for a better UX when doing the long inplace encryption */
- if (!onlyCreateHeader) {
- /* Now that /data is unmounted, we need to mount a tmpfs
- * /data, set a property saying we're doing inplace encryption,
- * and restart the framework.
- */
- wait_and_unmount(DATA_MNT_POINT, true);
- if (fs_mgr_do_tmpfs_mount(DATA_MNT_POINT)) {
- goto error_shutting_down;
- }
- /* Tells the framework that inplace encryption is starting */
- property_set("vold.encrypt_progress", "0");
-
- /* restart the framework. */
- /* Create necessary paths on /data */
- prep_data_fs();
-
- /* Ugh, shutting down the framework is not synchronous, so until it
- * can be fixed, this horrible hack will wait a moment for it all to
- * shut down before proceeding. Without it, some devices cannot
- * restart the graphics services.
- */
- sleep(2);
- }
-
/* Start the actual work of making an encrypted filesystem */
/* Initialize a crypt_mnt_ftr for the partition */
if (previously_encrypted_upto == 0 && !rebootEncryption) {