Introduce postMount() VolumeBase helper.
When we're mounting a private volume, we create stacked emulated volumes on top of it. Due to the ordering there, we would broadcast the emulated volumes being created *before* the "mounted" status update. This in turn could cause us to try and mount these emulated volumes before the underlying private volume is really mounted. This is problematic in particular on devices that support a filesystem keyring, where we need to do some additional setup before the devices can be used. While we could modify StorageManagerService to delay the mount, a safer fix at this stage of the release is to just fix the ordering of these events. To achieve that, add a simple postMount() helper, that is called after a succesful mount. This allows us to setup the volume properly before trying to mount any stacked volumes. Bug: 151079464 Test: atest AdoptableHostTest Change-Id: I2cc4113d4d71d89aa629bb9c0fa9be441355c079
This commit is contained in:
parent
fc7b6697b4
commit
5ec8658abc
4 changed files with 11 additions and 2 deletions
|
@ -177,6 +177,10 @@ status_t PrivateVolume::doMount() {
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrivateVolume::doPostMount() {
|
||||||
auto vol_manager = VolumeManager::Instance();
|
auto vol_manager = VolumeManager::Instance();
|
||||||
std::string mediaPath(mPath + "/media");
|
std::string mediaPath(mPath + "/media");
|
||||||
|
|
||||||
|
@ -189,8 +193,6 @@ status_t PrivateVolume::doMount() {
|
||||||
addVolume(vol);
|
addVolume(vol);
|
||||||
vol->create();
|
vol->create();
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t PrivateVolume::doUnmount() {
|
status_t PrivateVolume::doUnmount() {
|
||||||
|
|
|
@ -49,6 +49,7 @@ class PrivateVolume : public VolumeBase {
|
||||||
status_t doCreate() override;
|
status_t doCreate() override;
|
||||||
status_t doDestroy() override;
|
status_t doDestroy() override;
|
||||||
status_t doMount() override;
|
status_t doMount() override;
|
||||||
|
void doPostMount() override;
|
||||||
status_t doUnmount() override;
|
status_t doUnmount() override;
|
||||||
status_t doFormat(const std::string& fsType) override;
|
status_t doFormat(const std::string& fsType) override;
|
||||||
|
|
||||||
|
|
|
@ -232,9 +232,14 @@ status_t VolumeBase::mount() {
|
||||||
status_t res = doMount();
|
status_t res = doMount();
|
||||||
setState(res == OK ? State::kMounted : State::kUnmountable);
|
setState(res == OK ? State::kMounted : State::kUnmountable);
|
||||||
|
|
||||||
|
if (res == OK) {
|
||||||
|
doPostMount();
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VolumeBase::doPostMount() {}
|
||||||
|
|
||||||
status_t VolumeBase::unmount() {
|
status_t VolumeBase::unmount() {
|
||||||
if (mState != State::kMounted) {
|
if (mState != State::kMounted) {
|
||||||
LOG(WARNING) << getId() << " unmount requires state mounted";
|
LOG(WARNING) << getId() << " unmount requires state mounted";
|
||||||
|
|
|
@ -120,6 +120,7 @@ class VolumeBase {
|
||||||
virtual status_t doCreate();
|
virtual status_t doCreate();
|
||||||
virtual status_t doDestroy();
|
virtual status_t doDestroy();
|
||||||
virtual status_t doMount() = 0;
|
virtual status_t doMount() = 0;
|
||||||
|
virtual void doPostMount();
|
||||||
virtual status_t doUnmount() = 0;
|
virtual status_t doUnmount() = 0;
|
||||||
virtual status_t doFormat(const std::string& fsType);
|
virtual status_t doFormat(const std::string& fsType);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue