OSDN Git Service

Always unmount data and obb directory that mounted
authorRicky Wai <rickywai@google.com>
Wed, 5 May 2021 14:43:45 +0000 (14:43 +0000)
committerRicky Wai <rickywai@google.com>
Wed, 5 May 2021 14:44:16 +0000 (14:44 +0000)
Otherwise, when system removes user's volume, it will hang
as there are mounts (obb and data mounts) still remain mounted in system.

Bug: 187122943
Test: atest UserLifecycleTests#managedProfileUnlock_stopped, it's not blocked anymore

Change-Id: Ic37985f98e6cbfe4fa38b981d3332c4dfc40c5b8

model/EmulatedVolume.cpp

index 09a75b5..6f21ff8 100644 (file)
@@ -194,27 +194,28 @@ status_t EmulatedVolume::unmountFuseBindMounts() {
         // Here we assume obb/data dirs is mounted as tmpfs, then it must be caused by
         // app data isolation.
         KillProcessesWithTmpfsMountPrefix(appObbDir);
-    } else {
-        std::string androidDataTarget(
-                StringPrintf("/mnt/user/%d/%s/%d/Android/data", userId, label.c_str(), userId));
+    }
 
-        LOG(INFO) << "Unmounting " << androidDataTarget;
-        auto status = UnmountTree(androidDataTarget);
-        if (status != OK) {
-            return status;
-        }
-        LOG(INFO) << "Unmounted " << androidDataTarget;
+    // Always unmount data and obb dirs as they are mounted to lowerfs for speeding up access.
+    std::string androidDataTarget(
+            StringPrintf("/mnt/user/%d/%s/%d/Android/data", userId, label.c_str(), userId));
+
+    LOG(INFO) << "Unmounting " << androidDataTarget;
+    auto status = UnmountTree(androidDataTarget);
+    if (status != OK) {
+        return status;
+    }
+    LOG(INFO) << "Unmounted " << androidDataTarget;
 
-        std::string androidObbTarget(
-                StringPrintf("/mnt/user/%d/%s/%d/Android/obb", userId, label.c_str(), userId));
+    std::string androidObbTarget(
+            StringPrintf("/mnt/user/%d/%s/%d/Android/obb", userId, label.c_str(), userId));
 
-        LOG(INFO) << "Unmounting " << androidObbTarget;
-        status = UnmountTree(androidObbTarget);
-        if (status != OK) {
-            return status;
-        }
-        LOG(INFO) << "Unmounted " << androidObbTarget;
+    LOG(INFO) << "Unmounting " << androidObbTarget;
+    status = UnmountTree(androidObbTarget);
+    if (status != OK) {
+        return status;
     }
+    LOG(INFO) << "Unmounted " << androidObbTarget;
     return OK;
 }