From ce57c58e6b0efd4621e1c84abfce38f4e30deff3 Mon Sep 17 00:00:00 2001 From: Daniel Zheng Date: Thu, 5 Oct 2023 13:22:52 -0700 Subject: [PATCH] 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 --- fs_mgr/libsnapshot/include/libsnapshot/cow_format.h | 4 ---- fs_mgr/libsnapshot/libsnapshot_cow/cow_format.cpp | 5 ----- fs_mgr/libsnapshot/libsnapshot_cow/cow_reader.cpp | 1 - fs_mgr/libsnapshot/libsnapshot_cow/test_v2.cpp | 6 ------ 4 files changed, 16 deletions(-) diff --git a/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h b/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h index 2a2cee2b72b5..1c92f9157fae 100644 --- a/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h +++ b/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h @@ -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; diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/cow_format.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/cow_format.cpp index 58dca64e19bd..5ab4f7a52226 100644 --- a/fs_mgr/libsnapshot/libsnapshot_cow/cow_format.cpp +++ b/fs_mgr/libsnapshot/libsnapshot_cow/cow_format.cpp @@ -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) { diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/cow_reader.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/cow_reader.cpp index bf50f2f5eb2d..0285c175526f 100644 --- a/fs_mgr/libsnapshot/libsnapshot_cow/cow_reader.cpp +++ b/fs_mgr/libsnapshot/libsnapshot_cow/cow_reader.cpp @@ -136,7 +136,6 @@ bool CowReader::Parse(android::base::borrowed_fd fd, std::optional lab << v2_op.compression << ", op: " << v2_op; return false; } - source_info |= kCowOpSourceInfoCompressBit; } new_op.source_info = source_info; } diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/test_v2.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/test_v2.cpp index 8f3f03f38f3f..100b13778a5b 100644 --- a/fs_mgr/libsnapshot/libsnapshot_cow/test_v2.cpp +++ b/fs_mgr/libsnapshot/libsnapshot_cow/test_v2.cpp @@ -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())); }