summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Sharkey <jsharkey@google.com> 2016-03-18 17:44:54 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-03-18 17:44:55 +0000
commit910e7726b3c0e6cc62b3e3c8d8fcafd372d70f44 (patch)
treef6530a09b5c8ef62d5355423b9c2a42217a84a6d
parent2b75d9c171731fadce321f7419d041239449da07 (diff)
parent885b742bb66660947d8335e9a4f5a4eef2e45ff9 (diff)
Merge "Changes of root storage space unmounting time on Zygote Process" into nyc-dev
-rw-r--r--core/java/com/android/internal/os/Zygote.java6
-rw-r--r--core/java/com/android/internal/os/ZygoteInit.java3
-rw-r--r--core/jni/com_android_internal_os_Zygote.cpp17
3 files changed, 22 insertions, 4 deletions
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index 919254a36a76..66cc97598ae8 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -149,6 +149,12 @@ public final class Zygote {
native private static int nativeForkSystemServer(int uid, int gid, int[] gids, int debugFlags,
int[][] rlimits, long permittedCapabilities, long effectiveCapabilities);
+ /**
+ * Zygote unmount storage space on initializing.
+ * This method is called once.
+ */
+ native protected static void nativeUnmountStorageOnInit();
+
private static void callPostForkChildHooks(int debugFlags, boolean isSystemServer,
String instructionSet) {
VM_HOOKS.postForkChild(debugFlags, isSystemServer, instructionSet);
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index 3abea26ab42b..b658f87a9689 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -643,6 +643,9 @@ public class ZygoteInit {
// Zygote.
Trace.setTracingEnabled(false);
+ // Zygote process unmounts root storage spaces.
+ Zygote.nativeUnmountStorageOnInit();
+
if (startSystemServer) {
startSystemServer(abiList, socketName);
}
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index 612f4dfd1505..3f4b2a61321b 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -302,9 +302,6 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode,
return false;
}
- // Unmount storage provided by root namespace and mount requested view
- UnmountTree("/storage");
-
String8 storageSource;
if (mount_mode == MOUNT_EXTERNAL_DEFAULT) {
storageSource = "/mnt/runtime/default";
@@ -667,12 +664,24 @@ static jint com_android_internal_os_Zygote_nativeForkSystemServer(
return pid;
}
+static void com_android_internal_os_Zygote_nativeUnmountStorageOnInit(JNIEnv* env, jclass) {
+ // Zygote process unmount root storage space initially before every child processes are forked.
+ // Every forked child processes (include SystemServer) only mount their own root storage space
+ // And no need unmount storage operation in MountEmulatedStorage method.
+ // Zygote process does not utilize root storage spaces and unshared its mount namespace from the ART.
+
+ UnmountTree("/storage");
+ return;
+}
+
static const JNINativeMethod gMethods[] = {
{ "nativeForkAndSpecialize",
"(II[II[[IILjava/lang/String;Ljava/lang/String;[ILjava/lang/String;Ljava/lang/String;)I",
(void *) com_android_internal_os_Zygote_nativeForkAndSpecialize },
{ "nativeForkSystemServer", "(II[II[[IJJ)I",
- (void *) com_android_internal_os_Zygote_nativeForkSystemServer }
+ (void *) com_android_internal_os_Zygote_nativeForkSystemServer },
+ { "nativeUnmountStorageOnInit", "()V",
+ (void *) com_android_internal_os_Zygote_nativeUnmountStorageOnInit }
};
int register_com_android_internal_os_Zygote(JNIEnv* env) {