SDCardFS is deprecated on devices that launch with Android 11 or higher and run kernel version 5.4 or higher. On such devices, VTS testing doesn't allow mounted file systems listed as SDCardFS. Devices that launch with Android 11 or higher but run kernel version 4.19 or lower can continue to use SDCardFS, but Google doesn't provide additional support.
Before its deprecation, SDCardFS provided a way to control access to emulated internal storage and external SD cards, allowing apps to access only the data relevant to them. Additionally, it provided a layer of case insensitivity, as well as some additional storage tracking.
SDCardFS replacement functionality
The replacement for SDCardFS uses several Linux kernel filesystem features to achieve similar results. Case insensitivity is handled directly by the filesystem; this results in lookup times nearly identical in case-sensitive and case-insensitive folders, removing the large folder slowdown from SDCardFS. The quota tracking that SDCardFS was doing to quickly gather storage data for settings is now configured from userspace using project quotas. In some performance-sensitive contexts, directories are bind mounted in place. A new FUSE implementation provides scoped storage for direct filesystem access, primarily to support redaction of location information.
Configuring SDCard replacement functionality
To enable project quotas and case folding for emulated storage without SDCardFS
on a device that launched with Android 11 or higher,
emulated_storage.mk in the
$(call inherit-product, $(SRC_TARGET_DIR)/product/emulated_storage.mk)
Warning: Do not do this on devices that launched with Android 10 or lower, since filesystem native case-insensitivity is incompatible with the file-based encryption settings used on such devices. It is necessary to keep using SDCardFS on such devices.
Why deprecate SDCardFS?
There are various reasons to deprecate SDCardFS.
SDCardFS suffers from several race conditions concerning case sensitivity, as well as some issues concerning low memory circumstances. Case-insensitive lookups can be rather slow in large directories because lookups have to walk the lower directory to find alternate cases. Accessing the upper and lower filesystems at the same time can lead to issues as well.
SDCardFS requires additional patches to the VFS to support changing options on bind mounts. These patches cause additional work to accept upstream changes to these areas. SDCardFS’s features can be replicated by upstream components, removing this pain point.
Feature parity with API
In the previous release of Android, scoped storage limited access to particular types of metadata. Direct storage access through SDCardFS doesn't support these scoped storage features.