Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08791b8b authored by Omar Eissa's avatar Omar Eissa
Browse files

Add tracing points to StorageManagerService

The CL adds tracing points and sections to StorageManagerService which
should allow us to better understand the pain points in mounting flow at
device boot and user unlocking.

Bug: 251055582
Test: manual
Change-Id: Iaccf6f2a767afe13d02b38f2a286b5f0e3f3a6de
parent fc362ef1
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ import android.os.ServiceManager;
import android.os.ServiceSpecificException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.DiskInfo;
@@ -1180,6 +1181,7 @@ class StorageManagerService extends IStorageManager.Stub

    private void onUserUnlocking(int userId) {
        Slog.d(TAG, "onUserUnlocking " + userId);
        Trace.instant(Trace.TRACE_TAG_SYSTEM_SERVER, "SMS.onUserUnlocking: " + userId);

        if (userId != UserHandle.USER_SYSTEM) {
            // Check if this user shares media with another user
@@ -1466,6 +1468,8 @@ class StorageManagerService extends IStorageManager.Stub
        @Override
        public void onVolumeCreated(String volId, int type, String diskId, String partGuid,
                int userId) {
            Trace.instant(Trace.TRACE_TAG_SYSTEM_SERVER,
                    "SMS.onVolumeCreated: " + volId + ", " + userId);
            synchronized (mLock) {
                final DiskInfo disk = mDisks.get(diskId);
                final VolumeInfo vol = new VolumeInfo(volId, type, disk, partGuid);
@@ -2352,6 +2356,7 @@ class StorageManagerService extends IStorageManager.Stub

    private void mount(VolumeInfo vol) {
        try {
            Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "SMS.mount: " + vol.id);
            // TODO(b/135341433): Remove cautious logging when FUSE is stable
            Slog.i(TAG, "Mounting volume " + vol);
            extendWatchdogTimeout("#mount might be slow");
@@ -2363,6 +2368,8 @@ class StorageManagerService extends IStorageManager.Stub
                    vol.internalPath = internalPath;
                    ParcelFileDescriptor pfd = new ParcelFileDescriptor(fd);
                    try {
                        Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER,
                                "SMS.startFuseFileSystem: " + vol.id);
                        mStorageSessionController.onVolumeMount(pfd, vol);
                        return true;
                    } catch (ExternalStorageServiceException e) {
@@ -2375,6 +2382,7 @@ class StorageManagerService extends IStorageManager.Stub
                                TimeUnit.SECONDS.toMillis(nextResetSeconds));
                        return false;
                    } finally {
                        Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
                        try {
                            pfd.close();
                        } catch (Exception e) {
@@ -2386,6 +2394,8 @@ class StorageManagerService extends IStorageManager.Stub
            Slog.i(TAG, "Mounted volume " + vol);
        } catch (Exception e) {
            Slog.wtf(TAG, e);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
        }
    }