Adding a check here to ensure that next_data_pos_ isn't modified since
initialization. After sizing the sequence buffer, this value should be
the initialized value + the size of sequence buffer.
Test: cow_api_test
Change-Id: I9c79041b72544500989860a13ca6c25830d28750
Update snapshot.cpp to grab estimate_op_buffer_size &
estimate_sequence_buffer_size from update_engine. Update v3 writer to
use these options to size the buffers appropriately.
we probably don't need the fields for merge metrics yet but will leave
it here for now
Test: th
Bug: 313962438
Change-Id: I08252ff66174de9bafaf8dbe9115d9d049084c4c
Adding a cow size info struct as writer will now need to know the op buffer
size at the time of initialization. The sequence of events is as follows
(same as estimate_cow_size but putting down here for clarity)
1. ota_from_target_files does dry run to determine cow size + ops buffer
size
2. data is passed through delta archive manifest
3. snapshot.cpp parses these fields and confgiures cowoptions struct to
pass to writer initialization
4. cow is initialized with correct sizing. Data is incrementally added
at the ends of the cow ops buffer (which is why we need to know the
sizing ahead of time)
Test: ota
Change-Id: I950e5ef82c9bd7e9bd9603b0599c930767ee3f0d
Performance of V3 COW writer is now on-par with V2 in both incremental
OTA and full OTA.
Test: th
Bug: 313962438
Change-Id: If56e0fe42367f947c513fc4c93119c3825763cb9
If the daemon is alive, detach it before explicitly terminating service.
Bug: 316876960
Test: treehugger presubmit tests
Change-Id: I94d9d1a0dab09a6b016f422c7497098abc86add8
Signed-off-by: Akilesh Kailash <akailash@google.com>
If sequence data is written and the number of ops reaches the maximum,
op data will corrupt the block data because location of block data is
stale after writing sequence data. Fix by resetting location of block
data after EmitSequenceData()
Test: th
Bug: 313962438
Change-Id: Ib53b81772ba341cdf5c240baaee7c10725a365c3
There is no need to connect to daemon for legacy VAB.
Bug: 311900089
Test: treehugger - presubmit
Change-Id: I2256cee611431ab2a286730c61092d2c546caf1e
Signed-off-by: Akilesh Kailash <akailash@google.com>
During PrepareSnapshotPartitionsForUpdate, we attempt to connect to
snapuserd with a 5s timeout, only to tell snapuserd to shutdown
immediately. If snapuserd isn't running, we will wait-out the whole 5
seconds. Change the logic to return early if socket_connect() calls
return ENOENT, indicating that snapuserd socket isn't used by any
process. This reduces allocateSpaceForPayload() time from 6s to 1s.
Test: th
Bug: 315215541
Change-Id: Ib24d7c63733a896c082ac92aaa88ad52d050a2a5
This reverts commit 9d0c06d3e2.
The failure is fixed by https://r.android.com/2725997. Workaround no
longer needed.
Test: manual
Bug: 208565717
Bug: 295944813
Change-Id: I83638938bf52a4b2b1e72743f892c579622ba9e6
This also improves atomicity of ops. If a single Add*Blocks() call
with 100 blocks failed in the middle, partially written blocks would be
discarded, and op count on disk stays unchanged. Previously wew ould
update the op count on disk with partially written blocks, causing
labels to be inaccurate.
Test: th
Bug: 313962438
Change-Id: If175a705f6ec46c1b25c52d0d9f02f01a540ce55
Current cow size estimation is computed by taking the offset of next
data write. However, during COW size estimation we repeatdly increment
op_count_max. Since data section is placed right after op section,
incrementing op_count_max has the effect of moving the beginning of
data section. next_data_pos_ is never updated in this process, causing
the final estiamte to be off.
Test: th
Bug: 313962438
Change-Id: I250dff54c470c9c20d6db33d91bac898358dee31
Since currently implementation just does an bitwise or with the
storage unit, multiple calls to set_source would result in overlapping
bits. Fix by first clear the existing storage.
Test: th
Bug: 313962438
Change-Id: Iecfe8dd244c0f65ecd3cacb0404fdc39ef836d97
Allow O_DIRECT reads on source block device.
This will further cut down the Active and Inactive file pages
during partition verification.
On Pixel 6 after incremental OTA - Post OTA reboot:
Without patch With patch Delta
--------------------------------------------------------
Inactive(File): 4992MB 3887MB ~22%
Active(File): 1465MB 1014MB ~30%
Boot time however increases from 25 to 30 seconds.
This is not yet enabled. This will be behind a sysprop flag
or for low memory devices and will be enabled later.
Additionally, set the priority of worker threads to normal.
Merge threads priority is reduced. This will help low memory
devices as tested on Pixel watch.
Bug: 311233916
Test: OTA on Pixel 6
Change-Id: Icacdef08d68e28d3062611477703e7cf393a9f10
Signed-off-by: Akilesh Kailash <akailash@google.com>
Scanning of partitions post OTA leads to memory pressure. Tune
the read-ahead of source and COW block device. This is currently
set to 32KB.
This reduces Inactive(file) and Active(file) usage during entire
duration of boot post OTA.
On Pixel 6: For incremental OTA ~400M. During boot:
Without-patch With-patch Delta
--------------------------------------------
1: Peak Inactive(file): 4469MB 3118MB ~30%
2: Peak Active(file): 985MB 712MB ~27%
No regression observed on boot time.
Additionally, cut down the number of threads to verify the partitions.
Bug: 311233916
Test: Incremental OTA on Pixel 6
Change-Id: I0b842776c36fa089c39c170fa7bf0f246e16636d
Signed-off-by: Akilesh Kailash <akailash@google.com>
This does not change the default cow version. Currently v2 is still the
default. This CL only enables OEMs to set virtual_ab_cow_version to 3
for testing purposes.
Test: th
Bug: 313962438
Change-Id: I7a328fa32283560a48604ffe02edd2551ac49a83
We can shove type into source info to save 8 bits in per cow operation.
We only need 4 bits inside of source_info to enumerate all the types of
Cow Operation. Since CowOperationV3 is not used on disk(just yet) , we
can make format changes.
This CL is mechanical:
1. Remove tye .type field from CowOperation struct
2. Add a type() getter method to CowOperation struct
3. Replace all existing usage of `type` member with the new getter
No functional changes, just refactorings.
Test: th
Bug: 304602386
Bug: 313962438
Change-Id: I85d89c71fc6afede12ea299a4a3e3b2184ea2d8b
Sync writes after every 1MB instead of flushing at the end.
Bug: 299011882
Test: Boot device off snapshots
Change-Id: If91168ec92c2b2995bdf296ea1c7d4c261b12411
Signed-off-by: Akilesh Kailash <akailash@google.com>
There's a bug previsouly where we compare return value of
GetCowOpSourceInfoData() with CowOperationType. Such bugs are possible
because cow operation enums are weakly typed integers. Turn
CowOperationType into strongly typed enum to prevent such bugs.
Test: th
Bug: 304602386
Change-Id: If6941a4740c374ed066cf0aee9e52f4df05a9b38
v3 writer to write sequence data. Sequence data will be written after
the scratch space and before the resume space. Since this is just a list
of integers, writing and reading should be trivial
Test: cow_api_test
Change-Id: If3b6b1cfa155aeb65bf693263fc373154ba8e81d
Op count should be set before we sync the header. This way subsequence
writers can initialize with the correct op buffer size
Test: cow_api_test
Change-Id: I56a0d747b3f2a1d9d582d8f9d643b81cbdd9b8d7
After we write emit a label, we need to update the number of resume
points + sequence data and op_count. Realistically we could just call
Finalize, but maybe synching these specific fields could prevent
unexpected outcomes.
Test: cow_api_test
Change-Id: I1585601a134221689ce8d5675a2a3e32f1e8a0e6
No need partition verification when device boots on snapshot without
slot switch.
This also saves couple of seconds of boot time.
Bug: 299011882
Test: Boot device on snapshot, OTA on Pixel
Change-Id: I5b781de7e0f745bbfe9646f88ca912139b2d853e
Signed-off-by: Akilesh Kailash <akailash@google.com>
Since these functions are used across both parser and writer, updating
it as inline functions in cow_format.
Test: cow_api_test
Change-Id: I9824684e3b9b48947accce935335d4019d745ae0
If any of the read-only partitions are mounted off dm-user
then certainly update is in-progress.
Bug: 308900853
Test: OTA on Pixel, reboot during OTA.
Change-Id: I36121e1d99ec7c1f1110a65fc67996190875af18
Signed-off-by: Akilesh Kailash <akailash@google.com>
We want to add a resume_point_count in the header to represent how many
resume points we've written. In the case that we've written less than
resume_buffer_size, we only want to read the valid resume points.
without these changes incremental OTA runs into segfault or have faulty
data when trying to FindResumeOp() as our resume points contain invalid
entries
Test: full ota followed by inc ota on cuttlefish
Change-Id: I0a8971955439639f2d0f39d9d518c1145ae15c3d
Update FindResumeOp to take in a uint64_t to match the value of the
caller function
Test: ota with following CL
Change-Id: I19568d119b7ebd75ea9e98970b311ae7da92ff0e
Cow size should just be wherever the last data position is written. In
v3 we no longer have a footer, so this calculation is simple. This
function is used by cow estimator
Test: cow_api_test
Change-Id: I08204e2d560b120450019a529baa41de9b8e66d5
The attached test data is a 4096 length byte run that gz compresses to
exactly 4096 bytes. This exposes an edge case in CowReader::ReadData
with v2 snapshot files.
Bug: 310191184
Test: cow_api_test
Change-Id: I35e8d7e939d607d1dc118285ebc2f636c2291a20
Add resume space to cow v3. Resume buffer goes after header and scratch
space, and is currently set to contain 4 resume points. When AddLabel is
called, the oldest label is replaced with newest one.
Parser will parse up until the last resumable op from a given label.
Test: cow_api_test
Change-Id: Ie072f245721776887d59c96dad296965ad31a5cc
Ensure that cow was written by v3 writer for the data_length check to
work. All ops written by v2 writer should go through the decompressor
path if a compressor was used.
Test: cow_api_test
Change-Id: I053d6fdaf29ef7001e68f43b45d5a3ff1a36b1c3
Add compression path back into Cow operations. Main change is that the
compression algorithm is stored in the header instead of each individaul
op. Have the writer_v3 set this algorithm when parsing options.
There looks to be a lot of code we'll be able to factor out into the
base class, but we can leave that to a later CL.
Test: cow_api_test
Change-Id: Ie9a8eceb5fbdaecae50911119c75f2e51d776a28