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

Commit bbeb9ac6 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11243032 from a07c7583 to 24Q2-release

Change-Id: I6afca415ecffd8a6079e03d70dbf6b8b653562f8
parents 35e4389c a07c7583
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -216,7 +216,23 @@ bool CowWriterV3::OpenForAppend(uint64_t label) {
    return true;
}

bool CowWriterV3::CheckOpCount(size_t op_count) {
    if (IsEstimating()) {
        return true;
    }
    if (header_.op_count + op_count > header_.op_count_max) {
        LOG(ERROR) << "Current number of ops on disk: " << header_.op_count
                   << ", number of ops attempting to write: " << op_count
                   << ", this will exceed max op count " << header_.op_count_max;
        return false;
    }
    return true;
}

bool CowWriterV3::EmitCopy(uint64_t new_block, uint64_t old_block, uint64_t num_blocks) {
    if (!CheckOpCount(num_blocks)) {
        return false;
    }
    std::vector<CowOperationV3> ops(num_blocks);
    for (size_t i = 0; i < num_blocks; i++) {
        CowOperationV3& op = ops[i];
@@ -232,11 +248,17 @@ bool CowWriterV3::EmitCopy(uint64_t new_block, uint64_t old_block, uint64_t num_
}

bool CowWriterV3::EmitRawBlocks(uint64_t new_block_start, const void* data, size_t size) {
    if (!CheckOpCount(size / header_.block_size)) {
        return false;
    }
    return EmitBlocks(new_block_start, data, size, 0, 0, kCowReplaceOp);
}

bool CowWriterV3::EmitXorBlocks(uint32_t new_block_start, const void* data, size_t size,
                                uint32_t old_block, uint16_t offset) {
    if (!CheckOpCount(size / header_.block_size)) {
        return false;
    }
    return EmitBlocks(new_block_start, data, size, old_block, offset, kCowXorOp);
}

@@ -313,8 +335,11 @@ bool CowWriterV3::EmitBlocks(uint64_t new_block_start, const void* data, size_t
}

bool CowWriterV3::EmitZeroBlocks(uint64_t new_block_start, const uint64_t num_blocks) {
    if (!CheckOpCount(num_blocks)) {
        return false;
    }
    std::vector<CowOperationV3> ops(num_blocks);
    for (uint64_t i = 0; i < ops.size(); i++) {
    for (uint64_t i = 0; i < num_blocks; i++) {
        auto& op = ops[i];
        op.set_type(kCowZeroOp);
        op.new_block = new_block_start + i;
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ class CowWriterV3 : public CowWriterBase {
    bool EmitBlocks(uint64_t new_block_start, const void* data, size_t size, uint64_t old_block,
                    uint16_t offset, CowOperationType type);
    bool CompressBlocks(size_t num_blocks, const void* data);
    bool CheckOpCount(size_t op_count);

  private:
    CowHeaderV3 header_{};
+16 −8
Original line number Diff line number Diff line
@@ -2864,15 +2864,23 @@ void SnapshotTestEnvironment::TearDown() {
}

void KillSnapuserd() {
    auto status = android::base::GetProperty("init.svc.snapuserd", "stopped");
    if (status == "stopped") {
        return;
    // Detach the daemon if it's alive
    auto snapuserd_client = SnapuserdClient::TryConnect(kSnapuserdSocket, 5s);
    if (snapuserd_client) {
        snapuserd_client->DetachSnapuserd();
    }
    auto snapuserd_client = SnapuserdClient::Connect(kSnapuserdSocket, 5s);
    if (!snapuserd_client) {
        return;

    // Now stop the service - Init will send a SIGKILL to the daemon. However,
    // process state will move from "running" to "stopping". Only after the
    // process is reaped by init, the service state is moved to "stopped".
    //
    // Since the tests involve starting the daemon immediately, wait for the
    // process to completely stop (aka. wait until init reaps the terminated
    // process).
    android::base::SetProperty("ctl.stop", "snapuserd");
    if (!android::base::WaitForProperty("init.svc.snapuserd", "stopped", 10s)) {
        LOG(ERROR) << "Timed out waiting for snapuserd to stop.";
    }
    snapuserd_client->DetachSnapuserd();
}

}  // namespace snapshot