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

Commit 3c05313b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[incfs] Use the new libincfs API for file status checking" into sc-dev

parents b50b960b 256a1a45
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -255,13 +255,12 @@ binder::Status BinderIncrementalService::unlink(int32_t storageId, const std::st
binder::Status BinderIncrementalService::isFileFullyLoaded(int32_t storageId,
                                                           const std::string& path,
                                                           int32_t* _aidl_return) {
    *_aidl_return = mImpl.isFileFullyLoaded(storageId, path);
    *_aidl_return = (int)mImpl.isFileFullyLoaded(storageId, path);
    return ok();
}

binder::Status BinderIncrementalService::isFullyLoaded(int32_t storageId, int32_t* _aidl_return) {
    *_aidl_return = mImpl.getLoadingProgress(storageId, /*stopOnFirstIncomplete=*/true)
                            .blocksRemainingOrError();
    *_aidl_return = (int)mImpl.isMountFullyLoaded(storageId);
    return ok();
}

+11 −16
Original line number Diff line number Diff line
@@ -1980,35 +1980,30 @@ int IncrementalService::setFileContent(const IfsMountPtr& ifs, const incfs::File
    return 0;
}

int IncrementalService::isFileFullyLoaded(StorageId storage, std::string_view filePath) const {
incfs::LoadingState IncrementalService::isFileFullyLoaded(StorageId storage,
                                                          std::string_view filePath) const {
    std::unique_lock l(mLock);
    const auto ifs = getIfsLocked(storage);
    if (!ifs) {
        LOG(ERROR) << "isFileFullyLoaded failed, invalid storageId: " << storage;
        return -EINVAL;
        return incfs::LoadingState(-EINVAL);
    }
    const auto storageInfo = ifs->storages.find(storage);
    if (storageInfo == ifs->storages.end()) {
        LOG(ERROR) << "isFileFullyLoaded failed, no storage: " << storage;
        return -EINVAL;
        return incfs::LoadingState(-EINVAL);
    }
    l.unlock();
    return isFileFullyLoadedFromPath(*ifs, filePath);
    return mIncFs->isFileFullyLoaded(ifs->control, filePath);
}

int IncrementalService::isFileFullyLoadedFromPath(const IncFsMount& ifs,
                                                  std::string_view filePath) const {
    const auto [filledBlocks, totalBlocks] = mIncFs->countFilledBlocks(ifs.control, filePath);
    if (filledBlocks < 0) {
        LOG(ERROR) << "isFileFullyLoadedFromPath failed to get filled blocks count for: "
                   << filePath << " errno: " << filledBlocks;
        return filledBlocks;
    }
    if (totalBlocks < filledBlocks) {
        LOG(ERROR) << "isFileFullyLoadedFromPath failed to get total num of blocks";
        return -EINVAL;
incfs::LoadingState IncrementalService::isMountFullyLoaded(StorageId storage) const {
    const auto ifs = getIfs(storage);
    if (!ifs) {
        LOG(ERROR) << "isMountFullyLoaded failed, invalid storageId: " << storage;
        return incfs::LoadingState(-EINVAL);
    }
    return totalBlocks - filledBlocks;
    return mIncFs->isEverythingFullyLoaded(ifs->control);
}

IncrementalService::LoadingProgress IncrementalService::getLoadingProgress(
+2 −2
Original line number Diff line number Diff line
@@ -164,7 +164,8 @@ public:
             std::string_view newPath);
    int unlink(StorageId storage, std::string_view path);

    int isFileFullyLoaded(StorageId storage, std::string_view filePath) const;
    incfs::LoadingState isFileFullyLoaded(StorageId storage, std::string_view filePath) const;
    incfs::LoadingState isMountFullyLoaded(StorageId storage) const;

    LoadingProgress getLoadingProgress(StorageId storage, bool stopOnFirstIncomplete) const;

@@ -412,7 +413,6 @@ private:
    int setStorageParams(IncFsMount& ifs, StorageId storageId, bool enableReadLogs);
    binder::Status applyStorageParams(IncFsMount& ifs, bool enableReadLogs);

    int isFileFullyLoadedFromPath(const IncFsMount& ifs, std::string_view filePath) const;
    LoadingProgress getLoadingProgressFromPath(const IncFsMount& ifs, std::string_view path,
                                               bool stopOnFirstIncomplete) const;

+7 −0
Original line number Diff line number Diff line
@@ -197,6 +197,13 @@ public:
        }
        return {filledBlockCount, totalBlocksCount};
    }
    incfs::LoadingState isFileFullyLoaded(const Control& control,
                                          std::string_view path) const final {
        return incfs::isFullyLoaded(control, path);
    }
    incfs::LoadingState isEverythingFullyLoaded(const Control& control) const final {
        return incfs::isEverythingFullyLoaded(control);
    }
    ErrorCode link(const Control& control, std::string_view from, std::string_view to) const final {
        return incfs::link(control, from, to);
    }
+3 −0
Original line number Diff line number Diff line
@@ -102,6 +102,9 @@ public:
    virtual std::string toString(FileId fileId) const = 0;
    virtual std::pair<IncFsBlockIndex, IncFsBlockIndex> countFilledBlocks(
            const Control& control, std::string_view path) const = 0;
    virtual incfs::LoadingState isFileFullyLoaded(const Control& control,
                                                  std::string_view path) const = 0;
    virtual incfs::LoadingState isEverythingFullyLoaded(const Control& control) const = 0;
    virtual ErrorCode link(const Control& control, std::string_view from,
                           std::string_view to) const = 0;
    virtual ErrorCode unlink(const Control& control, std::string_view path) const = 0;
Loading