[pm] remove incremental startable/unstartable code

Also remove streaming health status reporting which could cause
startable state change because it is also not needed any more.

BUG: 171920377
Test: builds
Change-Id: I7284e7a63df79da7dbf3d16ff64302b3d1ce1348
This commit is contained in:
Songchun Fan
2021-04-14 19:04:11 +00:00
parent e53db0d402
commit 5ada1508c2
28 changed files with 23 additions and 991 deletions

View File

@@ -335,20 +335,6 @@ binder::Status BinderIncrementalService::unregisterLoadingProgressListener(int32
return ok();
}
binder::Status BinderIncrementalService::registerStorageHealthListener(
int32_t storageId,
const ::android::os::incremental::StorageHealthCheckParams& healthCheckParams,
const ::android::sp<IStorageHealthListener>& healthListener, bool* _aidl_return) {
*_aidl_return =
mImpl.registerStorageHealthListener(storageId, healthCheckParams, healthListener);
return ok();
}
binder::Status BinderIncrementalService::unregisterStorageHealthListener(int32_t storageId) {
mImpl.unregisterStorageHealthListener(storageId);
return ok();
}
binder::Status BinderIncrementalService::getMetrics(int32_t storageId,
android::os::PersistableBundle* _aidl_return) {
mImpl.getMetrics(storageId, _aidl_return);

View File

@@ -95,11 +95,6 @@ public:
progressListener,
bool* _aidl_return) final;
binder::Status unregisterLoadingProgressListener(int32_t storageId, bool* _aidl_return) final;
binder::Status registerStorageHealthListener(
int32_t storageId,
const ::android::os::incremental::StorageHealthCheckParams& healthCheckParams,
const ::android::sp<IStorageHealthListener>& healthListener, bool* _aidl_return) final;
binder::Status unregisterStorageHealthListener(int32_t storageId) final;
binder::Status getMetrics(int32_t storageId,
android::os::PersistableBundle* _aidl_return) final;

View File

@@ -2189,29 +2189,6 @@ bool IncrementalService::unregisterLoadingProgressListener(StorageId storage) {
return removeTimedJobs(*mProgressUpdateJobQueue, storage);
}
bool IncrementalService::registerStorageHealthListener(
StorageId storage, const StorageHealthCheckParams& healthCheckParams,
StorageHealthListener healthListener) {
DataLoaderStubPtr dataLoaderStub;
{
const auto& ifs = getIfs(storage);
if (!ifs) {
return false;
}
std::unique_lock l(ifs->lock);
dataLoaderStub = ifs->dataLoaderStub;
if (!dataLoaderStub) {
return false;
}
}
dataLoaderStub->setHealthListener(healthCheckParams, std::move(healthListener));
return true;
}
void IncrementalService::unregisterStorageHealthListener(StorageId storage) {
registerStorageHealthListener(storage, {}, {});
}
bool IncrementalService::perfLoggingEnabled() {
static const bool enabled = base::GetBoolProperty("incremental.perflogging", false);
return enabled;
@@ -2779,25 +2756,6 @@ void IncrementalService::DataLoaderStub::setCurrentStatus(int newStatus) {
mStatusCondition.notify_all();
}
binder::Status IncrementalService::DataLoaderStub::reportStreamHealth(MountId mountId,
int newStatus) {
if (!isValid()) {
return binder::Status::
fromServiceSpecificError(-EINVAL,
"reportStreamHealth came to invalid DataLoaderStub");
}
if (id() != mountId) {
LOG(ERROR) << "reportStreamHealth: mount ID mismatch: expected " << id()
<< ", but got: " << mountId;
return binder::Status::fromServiceSpecificError(-EPERM, "Mount ID mismatch.");
}
{
std::lock_guard lock(mMutex);
mStreamStatus = newStatus;
}
return binder::Status::ok();
}
bool IncrementalService::DataLoaderStub::isHealthParamsValid() const {
return mHealthCheckParams.blockedTimeoutMs > 0 &&
mHealthCheckParams.blockedTimeoutMs < mHealthCheckParams.unhealthyTimeoutMs;
@@ -2811,33 +2769,6 @@ void IncrementalService::DataLoaderStub::onHealthStatus(const StorageHealthListe
}
}
static int adjustHealthStatus(int healthStatus, int streamStatus) {
if (healthStatus == IStorageHealthListener::HEALTH_STATUS_OK) {
// everything is good; no need to change status
return healthStatus;
}
int newHeathStatus = healthStatus;
switch (streamStatus) {
case IDataLoaderStatusListener::STREAM_STORAGE_ERROR:
// storage is limited and storage not healthy
newHeathStatus = IStorageHealthListener::HEALTH_STATUS_UNHEALTHY_STORAGE;
break;
case IDataLoaderStatusListener::STREAM_INTEGRITY_ERROR:
// fall through
case IDataLoaderStatusListener::STREAM_SOURCE_ERROR:
// fall through
case IDataLoaderStatusListener::STREAM_TRANSPORT_ERROR:
if (healthStatus == IStorageHealthListener::HEALTH_STATUS_UNHEALTHY) {
newHeathStatus = IStorageHealthListener::HEALTH_STATUS_UNHEALTHY_TRANSPORT;
}
// pending/blocked status due to transportation issues is not regarded as unhealthy
break;
default:
break;
}
return newHeathStatus;
}
void IncrementalService::DataLoaderStub::updateHealthStatus(bool baseline) {
LOG(DEBUG) << id() << ": updateHealthStatus" << (baseline ? " (baseline)" : "");
@@ -2915,8 +2846,6 @@ void IncrementalService::DataLoaderStub::updateHealthStatus(bool baseline) {
checkBackAfter = unhealthyMonitoring;
healthStatusToReport = IStorageHealthListener::HEALTH_STATUS_UNHEALTHY;
}
// Adjust health status based on stream status
healthStatusToReport = adjustHealthStatus(healthStatusToReport, mStreamStatus);
LOG(DEBUG) << id() << ": updateHealthStatus in " << double(checkBackAfter.count()) / 1000.0
<< "secs";
mService.addTimedJob(*mService.mTimedQueue, id(), checkBackAfter,

View File

@@ -189,10 +189,7 @@ public:
bool registerLoadingProgressListener(StorageId storage,
StorageLoadingProgressListener progressListener);
bool unregisterLoadingProgressListener(StorageId storage);
bool registerStorageHealthListener(StorageId storage,
const StorageHealthCheckParams& healthCheckParams,
StorageHealthListener healthListener);
void unregisterStorageHealthListener(StorageId storage);
RawMetadata getMetadata(StorageId storage, std::string_view path) const;
RawMetadata getMetadata(StorageId storage, FileId node) const;
@@ -256,7 +253,6 @@ private:
private:
binder::Status onStatusChanged(MountId mount, int newStatus) final;
binder::Status reportStreamHealth(MountId mount, int newStatus) final;
void setCurrentStatus(int newStatus);
@@ -319,7 +315,6 @@ private:
BootClockTsUs kernelTsUs;
} mHealthBase = {TimePoint::max(), kMaxBootClockTsUs};
StorageHealthCheckParams mHealthCheckParams;
int mStreamStatus = content::pm::IDataLoaderStatusListener::STREAM_HEALTHY;
std::vector<incfs::ReadInfoWithUid> mLastPendingReads;
};
using DataLoaderStubPtr = sp<DataLoaderStub>;

View File

@@ -184,18 +184,6 @@ public:
setAndReportStatus(id, IDataLoaderStatusListener::DATA_LOADER_IMAGE_READY);
return binder::Status::ok();
}
binder::Status storageError(int32_t id) {
if (mListener) {
mListener->reportStreamHealth(id, IDataLoaderStatusListener::STREAM_STORAGE_ERROR);
}
return binder::Status::ok();
}
binder::Status transportError(int32_t id) {
if (mListener) {
mListener->reportStreamHealth(id, IDataLoaderStatusListener::STREAM_INTEGRITY_ERROR);
}
return binder::Status::ok();
}
int32_t setStorageParams(bool enableReadLogs) {
int32_t result = -1;
EXPECT_NE(mServiceConnector.get(), nullptr);
@@ -1904,87 +1892,6 @@ TEST_F(IncrementalServiceTest, testStartDataLoaderUnbindOnAllDoneWithReadlogs) {
ASSERT_EQ(mDataLoader->status(), IDataLoaderStatusListener::DATA_LOADER_DESTROYED);
}
TEST_F(IncrementalServiceTest, testRegisterStorageHealthListenerSuccess) {
mIncFs->openMountSuccess();
sp<NiceMock<MockStorageHealthListener>> listener{new NiceMock<MockStorageHealthListener>};
sp<NiceMock<MockStorageHealthListener>> newListener{new NiceMock<MockStorageHealthListener>};
NiceMock<MockStorageHealthListener>* newListenerMock = newListener.get();
TemporaryDir tempDir;
int storageId =
mIncrementalService->createStorage(tempDir.path, mDataLoaderParcel,
IncrementalService::CreateOptions::CreateNew);
ASSERT_GE(storageId, 0);
mIncrementalService->startLoading(storageId, std::move(mDataLoaderParcel), {}, {}, listener,
{});
StorageHealthCheckParams newParams;
newParams.blockedTimeoutMs = 10000;
newParams.unhealthyTimeoutMs = 20000;
newParams.unhealthyMonitoringMs = 30000;
ASSERT_TRUE(mIncrementalService->registerStorageHealthListener(storageId, std::move(newParams),
newListener));
using MS = std::chrono::milliseconds;
using MCS = std::chrono::microseconds;
const auto blockedTimeout = MS(newParams.blockedTimeoutMs);
const auto unhealthyTimeout = MS(newParams.unhealthyTimeoutMs);
const uint64_t kFirstTimestampUs = 1000000000ll;
const uint64_t kBlockedTimestampUs =
kFirstTimestampUs - std::chrono::duration_cast<MCS>(blockedTimeout).count();
const uint64_t kUnhealthyTimestampUs =
kFirstTimestampUs - std::chrono::duration_cast<MCS>(unhealthyTimeout).count();
// test that old listener was not called
EXPECT_CALL(*listener.get(),
onHealthStatus(_, IStorageHealthListener::HEALTH_STATUS_READS_PENDING))
.Times(0);
EXPECT_CALL(*newListenerMock,
onHealthStatus(_, IStorageHealthListener::HEALTH_STATUS_READS_PENDING))
.Times(1);
EXPECT_CALL(*newListenerMock, onHealthStatus(_, IStorageHealthListener::HEALTH_STATUS_BLOCKED))
.Times(1);
EXPECT_CALL(*newListenerMock,
onHealthStatus(_, IStorageHealthListener::HEALTH_STATUS_UNHEALTHY_STORAGE))
.Times(1);
EXPECT_CALL(*newListenerMock,
onHealthStatus(_, IStorageHealthListener::HEALTH_STATUS_UNHEALTHY_TRANSPORT))
.Times(1);
mIncFs->waitForPendingReadsSuccess(kFirstTimestampUs);
mLooper->mCallback(-1, -1, mLooper->mCallbackData);
ASSERT_EQ(IStorageHealthListener::HEALTH_STATUS_READS_PENDING, newListener->mStatus);
ASSERT_EQ(storageId, newListener->mStorageId);
auto timedCallback = mTimedQueue->mWhat;
mTimedQueue->clearJob(storageId);
// test when health status is blocked with transport error
mDataLoader->transportError(storageId);
mIncFs->waitForPendingReadsSuccess(kBlockedTimestampUs);
timedCallback();
ASSERT_EQ(IStorageHealthListener::HEALTH_STATUS_BLOCKED, newListener->mStatus);
timedCallback = mTimedQueue->mWhat;
mTimedQueue->clearJob(storageId);
// test when health status is blocked with storage error
mDataLoader->storageError(storageId);
mIncFs->waitForPendingReadsSuccess(kBlockedTimestampUs);
timedCallback();
ASSERT_EQ(IStorageHealthListener::HEALTH_STATUS_UNHEALTHY_STORAGE, newListener->mStatus);
timedCallback = mTimedQueue->mWhat;
mTimedQueue->clearJob(storageId);
// test when health status is unhealthy with transport error
mDataLoader->transportError(storageId);
mIncFs->waitForPendingReadsSuccess(kUnhealthyTimestampUs);
timedCallback();
ASSERT_EQ(IStorageHealthListener::HEALTH_STATUS_UNHEALTHY_TRANSPORT, newListener->mStatus);
mTimedQueue->clearJob(storageId);
}
static std::vector<PerUidReadTimeouts> createPerUidTimeouts(
std::initializer_list<std::tuple<int, int, int, int>> tuples) {
std::vector<PerUidReadTimeouts> result;