[Galaxy A3, A5, A7, A8, A9 Original Android Develop] impasta:
Hi,

I guess I have found another problem. It looks like LOS 18.1 does not like adopted storage. LOS 17.1 looks good, though.

It does work, like installing apps to the adopted storage and writing some files there.

But, when system_server crashes or more specifically vold resets, the system will fail to remount the adopted storage and it will show in the Settings app as corrupted. A simple fix here is to reboot the phone. You could also reinsert the micro sd card but it is a hit-or-miss.

To reproduce:

Format SD card as internal storage (or create an adopted storage); This is also reproducible on semi-adopted storage.

Do anything that will make vold reset like:

Issue `stop` then `start` as root

Issue `setprop ctl.restart zygote` as root

Do a warm/soft reboot

Run `killall -7 com.android.providers.media.module` as root

When vold resets it will try to unmount everything (including the emulated storage) but will fail on the adopted storage, you can see logs like this:

D StorageManagerService: Thinking about reset, mBootCompleted=true, mDaemonConnected=true
I StorageSessionController: Started resetting external storage service...
I StorageSessionController: Finished resetting external storage service
I StorageManagerService: Resetting vold...
I vold : Killing all processes referencing /storage/emulated/0
D vold : fscrypt_prepare_user_storage for volume null, user 0, serial 0, flags 2
D vold : Preparing: /data/system_ce/0
D vold : Preparing: /data/misc_ce/0
D vold : Preparing: /data/vendor_ce/0
D vold : Preparing: /data/media/0
D vold : Preparing: /data/data
D vold : Starting restorecon of /data/system_ce/0
D vold : Finished restorecon of /data/system_ce/0
D vold : Starting restorecon of /data/vendor_ce/0
D vold : Finished restorecon of /data/vendor_ce/0
D vold : Starting restorecon of /data/misc_ce/0
D vold : Finished restorecon of /data/misc_ce/0
D vold : /system/bin/vold_prepare_subdirs
D vold : prepare
D vold :
D vold : 0
D vold : 2
I vold : Unmounting /mnt/installer/0/emulated/0/Android/obb
I vold : Unmounting /mnt/user/0/emulated/0/Android/data
I vold : Unmounted /mnt/user/0/emulated/0/Android/data
I vold : Unmounting /mnt/user/0/emulated/0/Android/obb
I vold : Unmounted /mnt/user/0/emulated/0/Android/obb
I vold : Unmounting pass_through_path /mnt/pass_through/0/emulated
I vold : Unmounting fuse path /mnt/user/0/emulated
I vold : Killing all processes referencing /storage/emulated/10
I vold : Unmounting /mnt/installer/10/emulated/10/Android/obb
I vold : Unmounting /mnt/user/10/emulated/10/Android/data
I vold : Unmounted /mnt/user/10/emulated/10/Android/data
I vold : Unmounting /mnt/user/10/emulated/10/Android/obb
I vold : Unmounted /mnt/user/10/emulated/10/Android/obb
I vold : Unmounting pass_through_path /mnt/pass_through/10/emulated
I vold : Unmounting fuse path /mnt/user/10/emulated
I vold : Unmounting pass_through_path /mnt/pass_through/0/9349-EAB9
I vold : Unmounting fuse path /mnt/user/0/9349-EAB9
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
D vold : /system/bin/sgdisk
D vold : --android-dump
D vold : /dev/block/vold/disk:179,32
D vold : DISK gpt 3E3C725E-62A4-4A18-86E2-5BF10A2BB7D7
D vold : PART 1 EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 F10B5C3D-1BFF-46CE-9BB3-F8B6457D05AB shared
D vold : PART 2 19A710A2-B3CA-11E4-B026-10604B889DCF D572AD45-59B6-4E92-A564-ABDB14561DD5 android_meta
D vold : PART 3 193D1EA4-B3CA-11E4-B075-10604B889DCF 0C1100AE-7DA4-4018-ACE6-8E3453241331 android_expand
D vold : Found key for GUID 0c1100ae7da44018ace68e3453241331
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
E vold : DM_DEV_REMOVE failed for [private:179,35]: Device or resource busy
E vold : Cannot remove dm device private:179,35: Device or resource busy
I vold : onUserStarted: 0
I StorageManagerService: Reset vold
I vold : onUserAdded: 0
I vold : onUserAdded: 10
I vold : onUserAdded: 11
I StorageManagerService: Mounting volume VolumeInfo{public:179,33}:
I StorageManagerService: type=PUBLIC diskId=disk:179,32 partGuid= mountFlags=VISIBLE mountUserId=0
I StorageManagerService: state=UNMOUNTED
I StorageManagerService: fsType=null fsUuid=null fsLabel=null
I StorageManagerService: path=null internalPath=null

Adopted storage will be unavailable after that stage but soon after, zygote will throw an error about failing to mount tmpfs on /mnt/expand/3d01dbcb-42d9-4446-8b3e-880d74e9f10e/. This will spam the logcat and cause some ANR to pop up in Android.

E StorageManagerService: Failed to notify volume state changed to the Storage Service
E StorageManagerService: com.android.server.storage.StorageSessionController$ExternalStorageServiceException: Failed to notify volume state changed for vol : StorageVolume: shared (9349-EAB9)
E StorageManagerService: at com.android.server.storage.StorageUserConnection$ActiveConnection.notifyVolumeStateChanged(StorageUserConnection.java:307)
E StorageManagerService: at com.android.server.storage.StorageUserConnection.notifyVolumeStateChanged(StorageUserConnection.java:124)
E StorageManagerService: at com.android.server.storage.StorageSessionController.notifyVolumeStateChanged(StorageSessionController.java:130)
E StorageManagerService: at com.android.server.StorageManagerService.onVolumeStateChangedAsync(StorageManagerService.java:1657)
E StorageManagerService: at com.android.server.StorageManagerService.access$2400(StorageManagerService.java:212)
E StorageManagerService: at com.android.server.StorageManagerService$StorageManagerServiceHandler.handleMessage(StorageManagerService.java:840)
E StorageManagerService: at android.os.Handler.dispatchMessage(Handler.java:106)
E StorageManagerService: at android.os.Looper.loop(Looper.java:223)
E StorageManagerService: at android.os.HandlerThread.run(HandlerThread.java:67)
E StorageManagerService: Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.CancellationException
E StorageManagerService: at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:361)
E StorageManagerService: at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1943)
E StorageManagerService: at com.android.server.storage.StorageUserConnection$ActiveConnection.waitForAsync(StorageUserConnection.java:266)
E StorageManagerService: at com.android.server.storage.StorageUserConnection$ActiveConnection.notifyVolumeStateChanged(StorageUserConnection.java:304)
E StorageManagerService: ... 8 more
E StorageManagerService: Caused by: java.util.concurrent.CancellationException
E StorageManagerService: at java.util.concurrent.CompletableFuture.cancel(CompletableFuture.java:2292)
E StorageManagerService: at com.android.server.storage.StorageUserConnection$ActiveConnection.close(StorageUserConnection.java:228)
E StorageManagerService: at com.android.server.storage.StorageUserConnection$ActiveConnection$1.handleDisconnection(StorageUserConnection.java:375)
E StorageManagerService: at com.android.server.storage.StorageUserConnection$ActiveConnection$1.onBindingDied(StorageUserConnection.java:355)
E StorageManagerService: at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1974)
E StorageManagerService: at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:2010)
E StorageManagerService: at android.os.Handler.handleCallback(Handler.java:938)
E StorageManagerService: at android.os.Handler.dispatchMessage(Handler.java:99)
E StorageManagerService: ... 2 more
E StorageUserConnection: Service: [ComponentInfo{com.android.providers.media.module/com.android.providers.media.fuse.ExternalStorageServiceImpl}] is null. User [0]
D StorageNotification: Notifying about public volume: VolumeInfo{public:179,33}:
D StorageNotification: type=PUBLIC diskId=disk:179,32 partGuid= mountFlags=VISIBLE mountUserId=0
D StorageNotification: state=UNMOUNTABLE
D StorageNotification: fsType=exfat fsUuid=9349-EAB9 fsLabel=shared
D StorageNotification: path=/storage/9349-EAB9 internalPath=/mnt/media_rw/9349-EAB9
I DropBoxManagerService: add tag=system_server_wtf isTagEnabled=true flags=0x2
I StorageSessionController: Notifying volume state changed for session with id: emulated;0
I StorageUserConnection: Binding to the ExternalStorageService for user 0
W DropBoxManagerService: Dropping: system_server_wtf (879 > 0 bytes)
I StorageUserConnection: Bound to the ExternalStorageService for user 0
D StorageNotification: Notifying about private volume: VolumeInfo{private:179,35}:
D StorageNotification: type=PRIVATE diskId=disk:179,32
D StorageNotification: partGuid=0C1100AE-7DA4-4018-ACE6-8E3453241331 mountFlags=0 mountUserId=-1
D StorageNotification: state=UNMOUNTABLE
D StorageNotification: fsType= fsUuid= fsLabel=
D StorageNotification: path=null internalPath=null
D StorageNotification: Notifying about private volume: VolumeInfo{private:179,35}:
D StorageNotification: type=PRIVATE diskId=disk:179,32
D StorageNotification: partGuid=0C1100AE-7DA4-4018-ACE6-8E3453241331 mountFlags=0 mountUserId=-1
D StorageNotification: state=UNMOUNTABLE
D StorageNotification: fsType= fsUuid= fsLabel=
D StorageNotification: path=null internalPath=null
F zygote : jni_internal.cc:729] JNI FatalError called: (com.android.providers.media.module) frameworks/base/core/jni/com_android_internal_os_Zygote.cpp:795: Failed to mount tmpfs to /mnt/expand/3d01dbcb-42d9-4446-8b3e-880d74e9f10e/user: No such file or directory
F zygote : runtime.cc:655] Runtime aborting...
F zygote : runtime.cc:655] Dumping all threads without mutator lock held
F zygote : runtime.cc:655] All threads:
F zygote : runtime.cc:655] DALVIK THREADS (1):
F zygote : runtime.cc:655] "main" prio=5 tid=1 Runnable
F zygote : runtime.cc:655] | group="" sCount=0 dsCount=0 flags=0 obj=0x72af2c28 self=0xdf6c1c10
F zygote : runtime.cc:655] | sysTid=6498 nice=0 cgrp=default sched=0/0 handle=0xe77eb470
F zygote : runtime.cc:655] | state=? schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
F zygote : runtime.cc:655] | stack=0xff5b1000-0xff5b3000 stackSize=8192KB
F zygote : runtime.cc:655] | held mutexes= "abort lock" "mutator lock"(shared held)
F zygote : runtime.cc:655] native: (backtrace::Unwind failed for thread 6498: Thread doesn't exist)
F zygote : runtime.cc:655] at com.android.internal.os.Zygote.nativeForkAndSpecialize(Native method)
F zygote : runtime.cc:655] at com.android.internal.os.Zygote.forkAndSpecialize(Zygote.java:344)
F zygote : runtime.cc:655] at com.android.internal.os.ZygoteConnection.processOneCommand(ZygoteConnection.java:257)
F zygote : runtime.cc:655] at com.android.internal.os.ZygoteServer.runSelectLoop(ZygoteServer.java:550)
F zygote : runtime.cc:655] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934)
F zygote : runtime.cc:655]
F zygote : runtime.cc:655] Aborting thread:
F zygote : runtime.cc:655] "main" prio=5 tid=1 Native
F zygote : runtime.cc:655] | group="" sCount=0 dsCount=0 flags=0 obj=0x72af2c28 self=0xdf6c1c10
F zygote : runtime.cc:655] | sysTid=6498 nice=0 cgrp=default sched=0/0 handle=0xe77eb470
F zygote : runtime.cc:655] | state=? schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
F zygote : runtime.cc:655] | stack=0xff5b1000-0xff5b3000 stackSize=8192KB
F zygote : runtime.cc:655] | held mutexes= "abort lock"
F zygote : runtime.cc:655] native: (backtrace::Unwind failed for thread 6498: Thread doesn't exist)
F zygote : runtime.cc:655] at com.android.internal.os.Zygote.nativeForkAndSpecialize(Native method)
F zygote : runtime.cc:655] at com.android.internal.os.Zygote.forkAndSpecialize(Zygote.java:344)
F zygote : runtime.cc:655] at com.android.internal.os.ZygoteConnection.processOneCommand(ZygoteConnection.java:257)
F zygote : runtime.cc:655] at com.android.internal.os.ZygoteServer.runSelectLoop(ZygoteServer.java:550)
F zygote : runtime.cc:655] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934)
F zygote : runtime.cc:655]
F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 12286 (main), pid 12286 (main)
E libc : capset failed: Operation not permitted
E libc : failed to raise ambient capability 0: Operation not permitted
E libc : failed to raise ambient capability 1: Operation not permitted
E libc : failed to raise ambient capability 2: Operation not permitted
E libc : failed to raise ambient capability 3: Operation not permitted
E libc : failed to raise ambient capability 4: Operation not permitted
E libc : failed to raise ambient capability 5: Operation not permitted
E libc : failed to raise ambient capability 6: Operation not permitted
E libc : failed to raise ambient capability 7: Operation not permitted
E libc : failed to raise ambient capability 8: Operation not permitted
E libc : failed to raise ambient capability 9: Operation not permitted
E libc : failed to raise ambient capability 10: Operation not permitted
E libc : failed to raise ambient capability 11: Operation not permitted
E libc : failed to raise ambient capability 12: Operation not permitted
E libc : failed to raise ambient capability 13: Operation not permitted
E libc : failed to raise ambient capability 14: Operation not permitted
E libc : failed to raise ambient capability 15: Operation not permitted
E libc : failed to raise ambient capability 16: Operation not permitted
E libc : failed to raise ambient capability 17: Operation not permitted
E libc : failed to raise ambient capability 18: Operation not permitted
E libc : failed to raise ambient capability 19: Operation not permitted
E libc : failed to raise ambient capability 20: Operation not permitted
E libc : failed to raise ambient capability 21: Operation not permitted
E libc : failed to raise ambient capability 22: Operation not permitted
E libc : failed to raise ambient capability 23: Operation not permitted
E libc : failed to raise ambient capability 24: Operation not permitted
E libc : failed to raise ambient capability 25: Operation not permitted
E libc : failed to raise ambient capability 26: Operation not permitted
E libc : failed to raise ambient capability 27: Operation not permitted
E libc : failed to raise ambient capability 28: Operation not permitted
E libc : failed to raise ambient capability 29: Operation not permitted
E libc : failed to raise ambient capability 30: Operation not permitted
E libc : failed to raise ambient capability 31: Operation not permitted
E libc : failed to raise ambient capability 32: Operation not permitted
E libc : failed to raise ambient capability 33: Operation not permitted
E libc : failed to raise ambient capability 34: Operation not permitted
E libc : failed to raise ambient capability 35: Operation not permitted
E libc : failed to raise ambient capability 36: Operation not permitted
E DEBUG : failed to readlink /proc/12286/fd/0: Permission denied
W main : type=1701 audit(0.0:32108): auid=4294967295 uid=0 gid=0 ses=4294967295 subj=u:r:zygote:s0 reason="memory violation" sig=6
E DEBUG : failed to readlink /proc/12286/fd/1: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/2: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/3: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/4: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/5: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/6: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/7: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/8: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/9: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/10: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/11: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/12: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/13: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/14: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/15: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/16: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/17: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/18: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/19: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/20: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/21: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/22: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/23: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/24: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/25: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/26: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/27: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/28: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/29: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/30: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/31: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/32: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/33: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/34: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/35: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/36: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/37: Permission denied
E DEBUG : failed to readlink /proc/12286/fd/38: Permission denied
F crash_dump32: crash_dump.cpp:474] failed to attach to thread 12286, already traced by 0 ()
I tombstoned: received crash request for pid 12286
W tombstoned: crash socket received short read of length 0 (expected 12)
F libc : crash_dump helper failed to exec
D Zygote : Forked child process 12286

What's worse is that if you tried to unmount that directory you get an invalid argument error. You cannot also remove that directory even if it does not contain anything. If you do remove it, you will get an "Device or resource busy" error.

Does anyone have any ideas on this?