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: 156d9d229378 ("Pre-create userdata metadata encryption device.")
Bug: 210737958
Test: manually test booting raven with android13-5.15
Change-Id: Iab2214a62d44ba7e53b57f2cf0f08ac06c77b4fd
diff --git a/MetadataCrypt.cpp b/MetadataCrypt.cpp
index 0bd6100..6550be4 100644
--- a/MetadataCrypt.cpp
+++ b/MetadataCrypt.cpp
@@ -187,15 +187,14 @@
     auto& dm = DeviceMapper::Instance();
     if (dm_name == kDmNameUserdata && dm.GetState(dm_name) == DmDeviceState::SUSPENDED) {
         // 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)) {
             LOG(ERROR) << "Failed to populate default-key device " << dm_name;
             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)) {
         LOG(ERROR) << "Could not create default-key device " << dm_name;
         return false;