Skip to content

Commit f54cc3b

Browse files
dvandercorpGerrit Code Review
authored and
Gerrit Code Review
committed
Merge changes I0b9ce272,I2bb3e55b
* changes: libsnapshot: Ignore non-data ops in snapshot_reader. libsnapshot: Round compressed COW sizes to the nearest block.
2 parents 674339d + 6404d11 commit f54cc3b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

fs_mgr/libsnapshot/partition_cow_creator.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ using RepeatedPtrField = google::protobuf::RepeatedPtrField<T>;
3535
namespace android {
3636
namespace snapshot {
3737

38+
static constexpr uint64_t kBlockSize = 4096;
39+
3840
using namespace android::storage_literals;
3941

4042
// Intersect two linear extents. If no intersection, return an extent with length 0.
@@ -149,7 +151,12 @@ uint64_t PartitionCowCreator::GetCowSize() {
149151

150152
// Add an extra 2MB of wiggle room for any minor differences in labels/metadata
151153
// that might come up.
152-
return update->estimate_cow_size() + 2_MiB;
154+
auto size = update->estimate_cow_size() + 2_MiB;
155+
156+
// Align to nearest block.
157+
size += kBlockSize - 1;
158+
size &= ~(kBlockSize - 1);
159+
return size;
153160
}
154161

155162
// WARNING: The origin partition should be READ-ONLY

fs_mgr/libsnapshot/snapshot_reader.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ bool CompressedSnapshotReader::SetCow(std::unique_ptr<CowReader>&& cow) {
9090
op_iter_ = cow_->GetOpIter();
9191
while (!op_iter_->Done()) {
9292
const CowOperation* op = &op_iter_->Get();
93+
if (op->type == kCowLabelOp || op->type == kCowFooterOp) {
94+
continue;
95+
}
9396
if (op->new_block >= ops_.size()) {
9497
ops_.resize(op->new_block + 1, nullptr);
9598
}
@@ -274,7 +277,7 @@ ssize_t CompressedSnapshotReader::ReadBlock(uint64_t chunk, IByteSink* sink, siz
274277
return -1;
275278
}
276279
} else {
277-
LOG(ERROR) << "CompressedSnapshotReader unknown op type: " << op->type;
280+
LOG(ERROR) << "CompressedSnapshotReader unknown op type: " << uint32_t(op->type);
278281
errno = EINVAL;
279282
return -1;
280283
}

0 commit comments

Comments
 (0)