Commit graph

900 commits

Author SHA1 Message Date
Daniel Zheng
e42df43569 Merge "Add binary to write basic COW" into main am: 0fc7feeafb
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2763849

Change-Id: I57488d1893a80bf44e5c3b12ec6f014691329c77
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-27 19:44:16 +00:00
Daniel Zheng
d7c5511095 Add binary to write basic COW
Adding small binary to write a simple COW for version 2. We will then
use updated reader to make sure we can read this version 2 cow. Think it
would be a good idea to keep the binary here to see how exactly we
generated the cow (useful for debugging and if we ever need to recreate
this cow)

Test: m basic_v2_cow_writer
Change-Id: I28435025b7a8280fc5c4574876cc9110b391cb0e
2023-09-26 16:51:48 -07:00
Treehugger Robot
8cd8ce3fc0 Merge "Create_cow: Hash of target blocks should not be stored." into main am: a2cd2202f0
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2759698

Change-Id: Ib652154e55c271260cbf0070af9c96f674c31709
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-24 01:59:18 +00:00
Akilesh Kailash
810274071d Create_cow: Hash of target blocks should not be stored.
Target block hash was in-correctly getting added to map thereby
overriding the source-hash.

Bug: 299011882
Test: Flash Pixel 6 Pro from A->B and from B->A
Change-Id: Ib3887c29cd6b8f2abd50e932273a5cfc2a096bd5
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-09-23 01:07:47 -07:00
Ryan Prichard
4570cf0ce2 Merge changes I7790dde8,I065907a5,Id2e82024 into main am: 532a608f58
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2758070

Change-Id: I654dd3283ac4d072649d17afa6e091da35263be1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-22 20:50:27 +00:00
Ryan Prichard
532a608f58 Merge changes I7790dde8,I065907a5,Id2e82024 into main
* changes:
  Add missing <assert.h> include
  Add missing <functional> and <vector> includes
  snapuserd_test: don't discard result of std::async
2023-09-22 19:42:45 +00:00
Ryan Prichard
93377e99e2 snapuserd_test: don't discard result of std::async
std::async returns a std::future whose destructor blocks until the
async function has completed, which defeats the purpose of using
std::async. The future needs to be kept alive to allow the function to
run concurrently.

Starting in C++20, std::async marked [[nodiscard]] to help catch this
misuse. Upgrading libc++ adds the [[nodiscard]] attribute to
std::async, so fixing this bug is necessary to keep the code compiling
after libc++ is updated.

Bug: 175635923
Test: treehugger
Test: m && m snapuserd_test
Change-Id: Id2e820248c2b6111aa843fb709e08a2c19677066
2023-09-21 17:52:18 -07:00
Daniel Zheng
822c758b84 Merge "Updating comments on cow layout" into main am: 1b52ac6efe
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2754949

Change-Id: I137135d6473e83c79dcdc9ed016ef8d61050cba0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-19 17:41:26 +00:00
Daniel Zheng
1b52ac6efe Merge "Updating comments on cow layout" into main 2023-09-19 16:32:28 +00:00
Treehugger Robot
a7d2ddb1cd Merge "Add static_assert to check sizeof off_t" into main am: 53a71f6b18
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2754946

Change-Id: I88a516d5cc76f06a142c75ea1b07dd4c21acedd9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-18 23:15:42 +00:00
Treehugger Robot
53a71f6b18 Merge "Add static_assert to check sizeof off_t" into main 2023-09-18 22:39:48 +00:00
Daniel Zheng
445d13f73f Merge "Add CowOperationV2" into main am: a10bfe1d13
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2736100

Change-Id: Ib2c7b4cdc556db7e594c2a1df8b3117ec986471b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-18 22:21:49 +00:00
Daniel Zheng
a10bfe1d13 Merge "Add CowOperationV2" into main 2023-09-18 21:30:29 +00:00
Akilesh Kailash
6ea36bd1e4 Add static_assert to check sizeof off_t
Add compile time flags which got dropped during refactoring.

Bug: 300178204
Test: Build on 32-bit userspace
Change-Id: I16be0973cb2cb2e174ff98c8b10fde27f997e4ab
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-09-18 14:09:27 -07:00
Daniel Zheng
cc44c37468 Updating comments on cow layout
Updating comments to match current format. Scratch space exists in
between header and operation

Test: th
Change-Id: I2f86e9dc4078f03370cdc38918136c894c6ca484
2023-09-18 14:02:17 -07:00
Daniel Zheng
d2ad53cf81 Add CowOperationV2
this is going to replace the current version of CowOperation and will
work with writer v2 and parser v2. This will be the on disk format of
the cow, while CowOperation will be updated to be the in memory format
of 15 bytes (implicitly will be the v3 version).

Test: m libsnapshot

Test: m libsnapshot
Change-Id: Ibd00ef014a9fc11cdf2bad97c52462db8eef9502
2023-09-18 12:47:59 -07:00
Akilesh Kailash
5fdf90777e Merge "Compile with -D_FILE_OFFSET_BITS to support 32-bit userspace" into main am: 81400915ef
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2753909

Change-Id: Ic0411e9cf2f10abdb2ce0c33f89a88b856b631ba
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-17 20:11:13 +00:00
Akilesh Kailash
0a59994c5a Compile with -D_FILE_OFFSET_BITS to support 32-bit userspace
This is to support when partition sizes are greater than 2GB (2^31)
on 32-bit userspace.

Bug: 300178204
Test: OTA on device with 32-bit userspace + product partition > 2GB
Change-Id: I7074682352d8388ed410c684cb7cb0fa346ba24c
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-09-17 09:34:43 -07:00
Daniel Zheng
d9c17e91bb Merge "Concatenate conditional" into main am: 5528777496
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2751931

Change-Id: I747433f20360ab65634db2642a8970c622d14d2f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-15 00:19:29 +00:00
Daniel Zheng
5528777496 Merge "Concatenate conditional" into main 2023-09-14 23:42:15 +00:00
Daniel Zheng
f5a280a03e Merge "Adding block sz to compressors" into main am: 7f13bc4f47
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2748856

Change-Id: I4ca4ee725b58a77aeb59144196ad98d0ac6ed0c5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-14 05:48:44 +00:00
Daniel Zheng
7f13bc4f47 Merge "Adding block sz to compressors" into main 2023-09-14 05:15:31 +00:00
Daniel Zheng
19a6aa6241 Concatenate conditional
Move two separate conditional checks to one in writer_v2

Test: m libsnapshot
Change-Id: Id70db313754b770e3fa091e9c127839b9f2a5138
2023-09-13 22:14:19 -07:00
Daniel Zheng
b309292859 Adding block sz to compressors
Adding block sz to compressor classes to prepare for variable block size
compression

Test: m libsnapshot
Change-Id: I84db20c80c0f95188f79ccc73b5c30678bd75e78
2023-09-13 22:14:19 -07:00
Akilesh Kailash
eaf919aa34 Merge "libsnapshot_cow: Prepare device to boot from pre-created snapshots" into main am: 6b78aac2cf
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2746258

Change-Id: Ifd60bf5bd01084a28a47244fefdf7867a62ac10c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-09 07:47:07 +00:00
Akilesh Kailash
bcae6b5e60 libsnapshot_cow: Prepare device to boot from pre-created snapshots
Two new API's have been added:

1: BootFromSnapshotsWithoutSlotSwitch: This will create a new marker
which indicates first-stage init to mount the partitions off snapshots.

We need this marker as during boot, there are couple of places during
mounting snapshots wherein the marker is used. However, there is no
change in the existing I/O path related to OTA.

2: PrepareDeviceToBootWithoutSnapshot: This will delete the marker so
that subsequent reboot will not have the partitions mounted without the
snapshots.

VTS tests covers both these API's. Additionally, when these
markers are present, new OTA's cannot be installed. All these
are covered in VTS tests.

===========================================================

snapshotctl: General flow to apply and revert pre-created snapshots

1: To install the pre-created snapshots:

$snapshotctl map-snapshots <directory path containing snapshots patches>

Now the device is ready to boot from snapshots.

2: After device reboots, partitions are mounted off the snapshots. There
   is no snapshot-merge.

3: In order to go back to previous build:

$snapshotctl revert-snapshots

Now the device is ready to boot from base build.

4: After device reboots back to previous build, all the snapshot states
   and COW images are removed.

============================================

Additional commands:

To delete the pre-created snapshots:

$snapshotctl delete-snapshots

======================================

Tested it on Pixel 6 Pro between two builds which are ~24 hours apart.

1: Creating snapshots on a linux-host - ~4-6 seconds
2: Applying pre-created snapshots - ~10-15 seconds (includes intermediate
   transfer of patches to the device). This depends on the size of snapshot patches.
3: Device reboot - ~12-14 seconds.

Bug: 299011882
Test: 1: Apply pre-created snapshots
2: Reboot device: Verify new build
3: Apply OTA when partitions are mounted of snapshots and verify OTA
   fails.
3: Revert-snapshot and reboot.
4: Verify device goes back to base build.

Full OTA on Pixel. vts_libsnapshot_test

Change-Id: I36a72d973d8f70ae49773ebd45dd996fac22a4e3
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-09-08 23:09:45 -07:00
Julien Desprez
49b04b7a82 Merge "Reland exporting create_snapshot" into main am: 5b3f7c3283
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2745757

Change-Id: I0b33232aa996505cb8003312d8213fbc89edba98
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-07 21:20:18 +00:00
Julien Desprez
670f983f45 Reland exporting create_snapshot
Previous attempt: aosp/2743815
Disabled on windows & mac.

Test: presubmit, (previously failed build: https://android-build.googleplex.com/builds/abtd/run/L06100000962955289?referrer=email now passing)
Bug: 290951369
Change-Id: I3d8084c13d843ea5919e3b50a0513faf386ccfed
2023-09-07 17:05:50 +00:00
Marvin Ramin
ec37283a03 Merge "Revert "Export create_snapshot to sdk targets"" into main am: b03378fe71
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2743796

Change-Id: I198fec6b385cf95e70b8e678e23133d5bf514506
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-07 10:04:06 +00:00
Marvin Ramin
a4d34c5715 Revert "Export create_snapshot to sdk targets"
This reverts commit bf72b25a07.

Reason for revert: DroidMonitor: Culprit for b/299411079

Change-Id: I9d46abcbcc81d43fde23d4431b6757d3520d4b2c
2023-09-07 09:03:25 +00:00
Julien Desprez
3da4bba60b Merge "Export create_snapshot to sdk targets" into main am: 2095008f32
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2743815

Change-Id: I009bd84211743e89c1ee47be55cc68add72f8328
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-07 01:13:48 +00:00
Julien Desprez
bf72b25a07 Export create_snapshot to sdk targets
Similar to fastboot binaries. This will ease the
automation to use this tool

Test: presubmit
Bug: 290951369
Change-Id: I5c879acc7cdecbafebfa074ef76034403cb0cd72
2023-09-06 11:10:03 -07:00
Treehugger Robot
8857bc99b7 Merge "snapshotctl: Create and write pre-created snapshots" into main am: 51e3b9cbca
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2739093

Change-Id: Ibcbdd6add41873d40c913f6ef8b73f59211de914
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-06 09:36:47 +00:00
Akilesh Kailash
340acbad36 Merge "create_snapshot: Create snapshot patch comparing two partition images" into main am: 3c41230654
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2738233

Change-Id: I313a119875acd8ddb6f13a5f6649bfc014459f90
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-09-06 06:29:44 +00:00
Akilesh Kailash
9ccb84a8ba snapshotctl: Create and write pre-created snapshots
Extend snapshotctl binary on the device
to create and apply pre-created snapshots.

snapshotctl map-snapshots <directory-where snapshot patches are present>

1: snapshotctl creates the block device based on the size of the
       snapshot patches.

2: snapshotctl will copy the data to the block device.

unmap and delete snapshots will cleanup.

No change in libsnapshot library except with minor refactoring.

This patch doesn't yet prepare the device to reboot from these
snapshots.

On Pixel 6 Pro, applying pre-created snapshots for all partitions
takes ~3 seconds wherein the delta between two builds are 24 hours apart.

Bug: 299011882

Test: snapshotctl map-snapshots /data/test-snapshots/
snapshotctl unmap-snapshots
snapshotctl delete-snapshots

Change-Id: I98a0fbd9cf7234c2188bad85cdd092ded8997710
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-09-06 06:02:51 +00:00
Akilesh Kailash
214d62e3f7 create_snapshot: Create snapshot patch comparing two partition images
This is a host based tool wherein it compares two Android images and generates snapshot patches which are similar to Android OTA format.

There are few advantages:

1: All the computation of snapshot logic is pushed onto the host.
2: Each partition can have different compression algorithm.
3: All the libsnapshot_cow changes can be tested very quickly.

Here is the test run. This compares two builds which are 24 hours apart.

```

create_snapshot --source=$ANDROID_PRODUCT_OUT/system.img --target=./images/system.img --compression="zstd" &
create_snapshot --source=$ANDROID_PRODUCT_OUT/product.img --target=./images/product.img --compression="lz4" &
create_snapshot --source=$ANDROID_PRODUCT_OUT/vendor.img --target=./images/vendor.img &
create_snapshot --source=$ANDROID_PRODUCT_OUT/system_ext.img --target=./images/system_ext.img --compression="gz" &
create_snapshot --source=$ANDROID_PRODUCT_OUT/vendor_dlkm.img --target=./images/vendor_dlkm.img &

echo "Waiting for snapshot patch creation"
wait $(jobs -p)
echo "Snapshot patch creation completed"
```

========================================
Waiting for snapshot patch creation
Snapshot patch: vendor_dlkm.patch created successfully
Snapshot patch: vendor.patch created successfully
Snapshot patch: system_ext.patch created successfully
Snapshot patch: product.patch created successfully
Snapshot patch: system.patch created successfully
Snapshot patch creation completed

real	0m3.848s
user	0m14.239s
sys	0m8.045s
========================================

It takes ~4 seconds to generate the snapshot patches on the host. Snapshot patches are named as <partition-name>.patch.

Bug: 299011882
Test: create_snapshot between two builds as mentioned above.
Change-Id: Ic87dd3349a866b5626fa03f1f879f417a8116cc2
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-09-05 15:42:11 -07:00
David Anderson
b8cf4b820f Merge "snapuserd: Add snapuserd_test to presubmit and VTS." into main am: 5b91ae9f4e
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2698913

Change-Id: Ia766fe856c9f507def6a4912f05a85c1c0c89631
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-29 23:12:42 +00:00
David Anderson
5b91ae9f4e Merge "snapuserd: Add snapuserd_test to presubmit and VTS." into main 2023-08-29 22:10:27 +00:00
Xin Li
4484eb1bfd Merge Android U (ab/10368041)
Bug: 291102124
Merged-In: I849958d9e9de3be48e32f57acc7b3526e184482c
Change-Id: Ic765b54aa981b6370b5dff6b4cf046bbe9fbdbaf
2023-08-25 13:54:47 -07:00
David Anderson
c718295a58 Merge "snapuserd: Fix race condition in MergeWorker::WaitForMergeBegin." into main 2023-08-25 16:09:35 +00:00
Treehugger Robot
c728c39121 Merge "Update bug component from Android Systems to OTA client" into main 2023-08-24 11:13:12 +00:00
Daniel Zheng
f278b54731 Merge "Add unit test for cow compressor performance" into main 2023-08-23 19:45:55 +00:00
Daniel Zheng
eb70926ad6 Add unit test for cow compressor performance
Adding test to measure performance differences between cow compression
algorithms + levels. This gives us an easy way to test performance
between the tunables without having to run an OTA every time. Ultimately we want this to be separate from
cow_api_test so it would be nice to have this be it's own binary. Can
add some tests for decompression + compressing from a part of an actual
img file too.

Test: m cow_benchmark
Change-Id: Iba92ae3c0b2ad4ff6f842556b701b223d7d37823
2023-08-23 10:20:15 -07:00
Daniel Zheng
b497e6f317 Fix one liner
Ensuring that the expression is evaluated before being outputed. In
response to comment from aosp/2708333

Test: th
Change-Id: I073c143f1c4e32af11e235ce782947b250117dc5
2023-08-22 14:45:15 -07:00
Alessio Balsini
d35715c021 Update bug component from Android Systems to OTA client
It's been a while since the Android Systems bug component does not
access the creation of new bugs for triage, instead, new bugs must
be created in the subcomponents of the team.
This change updates the bug component originally associated to this
subsystem from the Android Systems' 30545 to OTA client's 1014951.

Test: none
Bug: 270571229
Change-Id: I5455086bf777dd20abb2e2f0360f76a003120126
Signed-off-by: Alessio Balsini <balsini@google.com>
2023-08-22 10:18:47 +01:00
Daniel Zheng
4215f1a9fc Merge changes I5032300e,Idec3e051,I09be447b into main
* changes:
  ZSTD read from wrong buf
  Fix warning
  Fix zstd optimization api usage
2023-08-17 22:32:35 +00:00
Daniel Zheng
36882e98b4 ZSTD read from wrong buf
Fix zstd to read from ignore_buf rather than buf since that is where we
are first copying the date

Test: zstd ota
Change-Id: I5032300e4628ecd7e49f1fa9f76dc9a828fb58e6
2023-08-17 14:18:56 -07:00
Daniel Zheng
21aab6cb83 Fix warning
remove some unused headers and fix warning: Moving a temporary object prevents copy elision

Test: m libsnapshot
Change-Id: Idec3e051837dab5f1b95e677d1cdb09e9a57e73e
2023-08-17 14:18:56 -07:00
Daniel Zheng
96b78feec1 Fix zstd optimization api usage
ZSTD_c_windowLog should be set as log base 2 of max block size. Changing
hardcoded value to be determined by this variable.

Test: m libsnapshot
Change-Id: I09be447b7f1e95cb72a6a42eddb4035f61a43aad
2023-08-17 14:18:55 -07:00
Daniel Zheng
7bb24d3274 Merge "Removing extra string creation for log" into main 2023-08-17 18:19:10 +00:00