vold: Retry opening block device on failure when starting encryption
The device mapper storage device node can take some time to be created; so retry. Bug: 23024596 Change-Id: Ieeb3b697f9cef72d4ea9d106750696901f0a224d
This commit is contained in:
parent
1a20a6487f
commit
82fd804f8b
1 changed files with 13 additions and 5 deletions
18
cryptfs.c
18
cryptfs.c
|
@ -2445,11 +2445,19 @@ static int cryptfs_enable_inplace_ext4(char *crypto_blkdev,
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (data.cryptofd = open(crypto_blkdev, O_WRONLY|O_CLOEXEC)) < 0) {
|
// Wait until the block device appears. Re-use the mount retry values since it is reasonable.
|
||||||
SLOGE("Error opening crypto_blkdev %s for ext4 inplace encrypt. err=%d(%s)\n",
|
int retries = RETRY_MOUNT_ATTEMPTS;
|
||||||
crypto_blkdev, errno, strerror(errno));
|
while ((data.cryptofd = open(crypto_blkdev, O_WRONLY|O_CLOEXEC)) < 0) {
|
||||||
rc = ENABLE_INPLACE_ERR_DEV;
|
if (--retries) {
|
||||||
goto errout;
|
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)) {
|
if (setjmp(setjmp_env)) {
|
||||||
|
|
Loading…
Reference in a new issue