Merge "Do not reboot with commit failure when ext4 userdata is wiped" am: 45a3d47fd5

Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1770908

Change-Id: I4a41cf9e17224a2deb274b36ab763d2a656725af
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2023-01-08 21:57:40 +00:00 committed by Automerger Merge Worker
commit 843bda7ff7
2 changed files with 7 additions and 5 deletions

View file

@ -138,6 +138,7 @@ Status cp_startCheckpoint(int retry) {
namespace {
volatile bool isCheckpointing = false;
volatile bool isBow = true;
volatile bool needsCheckpointWasCalled = false;
@ -194,7 +195,7 @@ Status cp_commitChanges() {
return error(EINVAL, "Failed to remount");
}
}
} else if (fstab_rec->fs_mgr_flags.checkpoint_blk) {
} else if (fstab_rec->fs_mgr_flags.checkpoint_blk && isBow) {
if (!setBowState(mount_rec.blk_device, "2"))
return error(EINVAL, "Failed to set bow state");
}
@ -381,7 +382,7 @@ Status cp_prepareCheckpoint() {
LOG(INFO) << "Trimmed " << range.len << " bytes on " << mount_rec.mount_point << " in "
<< nanoseconds_to_milliseconds(time) << "ms for checkpoint";
setBowState(mount_rec.blk_device, "1");
isBow &= setBowState(mount_rec.blk_device, "1");
}
if (fstab_rec->fs_mgr_flags.checkpoint_blk || fstab_rec->fs_mgr_flags.checkpoint_fs) {
std::thread(cp_healthDaemon, std::string(mount_rec.mount_point),

View file

@ -95,7 +95,7 @@ void defaultkey_precreate_dm_device() {
}
}
static bool mount_via_fs_mgr(const char* mount_point, const char* blk_device) {
static bool mount_via_fs_mgr(const char* mount_point, const char* blk_device, bool needs_encrypt) {
// fs_mgr_do_mount runs fsck. Use setexeccon to run trusted
// partitions in the fsck domain.
if (setexeccon(android::vold::sFsckContext)) {
@ -104,7 +104,8 @@ static bool mount_via_fs_mgr(const char* mount_point, const char* blk_device) {
}
auto mount_rc = fs_mgr_do_mount(&fstab_default, const_cast<char*>(mount_point),
const_cast<char*>(blk_device), nullptr,
android::vold::cp_needsCheckpoint(), true);
needs_encrypt? false: android::vold::cp_needsCheckpoint(),
true);
if (setexeccon(nullptr)) {
PLOG(ERROR) << "Failed to clear setexeccon";
return false;
@ -350,7 +351,7 @@ bool fscrypt_mount_metadata_encrypted(const std::string& blk_device, const std::
}
LOG(DEBUG) << "Mounting metadata-encrypted filesystem:" << mount_point;
mount_via_fs_mgr(mount_point.c_str(), crypto_blkdev.c_str());
mount_via_fs_mgr(mount_point.c_str(), crypto_blkdev.c_str(), needs_encrypt);
// Record that there's at least one fstab entry with metadata encryption
if (!android::base::SetProperty("ro.crypto.metadata.enabled", "true")) {