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

Commit ac55edad authored by Songchun Fan's avatar Songchun Fan Committed by Android (Google) Code Review
Browse files

Merge "[incremental] add last pending reads info in dumpsys"

parents 2503bdd7 6944f1e4
Loading
Loading
Loading
Loading
+25 −5
Original line number Diff line number Diff line
@@ -2341,17 +2341,16 @@ BootClockTsUs IncrementalService::DataLoaderStub::getOldestPendingReadTs() {
        return result;
    }

    std::vector<incfs::ReadInfo> pendingReads;
    if (mService.mIncFs->waitForPendingReads(control, 0ms, &pendingReads) !=
    if (mService.mIncFs->waitForPendingReads(control, 0ms, &mLastPendingReads) !=
                android::incfs::WaitResult::HaveData ||
        pendingReads.empty()) {
        mLastPendingReads.empty()) {
        return result;
    }

    LOG(DEBUG) << id() << ": pendingReads: " << control.pendingReads() << ", "
               << pendingReads.size() << ": " << pendingReads.front().bootClockTsUs;
               << mLastPendingReads.size() << ": " << mLastPendingReads.front().bootClockTsUs;

    for (auto&& pendingRead : pendingReads) {
    for (auto&& pendingRead : mLastPendingReads) {
        result = std::min(result, pendingRead.bootClockTsUs);
    }
    return result;
@@ -2400,6 +2399,18 @@ void IncrementalService::DataLoaderStub::setHealthListener(
    }
}

static std::string toHexString(const RawMetadata& metadata) {
    int n = metadata.size();
    std::string res(n * 2, '\0');
    // Same as incfs::toString(fileId)
    static constexpr char kHexChar[] = "0123456789abcdef";
    for (int i = 0; i < n; ++i) {
        res[i * 2] = kHexChar[(metadata[i] & 0xf0) >> 4];
        res[i * 2 + 1] = kHexChar[(metadata[i] & 0x0f)];
    }
    return res;
}

void IncrementalService::DataLoaderStub::onDump(int fd) {
    dprintf(fd, "    dataLoader: {\n");
    dprintf(fd, "      currentStatus: %d\n", mCurrentStatus);
@@ -2415,6 +2426,15 @@ void IncrementalService::DataLoaderStub::onDump(int fd) {
    dprintf(fd, "        unhealthyTimeoutMs: %d\n", int(mHealthCheckParams.unhealthyTimeoutMs));
    dprintf(fd, "        unhealthyMonitoringMs: %d\n",
            int(mHealthCheckParams.unhealthyMonitoringMs));
    dprintf(fd, "        lastPendingReads: \n");
    const auto control = mService.mIncFs->openMount(mHealthPath);
    for (auto&& pendingRead : mLastPendingReads) {
        dprintf(fd, "          fileId: %s\n", mService.mIncFs->toString(pendingRead.id).c_str());
        const auto metadata = mService.mIncFs->getMetadata(control, pendingRead.id);
        dprintf(fd, "          metadataHex: %s\n", toHexString(metadata).c_str());
        dprintf(fd, "          blockIndex: %d\n", pendingRead.block);
        dprintf(fd, "          bootClockTsUs: %lld\n", (long long)pendingRead.bootClockTsUs);
    }
    dprintf(fd, "      }\n");
    const auto& params = mParams;
    dprintf(fd, "      dataLoaderParams: {\n");
+1 −0
Original line number Diff line number Diff line
@@ -257,6 +257,7 @@ private:
        } mHealthBase = {TimePoint::max(), kMaxBootClockTsUs};
        StorageHealthCheckParams mHealthCheckParams;
        int mStreamStatus = content::pm::IDataLoaderStatusListener::STREAM_HEALTHY;
        std::vector<incfs::ReadInfo> mLastPendingReads;
    };
    using DataLoaderStubPtr = sp<DataLoaderStub>;

+1 −0
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@ public:
    FileId getFileId(const Control& control, std::string_view path) const final {
        return incfs::getFileId(control, path);
    }
    std::string toString(FileId fileId) const final { return incfs::toString(fileId); }
    std::pair<IncFsBlockIndex, IncFsBlockIndex> countFilledBlocks(
            const Control& control, std::string_view path) const final {
        const auto fileId = incfs::getFileId(control, path);
+1 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ public:
    virtual incfs::RawMetadata getMetadata(const Control& control, FileId fileid) const = 0;
    virtual incfs::RawMetadata getMetadata(const Control& control, std::string_view path) const = 0;
    virtual FileId getFileId(const Control& control, std::string_view path) const = 0;
    virtual std::string toString(FileId fileId) const = 0;
    virtual std::pair<IncFsBlockIndex, IncFsBlockIndex> countFilledBlocks(
            const Control& control, std::string_view path) const = 0;
    virtual ErrorCode link(const Control& control, std::string_view from,
+1 −0
Original line number Diff line number Diff line
@@ -294,6 +294,7 @@ public:
    MOCK_CONST_METHOD2(getMetadata, RawMetadata(const Control& control, FileId fileid));
    MOCK_CONST_METHOD2(getMetadata, RawMetadata(const Control& control, std::string_view path));
    MOCK_CONST_METHOD2(getFileId, FileId(const Control& control, std::string_view path));
    MOCK_CONST_METHOD1(toString, std::string(FileId fileId));
    MOCK_CONST_METHOD2(countFilledBlocks,
                       std::pair<IncFsBlockIndex, IncFsBlockIndex>(const Control& control,
                                                                   std::string_view path));