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

Commit f54cc3bb authored by David Anderson's avatar David Anderson Committed by Gerrit Code Review
Browse files

Merge changes I0b9ce272,I2bb3e55b

* changes:
  libsnapshot: Ignore non-data ops in snapshot_reader.
  libsnapshot: Round compressed COW sizes to the nearest block.
parents 674339d9 6404d11a
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ using RepeatedPtrField = google::protobuf::RepeatedPtrField<T>;
namespace android {
namespace snapshot {

static constexpr uint64_t kBlockSize = 4096;

using namespace android::storage_literals;

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

        // Add an extra 2MB of wiggle room for any minor differences in labels/metadata
        // that might come up.
        return update->estimate_cow_size() + 2_MiB;
        auto size = update->estimate_cow_size() + 2_MiB;

        // Align to nearest block.
        size += kBlockSize - 1;
        size &= ~(kBlockSize - 1);
        return size;
    }

    // WARNING: The origin partition should be READ-ONLY
+4 −1
Original line number Diff line number Diff line
@@ -90,6 +90,9 @@ bool CompressedSnapshotReader::SetCow(std::unique_ptr<CowReader>&& cow) {
    op_iter_ = cow_->GetOpIter();
    while (!op_iter_->Done()) {
        const CowOperation* op = &op_iter_->Get();
        if (op->type == kCowLabelOp || op->type == kCowFooterOp) {
            continue;
        }
        if (op->new_block >= ops_.size()) {
            ops_.resize(op->new_block + 1, nullptr);
        }
@@ -274,7 +277,7 @@ ssize_t CompressedSnapshotReader::ReadBlock(uint64_t chunk, IByteSink* sink, siz
            return -1;
        }
    } else {
        LOG(ERROR) << "CompressedSnapshotReader unknown op type: " << op->type;
        LOG(ERROR) << "CompressedSnapshotReader unknown op type: " << uint32_t(op->type);
        errno = EINVAL;
        return -1;
    }