Loading fs_mgr/fs_mgr.cpp +37 −4 Original line number Diff line number Diff line Loading @@ -850,7 +850,7 @@ bool fs_mgr_update_logical_partition(struct fstab_rec* rec) { } bool fs_mgr_update_checkpoint_partition(struct fstab_rec* rec) { if (fs_mgr_is_checkpoint(rec)) { if (fs_mgr_is_checkpoint_fs(rec)) { if (!strcmp(rec->fs_type, "f2fs")) { std::string opts(rec->fs_options); Loading @@ -860,10 +860,43 @@ bool fs_mgr_update_checkpoint_partition(struct fstab_rec* rec) { } else { LERROR << rec->fs_type << " does not implement checkpoints."; } } else if (rec->fs_mgr_flags & MF_CHECKPOINT_BLK) { LERROR << "Block based checkpoint not implemented."; } else if (fs_mgr_is_checkpoint_blk(rec)) { call_vdc({"checkpoint", "restoreCheckpoint", rec->blk_device}); android::base::unique_fd fd( TEMP_FAILURE_RETRY(open(rec->blk_device, O_RDONLY | O_CLOEXEC))); if (!fd) { PERROR << "Cannot open device " << rec->blk_device; return false; } uint64_t size = get_block_device_size(fd) / 512; if (!size) { PERROR << "Cannot get device size"; return false; } android::dm::DmTable table; if (!table.AddTarget( std::make_unique<android::dm::DmTargetBow>(0, size, rec->blk_device))) { LERROR << "Failed to add Bow target"; return false; } DeviceMapper& dm = DeviceMapper::Instance(); if (!dm.CreateDevice("bow", table)) { PERROR << "Failed to create bow device"; return false; } std::string name; if (!dm.GetDmDevicePathByName("bow", &name)) { PERROR << "Failed to get bow device name"; return false; } rec->blk_device = strdup(name.c_str()); } return true; } Loading fs_mgr/libdm/include/libdm/dm_target.h +14 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,20 @@ class DmTargetVerityString final : public DmTarget { std::string target_string_; }; // dm-bow is the backup on write target that can provide checkpoint capability // for file systems that do not support checkpoints natively class DmTargetBow final : public DmTarget { public: DmTargetBow(uint64_t start, uint64_t length, const std::string& target_string) : DmTarget(start, length), target_string_(target_string) {} std::string name() const override { return "bow"; } std::string GetParameterString() const override { return target_string_; } private: std::string target_string_; }; } // namespace dm } // namespace android Loading fs_mgr/tools/dmctl.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ using DmTarget = ::android::dm::DmTarget; using DmTargetLinear = ::android::dm::DmTargetLinear; using DmTargetZero = ::android::dm::DmTargetZero; using DmTargetAndroidVerity = ::android::dm::DmTargetAndroidVerity; using DmTargetBow = ::android::dm::DmTargetBow; using DmTargetTypeInfo = ::android::dm::DmTargetTypeInfo; using DmBlockDevice = ::android::dm::DeviceMapper::DmBlockDevice; Loading Loading @@ -108,6 +109,13 @@ class TargetParser final { std::string block_device = NextArg(); return std::make_unique<DmTargetAndroidVerity>(start_sector, num_sectors, keyid, block_device); } else if (target_type == "bow") { if (!HasArgs(1)) { std::cerr << "Expected \"bow\" <block_device>" << std::endl; return nullptr; } std::string block_device = NextArg(); return std::make_unique<DmTargetBow>(start_sector, num_sectors, block_device); } else { std::cerr << "Unrecognized target type: " << target_type << std::endl; return nullptr; Loading rootdir/init.rc +1 −0 Original line number Diff line number Diff line Loading @@ -400,6 +400,7 @@ on post-fs-data # Make sure we have the device encryption key. start vold exec - system system -- /system/bin/vdc checkpoint prepareDriveForCheckpoint /data installkey /data # Start bootcharting as soon as possible after the data partition is Loading Loading
fs_mgr/fs_mgr.cpp +37 −4 Original line number Diff line number Diff line Loading @@ -850,7 +850,7 @@ bool fs_mgr_update_logical_partition(struct fstab_rec* rec) { } bool fs_mgr_update_checkpoint_partition(struct fstab_rec* rec) { if (fs_mgr_is_checkpoint(rec)) { if (fs_mgr_is_checkpoint_fs(rec)) { if (!strcmp(rec->fs_type, "f2fs")) { std::string opts(rec->fs_options); Loading @@ -860,10 +860,43 @@ bool fs_mgr_update_checkpoint_partition(struct fstab_rec* rec) { } else { LERROR << rec->fs_type << " does not implement checkpoints."; } } else if (rec->fs_mgr_flags & MF_CHECKPOINT_BLK) { LERROR << "Block based checkpoint not implemented."; } else if (fs_mgr_is_checkpoint_blk(rec)) { call_vdc({"checkpoint", "restoreCheckpoint", rec->blk_device}); android::base::unique_fd fd( TEMP_FAILURE_RETRY(open(rec->blk_device, O_RDONLY | O_CLOEXEC))); if (!fd) { PERROR << "Cannot open device " << rec->blk_device; return false; } uint64_t size = get_block_device_size(fd) / 512; if (!size) { PERROR << "Cannot get device size"; return false; } android::dm::DmTable table; if (!table.AddTarget( std::make_unique<android::dm::DmTargetBow>(0, size, rec->blk_device))) { LERROR << "Failed to add Bow target"; return false; } DeviceMapper& dm = DeviceMapper::Instance(); if (!dm.CreateDevice("bow", table)) { PERROR << "Failed to create bow device"; return false; } std::string name; if (!dm.GetDmDevicePathByName("bow", &name)) { PERROR << "Failed to get bow device name"; return false; } rec->blk_device = strdup(name.c_str()); } return true; } Loading
fs_mgr/libdm/include/libdm/dm_target.h +14 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,20 @@ class DmTargetVerityString final : public DmTarget { std::string target_string_; }; // dm-bow is the backup on write target that can provide checkpoint capability // for file systems that do not support checkpoints natively class DmTargetBow final : public DmTarget { public: DmTargetBow(uint64_t start, uint64_t length, const std::string& target_string) : DmTarget(start, length), target_string_(target_string) {} std::string name() const override { return "bow"; } std::string GetParameterString() const override { return target_string_; } private: std::string target_string_; }; } // namespace dm } // namespace android Loading
fs_mgr/tools/dmctl.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ using DmTarget = ::android::dm::DmTarget; using DmTargetLinear = ::android::dm::DmTargetLinear; using DmTargetZero = ::android::dm::DmTargetZero; using DmTargetAndroidVerity = ::android::dm::DmTargetAndroidVerity; using DmTargetBow = ::android::dm::DmTargetBow; using DmTargetTypeInfo = ::android::dm::DmTargetTypeInfo; using DmBlockDevice = ::android::dm::DeviceMapper::DmBlockDevice; Loading Loading @@ -108,6 +109,13 @@ class TargetParser final { std::string block_device = NextArg(); return std::make_unique<DmTargetAndroidVerity>(start_sector, num_sectors, keyid, block_device); } else if (target_type == "bow") { if (!HasArgs(1)) { std::cerr << "Expected \"bow\" <block_device>" << std::endl; return nullptr; } std::string block_device = NextArg(); return std::make_unique<DmTargetBow>(start_sector, num_sectors, block_device); } else { std::cerr << "Unrecognized target type: " << target_type << std::endl; return nullptr; Loading
rootdir/init.rc +1 −0 Original line number Diff line number Diff line Loading @@ -400,6 +400,7 @@ on post-fs-data # Make sure we have the device encryption key. start vold exec - system system -- /system/bin/vdc checkpoint prepareDriveForCheckpoint /data installkey /data # Start bootcharting as soon as possible after the data partition is Loading