Migrating data sometimes leaves emulated unmounted

Sometimes migrating data fails to mount the target
volume after operation is finished.

MoveTask is running in its own thread, copying data
between external card and internal memory.

After copying the data the method "bringOnline" is
run. This method destroys and creates the volumes.

When VolumeBase::create() is run it will notify
MountService, who upon receiving this notification
will send a mount command to mount the new primary
storage.

This command will sometimes run before
setState(State::kUnmounted); is called on the newly
created volume. This will cause the mount command to
fail.

VoldConnector: SND -> {10 volume mount emulated 3 -1}
vold : emulated flags change requires state unmounted or unmountable
vold : emulated user change requires state unmounted or unmountable
vold : emulated mount requires state unmounted or unmountable

Lock bringOnline so no volume commands will be processed
until volumes are (re-)created and have correct state.

Bug: 26322200
Change-Id: I4aba85c226d904c42ae9edcdfec21619218939d6
This commit is contained in:
Henrik Baard 2015-11-26 12:05:13 +01:00 committed by Jeff Sharkey
parent f09a89a7d6
commit 7f52bca485

View file

@ -182,8 +182,11 @@ void MoveTask::run() {
// Step 1: tear down volumes and mount silently without making
// visible to userspace apps
bringOffline(mFrom);
bringOffline(mTo);
{
std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getLock());
bringOffline(mFrom);
bringOffline(mTo);
}
fromPath = mFrom->getInternalPath();
toPath = mTo->getInternalPath();
@ -201,8 +204,11 @@ void MoveTask::run() {
// NOTE: MountService watches for this magic value to know
// that move was successful
notifyProgress(82);
bringOnline(mFrom);
bringOnline(mTo);
{
std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getLock());
bringOnline(mFrom);
bringOnline(mTo);
}
// Step 4: clean up old data
if (execRm(fromPath, 85, 15) != OK) {
@ -213,8 +219,11 @@ void MoveTask::run() {
release_wake_lock(kWakeLock);
return;
fail:
bringOnline(mFrom);
bringOnline(mTo);
{
std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getLock());
bringOnline(mFrom);
bringOnline(mTo);
}
notifyProgress(kMoveFailedInternalError);
release_wake_lock(kWakeLock);
return;