summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Ng <dave@codeaurora.org>2015-01-21 13:55:21 -0800
committerPaul Crowley <paulcrowley@google.com>2015-10-01 11:45:22 +0100
commit82fd804f8ba49399f425bf43681b9b7fe464d9a1 (patch)
tree96ef8bf58eb5e054a6ea2a214e04826d65a4004f
parent1a20a6487faad2869eaec962e4373402aa7461b3 (diff)
downloadvold-marshmallow-dr-dev.tar.gz
vold: Retry opening block device on failure when starting encryptionmarshmallow-dr-dev
The device mapper storage device node can take some time to be created; so retry. Bug: 23024596 Change-Id: Ieeb3b697f9cef72d4ea9d106750696901f0a224d
-rw-r--r--cryptfs.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/cryptfs.c b/cryptfs.c
index 1a63a5b9..33fa19b9 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -2445,11 +2445,19 @@ static int cryptfs_enable_inplace_ext4(char *crypto_blkdev,
goto errout;
}
- if ( (data.cryptofd = open(crypto_blkdev, O_WRONLY|O_CLOEXEC)) < 0) {
- SLOGE("Error opening crypto_blkdev %s for ext4 inplace encrypt. err=%d(%s)\n",
- crypto_blkdev, errno, strerror(errno));
- rc = ENABLE_INPLACE_ERR_DEV;
- goto errout;
+ // Wait until the block device appears. Re-use the mount retry values since it is reasonable.
+ int retries = RETRY_MOUNT_ATTEMPTS;
+ while ((data.cryptofd = open(crypto_blkdev, O_WRONLY|O_CLOEXEC)) < 0) {
+ if (--retries) {
+ SLOGE("Error opening crypto_blkdev %s for ext4 inplace encrypt. err=%d(%s), retrying\n",
+ crypto_blkdev, errno, strerror(errno));
+ sleep(RETRY_MOUNT_DELAY_SECONDS);
+ } else {
+ SLOGE("Error opening crypto_blkdev %s for ext4 inplace encrypt. err=%d(%s)\n",
+ crypto_blkdev, errno, strerror(errno));
+ rc = ENABLE_INPLACE_ERR_DEV;
+ goto errout;
+ }
}
if (setjmp(setjmp_env)) {