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

Commit ce57c58e authored by Daniel Zheng's avatar Daniel Zheng
Browse files

Removing compression bit from v3 op

We don't need the compression bit in v3 op since all operations will
have the same compression per COW Device and it will be stored within the COW header.
We can check to see if an operation contains compressioned data by
checking data_length and see if it's less than BLOCK_SZ

Test: 4 critical OTA paths
Change-Id: I3f86756d83bf54bf6efd15d9cb7ac064eefdd949
parent 04e4c2a6
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -201,14 +201,10 @@ static constexpr uint8_t kCowReadAheadInProgress = 1;
static constexpr uint8_t kCowReadAheadDone = 2;

static constexpr uint64_t kCowOpSourceInfoDataMask = (1ULL << 48) - 1;
static constexpr uint64_t kCowOpSourceInfoCompressBit = (1ULL << 63);

static inline uint64_t GetCowOpSourceInfoData(const CowOperation* op) {
    return op->source_info & kCowOpSourceInfoDataMask;
}
static inline bool GetCowOpSourceInfoCompression(const CowOperation* op) {
    return !!(op->source_info & kCowOpSourceInfoCompressBit);
}

struct CowFooter {
    CowFooterOperation op;
+0 −5
Original line number Diff line number Diff line
@@ -83,11 +83,6 @@ std::ostream& operator<<(std::ostream& os, CowOperation const& op) {
    os << "CowOperation(";
    EmitCowTypeString(os, op.type);
    if (op.type == kCowReplaceOp || op.type == kCowXorOp || op.type == kCowSequenceOp) {
        if (op.source_info & kCowOpSourceInfoCompressBit) {
            os << ", compressed";
        } else {
            os << ", uncompressed";
        }
        os << ", data_length:" << op.data_length;
    }
    if (op.type != kCowClusterOp && op.type != kCowSequenceOp && op.type != kCowLabelOp) {
+0 −1
Original line number Diff line number Diff line
@@ -136,7 +136,6 @@ bool CowReader::Parse(android::base::borrowed_fd fd, std::optional<uint64_t> lab
                           << v2_op.compression << ", op: " << v2_op;
                return false;
            }
            source_info |= kCowOpSourceInfoCompressBit;
        }
        new_op.source_info = source_info;
    }
+0 −6
Original line number Diff line number Diff line
@@ -143,7 +143,6 @@ TEST_F(CowTest, ReadWrite) {
    op = iter->Get();

    ASSERT_EQ(op->type, kCowReplaceOp);
    ASSERT_FALSE(GetCowOpSourceInfoCompression(op));
    ASSERT_EQ(op->data_length, 4096);
    ASSERT_EQ(op->new_block, 50);
    ASSERT_TRUE(ReadData(reader, op, sink.data(), sink.size()));
@@ -219,7 +218,6 @@ TEST_F(CowTest, ReadWriteXor) {
    op = iter->Get();

    ASSERT_EQ(op->type, kCowXorOp);
    ASSERT_FALSE(GetCowOpSourceInfoCompression(op));
    ASSERT_EQ(op->data_length, 4096);
    ASSERT_EQ(op->new_block, 50);
    ASSERT_EQ(GetCowOpSourceInfoData(op), 98314);  // 4096 * 24 + 10
@@ -276,7 +274,6 @@ TEST_F(CowTest, CompressGz) {
    std::string sink(data.size(), '\0');

    ASSERT_EQ(op->type, kCowReplaceOp);
    ASSERT_TRUE(GetCowOpSourceInfoCompression(op));
    ASSERT_EQ(op->data_length, 56);  // compressed!
    ASSERT_EQ(op->new_block, 50);
    ASSERT_TRUE(ReadData(reader, op, sink.data(), sink.size()));
@@ -523,7 +520,6 @@ TEST_F(CowTest, ClusterCompressGz) {
    std::string sink(data.size(), '\0');

    ASSERT_EQ(op->type, kCowReplaceOp);
    ASSERT_TRUE(GetCowOpSourceInfoCompression(op));
    ASSERT_EQ(op->data_length, 56);  // compressed!
    ASSERT_EQ(op->new_block, 50);
    ASSERT_TRUE(ReadData(reader, op, sink.data(), sink.size()));
@@ -541,7 +537,6 @@ TEST_F(CowTest, ClusterCompressGz) {

    sink = {};
    sink.resize(data2.size(), '\0');
    ASSERT_TRUE(GetCowOpSourceInfoCompression(op));
    ASSERT_EQ(op->data_length, 41);  // compressed!
    ASSERT_EQ(op->new_block, 51);
    ASSERT_TRUE(ReadData(reader, op, sink.data(), sink.size()));
@@ -586,7 +581,6 @@ TEST_F(CowTest, CompressTwoBlocks) {

    auto op = iter->Get();
    ASSERT_EQ(op->type, kCowReplaceOp);
    ASSERT_TRUE(GetCowOpSourceInfoCompression(op));
    ASSERT_EQ(op->new_block, 51);
    ASSERT_TRUE(ReadData(reader, op, sink.data(), sink.size()));
}