Commit graph

2802 commits

Author SHA1 Message Date
David Anderson
a5df9e5db1 Merge "Add a test for bug 198265278." 2021-10-08 19:29:16 +00:00
Akilesh Kailash
71c680226d Merge changes from topic "vabc-merge-phase-1"
* changes:
  snapuserd: Refactor buffer allocation code
  snapuserd: Implement snapshot merge
  snapuserd: Move dm-snapshot-merge related code
2021-10-08 06:45:38 +00:00
David Anderson
af09c15049 Merge "adds LO_FLAGS_AUTOCLEAR for loop device of zram backing device" 2021-10-07 15:49:18 +00:00
Akilesh Kailash
fb964a1fbe snapuserd: Refactor buffer allocation code
Since there is no change in the buffer allocation
code with respect to snapshots in user-space, refactor
it so that we have a common code base.

Bug: 193863397
Test: Build
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I3a7b3d319f6d1532b1bb63af9884b64e1346bb50
2021-10-07 07:18:45 +00:00
Akilesh Kailash
228f6a099c snapuserd: Implement snapshot merge
Implement snapshot merge in the daemon. Following
are the important changes:

1: Spin up merge thread which does merging in user-space.
2: For ordered ops (COPY and XOR), read-ahead thread is used.
3: Read-ahead thread will read a fixed set of COW ops and cache
them in memory. Furthermore data is saved in scratch space buffer
in COW device.
4: No change in scratch space buffer - default 2MB buffer is allocated.
5: Merge thread and Read-ahead thread will work in lock step for merging
ordered ops.
6: Once the ordered ops are merged, REPLACE and XOR operations are
merged.
7: If there is a crash during merge, COW header tracks the number of
operations merged. No change in this code path.
8: Merge thread requires Base device for merging as opposed to using
the source device. Hence, while initializng the merge threads,
libsnapshot will have to pass the "Base" device to the daemon. This
is the same "Base" device which is passed to dm-snapshot during
snapshot creation.

Patch does not handle any communication with dm-user yet.

Bug: 193863397
Bug: 193863280
Bug: 193862712
Test: snapuserd_test on CF
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I14aab6eaa07ac68f2a3a23516ed9ba6567a35734
2021-10-07 07:09:28 +00:00
Akilesh Kailash
46e15bd18b snapuserd: Move dm-snapshot-merge related code
Move all the snapuserd files related to dm-snapshot/dm-snapshot-merge
to a seperate directory. We will have a logical seperation
to maintain user-space merge code.

No code changes other than moving files around.

Bug: 193863397
Test: Build
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Ide0d824bb19f9d870ec32699d0a37de0e5d6ce81
2021-10-07 07:08:45 +00:00
Akilesh Kailash
ba097d2cd2 Merge "Revert "snapuserd: Handle real time signal 36"" 2021-09-30 16:52:10 +00:00
Akilesh Kailash
fec60563c4 Revert "snapuserd: Handle real time signal 36"
This reverts commit 8d3b31fe68.

Reason for revert: With https://r.android.com/1840754, bionic will handle the real time signal for statically linked binaries.

Change-Id: I81f0892f1734c7ecfb604820a8894506df8618b3
2021-09-30 07:24:11 +00:00
Treehugger Robot
19dc4d413f Merge "Add OWNERS for VTS module vts_libdm_test" 2021-09-30 03:46:00 +00:00
Yiming Pan
47af156ee0 Add OWNERS for VTS module vts_libdm_test
Each VTS module is required to have OWNERS file. The ownership is based on
go/vts-owners. For more information about ownership policy, please visit
go/xts-owners-policy.

Test: Tree Hugger
Bug: 143903671
Change-Id: Id2911fd62841bf5622607f9deeb50c7cf1413b1b
2021-09-29 14:46:24 -07:00
Akilesh Kailash
7ec205920c Merge "snapuserd: Handle real time signal 36" 2021-09-29 21:04:41 +00:00
Yifan Hong
d6fc145473 Merge "libsnapshot_fuzzer: allow ENXIO." 2021-09-29 20:58:10 +00:00
Treehugger Robot
3ad79c8ff7 Merge "Add VerifyMergeOps to ISnapshotWriter" 2021-09-29 20:06:40 +00:00
Akilesh Kailash
8d3b31fe68 snapuserd: Handle real time signal 36
Add a signal handler for real time signal 36 which
is primarily used by profilers. Default action is to
terminate the daemon if there is no signal handler. We
don't want daemon to get terminated, hence just capture
the signal and ignore it.

Bug: 201497662
Test: cow_snapuserd_test, pkill -36 snapuserd
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Ife5a8bdb7344956076bc4223c19a126b90a00706
2021-09-29 17:35:49 +00:00
Kelvin Zhang
8c77196a74 Add VerifyMergeOps to ISnapshotWriter
It turns out update_engine never gets a ICowReader instance... it only
gets a generic FileDescriptor. So bring this function all the way up to
ISnapshotWriter interface.

Test: th
Change-Id: I7d17b9537f97282c99203b5cc13892e5daa1be4c
2021-09-29 10:04:11 -07:00
Yifan Hong
10e5e5979a libsnapshot_fuzzer: allow ENXIO.
This is an accepted error code.

Fixes: 170395454
Test: run fuzzer

Change-Id: I93862c44f434878a6e1a1ed15a94c92d4a60611b
2021-09-28 19:32:55 -07:00
Treehugger Robot
2d7301d235 Merge "Replace test_min_api_level with test_options.min_shipping_api_level" 2021-09-29 00:02:04 +00:00
Justin Yun
43678b17a5 Replace test_min_api_level with test_options.min_shipping_api_level
Test options for the api levels are moved to test_options.
test_min_api_level property will be removed with this change.

Bug: 187258404
Test: build
Change-Id: Id943566de2ac693b5955bd84a8463e5013a8bb0f
2021-09-28 20:35:09 +09:00
Kelvin Zhang
f2e1f20fd7 Add VerifyMergeOps() to CowReader interface
update_engine only sees ICowReader, so in order for update_engine to
consume this API, it has to be in the base interface class.

Test: th
Change-Id: I9100b6aa1db6eb6a884752620098172bdd51f200
2021-09-27 18:26:23 -07:00
David Anderson
2374bd48ed Add a test for bug 198265278.
This test uses dependency injection to cause a failure in
QuerySnapshotStatus. We expect ProcessUpdateState to return MergeFailed.
The test also checks that if the merge is attempted again, it can
succeed.

Some duplicated code has also been factored out into the test harness.

Bug: 198265278
Test: vts_libsnapshot_test gtest
Change-Id: I6ccb434afa0e5ebf6781b2cec5277e3b7c210b77
2021-09-27 17:29:45 -07:00
Liangcai Fan
d884ba5916 adds LO_FLAGS_AUTOCLEAR for loop device of zram backing device
Userdata spaces leak when zram writeback is enable and repeatedly kill
system_server(restart android).
The reason is that per_boot‘s inode is hold by loop device
although per_boot is deleted by user which become orphan inode in system.

Adds LO_FLAGS_AUTOCLEAR for loop device of zram backing device,
so loop device can release resouce.

Bug: 200904398

Change-Id: Ifeee9c0b58b10cdf7698077fbcaf54d5faccc3b1
Signed-off-by: Liangcai Fan <liangcai.fan@unisoc.com>
Signed-off-by: Hongyu Jin <hongyu.jin@unisoc.com>
Signed-off-by: Jing Xia <jing.xia@unisoc.com>
2021-09-26 10:07:50 +08:00
Treehugger Robot
5125c62cf8 Merge "libsnapshot: Add function to verify merge sequence" 2021-09-25 00:50:49 +00:00
Daniel Rosenberg
1e3fa94657 libsnapshot: Add function to verify merge sequence
This adds a function that verifies that the merge sequence does not
attempt to use blocks that have already been overwritten. It prints the
first such conflict to the logs.

Additionally, this adds a forwards merge iterator, and the ability to
ignore current progress in a merge for the purposes of verifying the
whole sequence.

This can be accessed via the VerifyMergeOps Function in Cow Reader, or
by using inspect_cow -v [COWFILE]

Include merged ops in inspect_cow listing with -a, and view ops in merge
order with -n

Bug: 200076590
Test: cow_api_test.InvalidMergeOrderTets
Change-Id: I893b9f8a8803cb6dd53225ec34224167b9fe2fda
2021-09-24 16:03:17 -07:00
David Anderson
5cd741583f Merge "libdm, libsnapshot: Add a virtual interface for DeviceMapper." 2021-09-23 22:25:46 +00:00
David Anderson
efec0abf4a libdm, libsnapshot: Add a virtual interface for DeviceMapper.
It is difficult to test libsnapshot failures because there is no way to
inject failure scenarios into the kernel's device-mapper. Exposing a
virtual interface will allow this kind of testing via dependency
injection.

Bug: 199785546
Test: builds, tests pass
Change-Id: I5add0c7e24f7fa2853114eaeda7c479eaa4e0552
2021-09-20 22:13:20 -07:00
Bob Badour
fe9d02890c Add LOCAL_LICENSE_KINDS to system/core/fs_mgr
Added Android-Apache-2.0 to fs_mgr/libsnapshot/scripts/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: If966409962d564c1cfec901af2f2b78e891b7fca
2021-09-15 10:57:11 -07:00
Akilesh Kailash
6f9672291c Merge "libsnapshot: Error handling after QuerySnapshotStatus" 2021-09-15 16:31:33 +00:00
Akilesh Kailash
3ad55a9690 libsnapshot: Error handling after QuerySnapshotStatus
QuerySnapshotStatus will capture the error codes
from dm-snapshot if there are any snapshot related
failure. Handle the error codes and fail the
QuerySnapshotStatus call.

Validate snapshot status in MapSnapshot(). If
the mode is set to Persistent and snapshot status
is in Merging state, then forcefully set the
mode to Merge state.

Bug: 198265278
Test: Full/incremental OTA
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I779184f1998b23edacd6e780acf2676442004340
2021-09-14 06:47:06 +00:00
David Anderson
7f994f4cfb libsnapshot: Fix new partitions not transitioning in second-stage init.
Bug: 196922070
Test: vts_libsnapshot_test
Change-Id: If8a7afde218fd719e4426dc1dda41f53a4e6544b
2021-09-13 19:42:58 -07:00
Akilesh Kailash
542bf0bfed snapuserd: I/O request on sectors not mapping to any COW op
If there is an I/O request which doesn't map to any
COW Operation in the vector mapping, then that request
is an EOF request and should not be discarded with an
I/O error.

Bug: 198787355
Test: Incremental OTA
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I241ee11d7cf540854aa4a232bc1b18da43d41e05
2021-09-11 06:06:25 +00:00
Treehugger Robot
237ec60d0b Merge "Skipping CompareVBMeta() in VerifyVBMetaDataError test case" 2021-09-10 04:16:02 +00:00
Yiming Pan
15a97fc951 Merge "Add OWNERS for VTS module vts_core_liblp_test" 2021-09-09 19:19:32 +00:00
Bowgo Tsai
ccd4b77440 Skipping CompareVBMeta() in VerifyVBMetaDataError test case
It has some random errors on the cloud, so skpping them for now.

Bug: 187303962
Test: atest --host \
      libfs_avb_internal_test:libfs_avb_internal_test.AvbUtilTest#VerifyVBMetaDataError
Change-Id: I658e3f052f99af645bdd44087f519d58acbe5641
2021-09-09 12:44:06 +08:00
Daniel Rosenberg
0518f8cb19 snapuserd: Fix PrepareReadAhead
When checking the instead of current, and when checking the position, we could underflow,
which would get caught by UBSAN

Bug: 177104308
Test: Map cow file with xor op or copy op at position 0
Change-Id: I4fba1982419e08b58759ec893e238175d245dbfc
2021-09-02 14:13:29 -07:00
Kelvin Zhang
bb0a7642d6 Fix a typo
this check should be performed on newly returned `op` instead of
`cow_op`

Test: th
Change-Id: Ia0812a1126d3e0bdfaff82859eb4b4a066a73bff
2021-09-02 14:12:19 -07:00
Tianjie Xu
055abbb4d6 Merge "Dump the root digest of hashtree for dm-verity partitions" 2021-09-01 17:47:11 +00:00
Treehugger Robot
d95a49f555 Merge changes I3968ff53,I0029838d
* changes:
  inspect_cow: Add -l option to show all ops
  inspect_cow: Add -o to view Sequence Data
2021-09-01 00:35:01 +00:00
Tianjie
10bec65ca8 Dump the root digest of hashtree for dm-verity partitions
It's requested by the partner engineering team to uniquely
identify a partition.

Bug: 197973981
Test: boot the device and check props
Change-Id: I0f7aa34dd0087f0698fe90b9df6c0eae06fc4f5d
2021-08-30 17:11:02 -07:00
Treehugger Robot
f98bcdbac0 Merge "[fs_mgr] Use shared libutils for remount" 2021-08-30 22:20:27 +00:00
Pirama Arumuga Nainar
cdf919d1f0 [fs_mgr] Use shared libutils for remount
Bug: http://b/197965342

remount depends on libbinder.so which already depends on libutils.so.
When linking remount with libutils.a, the linker tries to fetch objects
from libutils.a to redefine undefined symbols in libbinder.so.  This
causes linker failure with upstream LLD.  Switching to shared
libutils.so instead doesn't increase the dependency closure for remount.

Test: build with aosp/1809741 which has lld with the above behavior.
Change-Id: I858042a08babe2c2db1fc8c7eeb5de62dda5f328
2021-08-30 12:18:08 -07:00
Daniel Rosenberg
b7885099b4 inspect_cow: Add -l option to show all ops
This makes inspect_cow not list all ops by default. Instead you must
pass -l to do this. This allows for viewing other data without being
overwhelmed bt the cow listings.

Test: inspect_cow with no flags, -l, and -lo
Change-Id: I3968ff53acb4e645a16ac5b09c5dee8374946f55
2021-08-27 15:40:53 -07:00
Daniel Rosenberg
f34f18e0a1 inspect_cow: Add -o to view Sequence Data
This allows inspecting sequence op data while viewing cow ops. Data will
be displayed per op.

Test: inspect_cow -o [CowFile]
Change-Id: I0029838ddc265c1aaeba2bbfa70241dea0b8ff20
2021-08-27 15:40:53 -07:00
David Anderson
dc3afaf54a libsnapshot: Fix missing source partitions when adding a new partition.
When adding a new partition, don't attempt to map a source partition
during boot, because none exists. Instead use the base device.

Bug: 196922070
Test: vts_libsnapshot_test
Change-Id: Ice6015237b0a76a0210819994433e52159376393
2021-08-24 00:28:11 -07:00
Akilesh Kailash
b504369754 Merge "snapuserd: pass arguments by reference" 2021-08-19 01:12:22 +00:00
Akilesh Kailash
9cc14503e0 snapuserd: pass arguments by reference
Bug: 193863442
Test: Build
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I5c3ad108b0ae08c411936962fc859415febac2b6
2021-08-18 22:47:04 +00:00
Elliott Hughes
0589b7eb94 Merge "Split up the system/core/ TEST_MAPPING." 2021-08-18 16:25:15 +00:00
Treehugger Robot
0e13b0ebb4 Merge "fs_mgr: Separate the required modules of core and recovery variants" 2021-08-18 05:33:13 +00:00
David Anderson
9784f5ae1c Merge "Support multiple fstab configs for one mount point" 2021-08-17 01:39:59 +00:00
Elliott Hughes
22e082e87a Split up the system/core/ TEST_MAPPING.
A lot of things had moved out of system/core/ without their TEST_MAPPING
entries having gone with them, reducing the amount of presubmit coverage
for those things.

In order to reduce the likelihood of that happening again, I've pushed
all that remained in the system/core/ TEST_MAPPING down into the
individual subdirectories.

Test: treehugger
Change-Id: Ib75d65f9200fa64ae1552471da6fbe5b7023cf94
2021-08-16 16:37:10 -07:00
Treehugger Robot
55101e53fe Merge "Add mock interface for EmitXorBlocks" 2021-08-16 18:31:19 +00:00