diff options
author | 2021-04-30 09:50:58 -0700 | |
---|---|---|
committer | 2021-05-03 14:58:18 -0700 | |
commit | d48a25ee649b9aa2e6dde6e0e9844bb7da8bfe5c (patch) | |
tree | 761a5e4f7e4f00d9591029237d28f130b62f87ef /services/incremental/IncrementalService.cpp | |
parent | f949c37e14bd0ccdbb0fba7e2599b817133f9ed9 (diff) |
[IncrementalService] add last read error in dumpsys
BUG: 184844615
Test: dumpsys
Change-Id: I3e8178c8a62dc5d09c718b140bb48bda85a3bae5
Diffstat (limited to 'services/incremental/IncrementalService.cpp')
-rw-r--r-- | services/incremental/IncrementalService.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp index de8c8bc94568..68b5bd975dbc 100644 --- a/services/incremental/IncrementalService.cpp +++ b/services/incremental/IncrementalService.cpp @@ -395,6 +395,15 @@ static long elapsedMcs(Duration start, Duration end) { return std::chrono::duration_cast<std::chrono::microseconds>(end - start).count(); } +static uint64_t elapsedUsSinceMonoTs(uint64_t monoTsUs) { + timespec now; + if (clock_gettime(CLOCK_MONOTONIC, &now) != 0) { + return 0; + } + uint64_t nowUs = now.tv_sec * 1000000LL + now.tv_nsec / 1000; + return nowUs - monoTsUs; +} + void IncrementalService::onDump(int fd) { dprintf(fd, "Incremental is %s\n", incfs::enabled() ? "ENABLED" : "DISABLED"); dprintf(fd, "Incremental dir: %s\n", mIncrementalDir.c_str()); @@ -462,6 +471,25 @@ void IncrementalService::onDump(int fd) { dprintf(fd, " Metrics not available. Errno: %d\n", errno); } dprintf(fd, " }\n"); + + const auto lastReadError = mIncFs->getLastReadError(ifs->control); + const auto errorNo = errno; + dprintf(fd, " lastReadError: {\n"); + if (lastReadError) { + if (lastReadError->timestampUs == 0) { + dprintf(fd, " No read errors.\n"); + } else { + dprintf(fd, " fileId: %s\n", + IncFsWrapper::toString(lastReadError->id).c_str()); + dprintf(fd, " time: %llu microseconds ago\n", + (unsigned long long)elapsedUsSinceMonoTs(lastReadError->timestampUs)); + dprintf(fd, " blockIndex: %d\n", lastReadError->block); + dprintf(fd, " errno: %d\n", lastReadError->errorNo); + } + } else { + dprintf(fd, " Info not available. Errno: %d\n", errorNo); + } + dprintf(fd, " }\n"); } dprintf(fd, " }\n"); } |