Skip to content

Commit e8a1b2d

Browse files
dvandercorpersascape
authored andcommitted
libsnapshot: Fix new partitions not transitioning in second-stage init.
Bug: 196922070 Test: vts_libsnapshot_test Change-Id: If8a7afde218fd719e4426dc1dda41f53a4e6544b
1 parent 1b7ff44 commit e8a1b2d

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

fs_mgr/libsnapshot/snapshot.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ bool SnapshotManager::PerformInitTransition(InitTransition transition,
14671467
std::vector<std::string>* snapuserd_argv) {
14681468
LOG(INFO) << "Performing transition for snapuserd.";
14691469

1470-
// Don't use EnsuerSnapuserdConnected() because this is called from init,
1470+
// Don't use EnsureSnapuserdConnected() because this is called from init,
14711471
// and attempting to do so will deadlock.
14721472
if (!snapuserd_client_ && transition != InitTransition::SELINUX_DETACH) {
14731473
snapuserd_client_ = SnapuserdClient::Connect(kSnapuserdSocket, 10s);
@@ -1524,8 +1524,15 @@ bool SnapshotManager::PerformInitTransition(InitTransition transition,
15241524
continue;
15251525
}
15261526

1527+
std::string source_device_name;
1528+
if (snapshot_status.old_partition_size() > 0) {
1529+
source_device_name = GetSourceDeviceName(snapshot);
1530+
} else {
1531+
source_device_name = GetBaseDeviceName(snapshot);
1532+
}
1533+
15271534
std::string source_device;
1528-
if (!dm.GetDmDevicePathByName(GetSourceDeviceName(snapshot), &source_device)) {
1535+
if (!dm.GetDmDevicePathByName(source_device_name, &source_device)) {
15291536
LOG(ERROR) << "Could not get device path for " << GetSourceDeviceName(snapshot);
15301537
continue;
15311538
}

fs_mgr/libsnapshot/snapshot_test.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,14 +2071,24 @@ TEST_F(SnapshotUpdateTest, AddPartition) {
20712071
// After reboot, init does first stage mount.
20722072
auto init = NewManagerForFirstStageMount("_b");
20732073
ASSERT_NE(init, nullptr);
2074+
2075+
ASSERT_TRUE(init->EnsureSnapuserdConnected());
2076+
init->set_use_first_stage_snapuserd(true);
2077+
20742078
ASSERT_TRUE(init->NeedSnapshotsInFirstStageMount());
20752079
ASSERT_TRUE(init->CreateLogicalAndSnapshotPartitions("super", snapshot_timeout_));
20762080

20772081
// Check that the target partitions have the same content.
2078-
for (const auto& name : {"sys_b", "vnd_b", "prd_b", "dlkm_b"}) {
2082+
std::vector<std::string> partitions = {"sys_b", "vnd_b", "prd_b", "dlkm_b"};
2083+
for (const auto& name : partitions) {
20792084
ASSERT_TRUE(IsPartitionUnchanged(name));
20802085
}
20812086

2087+
ASSERT_TRUE(init->PerformInitTransition(SnapshotManager::InitTransition::SECOND_STAGE));
2088+
for (const auto& name : partitions) {
2089+
ASSERT_TRUE(init->snapuserd_client()->WaitForDeviceDelete(name + "-user-cow-init"));
2090+
}
2091+
20822092
// Initiate the merge and wait for it to be completed.
20832093
ASSERT_TRUE(init->InitiateMerge());
20842094
ASSERT_EQ(UpdateState::MergeCompleted, init->ProcessUpdateState());

0 commit comments

Comments
 (0)