MetadataCrypt: fix timeout due to missing userdata dm device
We need to load the partition table before we can wait on the userdata
dm device because the kernel (as of [1] doesn't send the KOBJ_ADD uevent
until after the partition table is loaded. The new flow needs to be:
CreateDevice() -> ioctl(DM_DEV_CREATE)
LoadTableAndActivate() -> ioctl(DM_TABLE_LOAD)
WaitForDevice()
This patch updates create_crypto_blk_dev() to first call
LoadTableAndActivate() before WaitForDevice().
[1] https://lore.kernel.org/all/20210804094147.459763-8-hch@lst.de/
Fixes: 156d9d2293
("Pre-create userdata metadata encryption device.")
Bug: 210737958
Test: manually test booting raven with android13-5.15
Change-Id: Iab2214a62d44ba7e53b57f2cf0f08ac06c77b4fd
This commit is contained in:
parent
235d1d65f8
commit
b910e7e325
1 changed files with 4 additions and 5 deletions
|
@ -187,15 +187,14 @@ static bool create_crypto_blk_dev(const std::string& dm_name, const std::string&
|
||||||
auto& dm = DeviceMapper::Instance();
|
auto& dm = DeviceMapper::Instance();
|
||||||
if (dm_name == kDmNameUserdata && dm.GetState(dm_name) == DmDeviceState::SUSPENDED) {
|
if (dm_name == kDmNameUserdata && dm.GetState(dm_name) == DmDeviceState::SUSPENDED) {
|
||||||
// The device was created in advance, populate it now.
|
// The device was created in advance, populate it now.
|
||||||
std::string path;
|
|
||||||
if (!dm.WaitForDevice(dm_name, 5s, crypto_blkdev)) {
|
|
||||||
LOG(ERROR) << "Failed to wait for default-key device " << dm_name;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!dm.LoadTableAndActivate(dm_name, table)) {
|
if (!dm.LoadTableAndActivate(dm_name, table)) {
|
||||||
LOG(ERROR) << "Failed to populate default-key device " << dm_name;
|
LOG(ERROR) << "Failed to populate default-key device " << dm_name;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!dm.WaitForDevice(dm_name, 5s, crypto_blkdev)) {
|
||||||
|
LOG(ERROR) << "Failed to wait for default-key device " << dm_name;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else if (!dm.CreateDevice(dm_name, table, crypto_blkdev, 5s)) {
|
} else if (!dm.CreateDevice(dm_name, table, crypto_blkdev, 5s)) {
|
||||||
LOG(ERROR) << "Could not create default-key device " << dm_name;
|
LOG(ERROR) << "Could not create default-key device " << dm_name;
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue