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

Commit c2278090 authored by Oleg Lyovin's avatar Oleg Lyovin
Browse files

remount: prefer 'cache' backing storage for non-A/B devices



In non-A/B configurations system partitions often
have layout with not so much free space left, while having
large /cache partition.

In a dynamic partitions configuration 'remount' for backing
storage will user either:

-- /data partition, which is not guaranteed to have
enough space due to applications disk usage;

-- or super partition, which is tied to system images size
having a little room for growing.

At the same time, /cache is guaranteed to be free,
so non-A/B platform can force it to be used as
backing storage.

Test: remount
Signed-off-by: default avatarOleg Lyovin <ovlevin@sberdevices.ru>
Change-Id: I68e621b884b2fe21a5c464b3deaf679186232eb3
parent 7014fa9f
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ using android::fiemap::IImageManager;
namespace {

constexpr char kDataScratchSizeMbProp[] = "fs_mgr.overlayfs.data_scratch_size_mb";
constexpr char kPreferCacheBackingStorageProp[] = "fs_mgr.overlayfs.prefer_cache_backing_storage";

bool fs_mgr_access(const std::string& path) {
    return access(path.c_str(), F_OK) == 0;
@@ -101,6 +102,10 @@ bool fs_mgr_is_dsu_running() {
const auto kScratchMountPoint = "/mnt/scratch"s;
const auto kCacheMountPoint = "/cache"s;

bool IsABDevice() {
    return !android::base::GetProperty("ro.boot.slot_suffix", "").empty();
}

std::vector<const std::string> OverlayMountPoints() {
    // Never fallback to legacy cache mount point if within a DSU system,
    // because running a DSU system implies the device supports dynamic
@@ -108,6 +113,15 @@ std::vector<const std::string> OverlayMountPoints() {
    if (fs_mgr_is_dsu_running()) {
        return {kScratchMountPoint};
    }

    // For non-A/B devices prefer cache backing storage if
    // kPreferCacheBackingStorageProp property set.
    if (!IsABDevice() &&
        android::base::GetBoolProperty(kPreferCacheBackingStorageProp, false) &&
        android::base::GetIntProperty("ro.vendor.api_level", -1) < __ANDROID_API_T__) {
        return {kCacheMountPoint, kScratchMountPoint};
    }

    return {kScratchMountPoint, kCacheMountPoint};
}