Merge "Retry deleting dm devices."
This commit is contained in:
commit
1dc4f816bd
1 changed files with 18 additions and 2 deletions
20
cryptfs.cpp
20
cryptfs.cpp
|
@ -64,6 +64,9 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <crypto_scrypt.h>
|
#include <crypto_scrypt.h>
|
||||||
}
|
}
|
||||||
|
@ -1220,9 +1223,22 @@ static int create_crypto_blk_dev(struct crypt_mnt_ftr* crypt_ftr, const unsigned
|
||||||
}
|
}
|
||||||
|
|
||||||
static int delete_crypto_blk_dev(const std::string& name) {
|
static int delete_crypto_blk_dev(const std::string& name) {
|
||||||
|
bool ret;
|
||||||
auto& dm = DeviceMapper::Instance();
|
auto& dm = DeviceMapper::Instance();
|
||||||
if (!dm.DeleteDevice(name)) {
|
// TODO(b/149396179) there appears to be a race somewhere in the system where trying
|
||||||
SLOGE("Cannot remove dm-crypt device %s: %s\n", name.c_str(), strerror(errno));
|
// to delete the device fails with EBUSY; for now, work around this by retrying.
|
||||||
|
int tries = 5;
|
||||||
|
while (tries-- > 0) {
|
||||||
|
ret = dm.DeleteDevice(name);
|
||||||
|
if (ret || errno != EBUSY) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SLOGW("DM_DEV Cannot remove dm-crypt device %s: %s, retrying...\n", name.c_str(),
|
||||||
|
strerror(errno));
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
}
|
||||||
|
if (!ret) {
|
||||||
|
SLOGE("DM_DEV Cannot remove dm-crypt device %s: %s\n", name.c_str(), strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue