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

Commit 9756d75e authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Initial pass at storage benchmarks.

Offer an interface for Settings to invoke benchmarks on various
attached volumes.

Bug: 21172095
Change-Id: I847ddc87c58285457d1324be87f70ce10507accb
parent 0d838a0f
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -1004,6 +1004,22 @@ public interface IMountService extends IInterface {
                }
            }

            @Override
            public long benchmark(String volId) throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeString(volId);
                    mRemote.transact(Stub.TRANSACTION_benchmark, _data, _reply, 0);
                    _reply.readException();
                    return _reply.readLong();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
            }

            @Override
            public void partitionPublic(String diskId) throws RemoteException {
                Parcel _data = Parcel.obtain();
@@ -1257,6 +1273,8 @@ public interface IMountService extends IInterface {
        static final int TRANSACTION_getPrimaryStorageUuid = IBinder.FIRST_CALL_TRANSACTION + 57;
        static final int TRANSACTION_setPrimaryStorageUuid = IBinder.FIRST_CALL_TRANSACTION + 58;

        static final int TRANSACTION_benchmark = IBinder.FIRST_CALL_TRANSACTION + 59;

        /**
         * Cast an IBinder object into an IMountService interface, generating a
         * proxy if needed.
@@ -1726,6 +1744,14 @@ public interface IMountService extends IInterface {
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_benchmark: {
                    data.enforceInterface(DESCRIPTOR);
                    String volId = data.readString();
                    long res = benchmark(volId);
                    reply.writeNoException();
                    reply.writeLong(res);
                    return true;
                }
                case TRANSACTION_partitionPublic: {
                    data.enforceInterface(DESCRIPTOR);
                    String diskId = data.readString();
@@ -2088,6 +2114,7 @@ public interface IMountService extends IInterface {
    public void mount(String volId) throws RemoteException;
    public void unmount(String volId) throws RemoteException;
    public void format(String volId) throws RemoteException;
    public long benchmark(String volId) throws RemoteException;

    public void partitionPublic(String diskId) throws RemoteException;
    public void partitionPrivate(String diskId) throws RemoteException;
+9 −0
Original line number Diff line number Diff line
@@ -640,6 +640,15 @@ public class StorageManager {
        }
    }

    /** {@hide} */
    public long benchmark(String volId) {
        try {
            return mMountService.benchmark(volId);
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    /** {@hide} */
    public void partitionPublic(String diskId) {
        try {
+22 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.net.Uri;
import android.os.Binder;
import android.os.Environment;
import android.os.Environment.UserEnvironment;
import android.os.DropBoxManager;
import android.os.FileUtils;
import android.os.Handler;
import android.os.HandlerThread;
@@ -174,6 +175,7 @@ class MountService extends IMountService.Stub
    private static final boolean WATCHDOG_ENABLE = false;

    private static final String TAG = "MountService";
    private static final String TAG_STORAGE_BENCHMARK = "storage_benchmark";

    private static final String VOLD_TAG = "VoldConnector";

@@ -233,6 +235,7 @@ class MountService extends IMountService.Stub
        public static final int VOLUME_DESTROYED = 659;

        public static final int MOVE_STATUS = 660;
        public static final int BENCHMARK_RESULT = 661;

        /*
         * 700 series - fstrim
@@ -927,6 +930,12 @@ class MountService extends IMountService.Stub
                break;
            }

            case VoldResponseCode.BENCHMARK_RESULT: {
                final DropBoxManager dropBox = mContext.getSystemService(DropBoxManager.class);
                dropBox.addText(TAG_STORAGE_BENCHMARK, raw);
                break;
            }

            case VoldResponseCode.FstrimCompleted: {
                EventLogTags.writeFstrimFinish(SystemClock.elapsedRealtime());
                break;
@@ -1405,6 +1414,19 @@ class MountService extends IMountService.Stub
        }
    }

    @Override
    public long benchmark(String volId) {
        enforcePermission(android.Manifest.permission.MOUNT_FORMAT_FILESYSTEMS);
        waitForReady();

        try {
            final NativeDaemonEvent res = mConnector.execute("volume", "benchmark", volId);
            return Long.parseLong(res.getMessage());
        } catch (NativeDaemonConnectorException e) {
            throw e.rethrowAsParcelableException();
        }
    }

    @Override
    public void partitionPublic(String diskId) {
        enforcePermission(android.Manifest.permission.MOUNT_FORMAT_FILESYSTEMS);