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

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

Snap for 11380007 from 4a63148f to 24Q2-release

Change-Id: I1d43a003f8ccdc9e7f3bd1b19cf3e485bd56a0ef
parents aaee3527 4a63148f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ message SnapshotStatus {
    // The old partition size (if none existed, this will be zero).
    uint64 old_partition_size = 10;

    // Compression algorithm (none, gz, or brotli).
    // Compression algorithm (none, gz, lz4, zstd, or brotli).
    string compression_algorithm = 11;

    // Estimated COW size from OTA manifest.
@@ -117,6 +117,9 @@ message SnapshotStatus {

    // Size of v3 operation buffer. Needs to be determined during writer initialization
    uint64 estimated_ops_buffer_size = 15;

    // Max bytes to be compressed at once (4k, 8k, 16k, 32k, 64k, 128k)
    uint64 compression_factor = 16;
}

// Next: 8
+6 −4
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ struct ResumePoint {
    // monotonically increasing value used by update_engine
    uint64_t label;
    // Index of last CowOperation guaranteed to be resumable
    uint32_t op_index;
    uint64_t op_index;
} __attribute__((packed));

static constexpr uint8_t kNumResumePoints = 4;
@@ -115,10 +115,12 @@ struct CowHeaderV3 : public CowHeader {
    uint32_t resume_point_max;
    // Number of CowOperationV3 structs in the operation buffer, currently and total
    // region size.
    uint32_t op_count;
    uint32_t op_count_max;
    uint64_t op_count;
    uint64_t op_count_max;
    // Compression Algorithm
    uint32_t compression_algorithm;
    // Max compression size supported
    uint32_t max_compression_size;
} __attribute__((packed));

enum class CowOperationType : uint8_t {
@@ -203,7 +205,7 @@ static constexpr uint64_t kCowOpSourceInfoTypeMask = (1ULL << kCowOpSourceInfoTy
struct CowOperationV3 {
    // If this operation reads from the data section of the COW, this contains
    // the length.
    uint16_t data_length;
    uint32_t data_length;

    // The block of data in the new image that this operation modifies.
    uint32_t new_block;
+4 −1
Original line number Diff line number Diff line
@@ -53,13 +53,16 @@ struct CowOptions {
    uint64_t num_merge_ops = 0;

    // Number of threads for compression
    int num_compress_threads = 0;
    uint16_t num_compress_threads = 0;

    // Batch write cluster ops
    bool batch_write = false;

    // Size of the cow operation buffer; used in v3 only.
    uint64_t op_count_max = 0;

    // Compression factor
    uint64_t compression_factor = 4096;
};

// Interface for writing to a snapuserd COW. All operations are ordered; merges
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ TEST_F(CowTestV3, CowHeaderV2Test) {

TEST_F(CowTestV3, Header) {
    CowOptions options;
    options.op_count_max = 15;
    auto writer = CreateCowWriter(3, options, GetCowFd());
    ASSERT_TRUE(writer->Finalize());

+16 −8
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ void CowWriterV3::SetupHeaders() {
}

bool CowWriterV3::ParseOptions() {
    num_compress_threads_ = std::max(options_.num_compress_threads, 1);
    num_compress_threads_ = std::max(int(options_.num_compress_threads), 1);
    auto parts = android::base::Split(options_.compression, ",");
    if (parts.size() > 2) {
        LOG(ERROR) << "failed to parse compression parameters: invalid argument count: "
@@ -129,6 +129,18 @@ bool CowWriterV3::ParseOptions() {
    header_.compression_algorithm = *algorithm;
    header_.op_count_max = options_.op_count_max;

    if (!IsEstimating() && header_.op_count_max == 0) {
        if (!options_.max_blocks.has_value()) {
            LOG(ERROR) << "can't size op buffer size since op_count_max is 0 and max_blocks is not "
                          "set.";
            return false;
        }
        LOG(INFO) << "op count max is read in as 0. Setting to "
                     "num blocks in partition "
                  << options_.max_blocks.value();
        header_.op_count_max = options_.max_blocks.value();
    }

    if (parts.size() > 1) {
        if (!android::base::ParseUint(parts[1], &compression_.compression_level)) {
            LOG(ERROR) << "failed to parse compression level invalid type: " << parts[1];
@@ -300,17 +312,11 @@ 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);
}

@@ -330,7 +336,9 @@ bool CowWriterV3::EmitBlocks(uint64_t new_block_start, const void* data, size_t
    }
    const auto bytes = reinterpret_cast<const uint8_t*>(data);
    const size_t num_blocks = (size / header_.block_size);

    if (!CheckOpCount(num_blocks)) {
        return false;
    }
    for (size_t i = 0; i < num_blocks;) {
        const auto blocks_to_write =
                std::min<size_t>(batch_size_ - cached_data_.size(), num_blocks - i);
Loading