Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8089c63 authored by David Anderson's avatar David Anderson Committed by android-build-merger
Browse files

Merge "libsnapshot: Don't force-unmap in DeleteSnapshot()."

am: 36acd1d2

Change-Id: I256f80b5bdbb1330438a16f2e28f5551de02a7bd
parents 8644f523 36acd1d2
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -170,9 +170,8 @@ class SnapshotManager final {
    bool MapSnapshot(LockedFile* lock, const std::string& name, const std::string& base_device,
                     const std::chrono::milliseconds& timeout_ms, std::string* dev_path);

    // Remove the backing copy-on-write image for the named snapshot. If the
    // device is still mapped, this will attempt an Unmap, and fail if the
    // unmap fails.
    // Remove the backing copy-on-write image for the named snapshot. The
    // caller is responsible for ensuring that the snapshot is unmapped.
    bool DeleteSnapshot(LockedFile* lock, const std::string& name);

    // Unmap a snapshot device previously mapped with MapSnapshotDevice().
+0 −5
Original line number Diff line number Diff line
@@ -300,11 +300,6 @@ bool SnapshotManager::DeleteSnapshot(LockedFile* lock, const std::string& name)
    CHECK(lock);
    if (!EnsureImageManager()) return false;

    if (!UnmapSnapshot(lock, name)) {
        LOG(ERROR) << "Snapshot could not be unmapped for deletion: " << name;
        return false;
    }

    // Take the snapshot's lock after Unmap, since it will also try to lock.
    auto status_file = OpenSnapshotStatusFile(name, O_RDONLY, LOCK_EX);
    if (!status_file) return false;
+2 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ TEST_F(SnapshotTest, CreateSnapshot) {
    ASSERT_EQ(snapshots.size(), 1);
    ASSERT_EQ(snapshots[0], "test-snapshot");

    // Scope so delete can re-acquire the status file lock.
    // Scope so delete can re-acquire the snapshot file lock.
    {
        auto file = sm->OpenSnapshotStatusFile("test-snapshot", O_RDONLY, LOCK_SH);
        ASSERT_NE(file, nullptr);
@@ -116,6 +116,7 @@ TEST_F(SnapshotTest, CreateSnapshot) {
        ASSERT_EQ(status.snapshot_size, kDeviceSize);
    }

    ASSERT_TRUE(sm->UnmapSnapshot(lock_.get(), "test-snapshot"));
    ASSERT_TRUE(sm->DeleteSnapshot(lock_.get(), "test-snapshot"));
}