vold: Reduce total number of attempts to unmount tmpfs

Reducing the total number of attempts to unmount tmpfs
filesyetem from 200 to 20, to align with AOSP branch.

To fix testTombStone CTS testcase failure, unmounting
tmpfs of /data for PERF case as well.

Test:
com.android.server.cts.ErrorsTest#testTombstone

CRs-Fixed: 2854346
Change-Id: Ia04d7ee8170d412b7435241397cbf58d6569b7ad
Signed-off-by: Phanindra Babu Pabba <pabba@codeaurora.org>
diff --git a/cryptfs.cpp b/cryptfs.cpp
index 0d1ceec..ad9b8e1 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -1836,7 +1836,7 @@
 
     // 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++) {
@@ -1860,10 +1860,10 @@
         // 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 == 20) {
+        if (i == 2) {
             SLOGW("sending SIGTERM to processes with open files\n");
             android::vold::KillProcessesWithOpenFiles(mountpoint, SIGTERM);
-        } else if (i >= 30) {
+        } else if (i >= 3) {
             SLOGW("sending SIGKILL to processes with open files\n");
             android::vold::KillProcessesWithOpenFiles(mountpoint, SIGKILL);
         }
@@ -2011,7 +2011,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", "");
@@ -2019,9 +2018,8 @@
         SLOGE("fs_crypto_blkdev not set\n");
         return -1;
     }
-
-    if (!(rc = wait_and_unmount(DATA_MNT_POINT))) {
 #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.
@@ -2109,9 +2107,7 @@
 
         /* Give it a few moments to get started */
         sleep(1);
-#ifndef CONFIG_HW_DISK_ENCRYPT_PERF
     }
-#endif
 
     if (rc == 0) {
         restart_successful = 1;
@@ -2754,31 +2750,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);
-        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 (!rebootEncryption) {