Sleep to wait for dm to create node
There appears to be a race condition from when the device mapper is
asked to create a device and when it actually appears. When we moved
ASECs to use Ext4, mount started winning the race more often.
Just insert a sleep-retry loop here to counter-act this race. We should
ideally look at the uevent replies, but it takes a bit more effort to
separate them out.
Change-Id: Ie8a5b36b1c9a26f2320a178d37312059d03a1281
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 3a63a19..76febed 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -948,6 +948,19 @@
}
}
+ /*
+ * The device mapper node needs to be created. Sometimes it takes a
+ * while. Wait for up to 1 second. We could also inspect incoming uevents,
+ * but that would take more effort.
+ */
+ int tries = 25;
+ while (tries--) {
+ if (!access(dmDevice, F_OK) || errno != ENOENT) {
+ break;
+ }
+ usleep(40 * 1000);
+ }
+
int result;
if (sb.c_opts & ASEC_SB_C_OPTS_EXT4) {
result = Ext4::doMount(dmDevice, mountPoint, true, false, true);