summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2012-05-03 13:49:46 -0700
committerKenny Root <kroot@google.com>2012-05-10 17:27:30 -0700
commitcdc2a1c83575a349ee44035de8c3b38b8b401003 (patch)
tree4503e6abcff137b04eba75958d1ac6ea5a21cb73
parente5032c42da3c33a854df0a24a7968b4ab54190b9 (diff)
downloadsystem_vold-cdc2a1c83575a349ee44035de8c3b38b8b401003.zip
system_vold-cdc2a1c83575a349ee44035de8c3b38b8b401003.tar.gz
system_vold-cdc2a1c83575a349ee44035de8c3b38b8b401003.tar.bz2
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
-rw-r--r--VolumeManager.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 3a63a19..76febed 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -948,6 +948,19 @@ int VolumeManager::mountAsec(const char *id, const char *key, int ownerUid) {
}
}
+ /*
+ * 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);