Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Removing compression bit from v3 op
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zbw182 committed Oct 9, 2023
1 parent 04e4c2a commit ce57c58
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 16 deletions.
4 changes: 0 additions & 4 deletions fs_mgr/libsnapshot/include/libsnapshot/cow_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions fs_mgr/libsnapshot/libsnapshot_cow/cow_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion fs_mgr/libsnapshot/libsnapshot_cow/cow_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 0 additions & 6 deletions fs_mgr/libsnapshot/libsnapshot_cow/test_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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()));
Expand All @@ -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()));
Expand Down Expand Up @@ -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()));
}
Expand Down

0 comments on commit ce57c58

Please sign in to comment.