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

Commit a33cdc99 authored by Kelvin Zhang's avatar Kelvin Zhang
Browse files

Add a function to determine cow op size

This is useful for update-engine to run on-device size estimates.
For example, when user wants to turn off compression parameter
on demand.

Test: th
Change-Id: I1e9cca88dff2492feeada3edcf0da2eb5f9430cc
parent 364d5dfb
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -329,6 +329,16 @@ struct BufferState {
    uint8_t read_ahead_state;
} __attribute__((packed));

constexpr size_t GetCowOpSize(size_t version) {
    if (version == 3) {
        return sizeof(CowOperationV3);
    } else if (version == 2 || version == 1) {
        return sizeof(CowOperationV2);
    } else {
        return 0;
    }
}

// 2MB Scratch space used for read-ahead
static constexpr uint64_t BUFFER_REGION_DEFAULT_SIZE = (1ULL << 21);