This will fail in vts_libsnapshot_test because the pid isn't set (and
even if it was, we don't want to kill any running snapuserd instances).
Rather than start an instance just for the sake of killing it, use
dependency injection instead.
Bug: N/A
Test: vts_libsnapshot_test
Change-Id: I1569f927e018319cf4008673a32d5526573d8d57
This simplifies the footer and label resume system for COW files.
Previously, a footer could be missing, and we'd try to recover the file.
Any ops we could recover were handed off to the CowWriter, which then
searched up to the correct resume label.
In the new model, a reader is opened with an optional label (resume
mode), or without a label.
When resuming to a label, a footer is optional. The read is terminated
by EOF, discovery of the requested label, or the presence of a footer.
However the requested label must be found, and parsing fails if it is
not found.
When opening a COW without a label, the footer must be present, as this
signals the file was successfully flushed. Parsing fails if no footer is
found.
Bug: N/A
Test: cow_api_test
full OTA with VABC
Change-Id: Ie79ab5259f532dd16c72f0e42da7568c5c5c4623
When we're writing to a block device, we can't truncate. Ignore those
commands. Truncate mostly just saves time in the read phase by chopping
off unused data in the event finalize wasn't called.
Bug: 172026020
Test: cow_api_test
Change-Id: I3befc71fa9597edf8243d0f9e17440db91409aea
Reduces disk space usage for commonly used libraries by merging coverage
data across processes.
Bug: 171338125
Test: Forrest run of coverage tests
Change-Id: I2b9e94871fc5d66971c5b7e725b296bcd721ccf2
dm-user device requires sector information which is retrieved
from snapuserd daemon once the metadata read is completed.
Split up the initialization of daemon into two APIs. Once
the metadata read is completed, send the sector information
back to libsnapshot to create the dm-user device.
On a sidenote, remove unused code from snapuserd_client
Bug: 168311203
Test: vts_libsnapshot_test, cow_snapuserd_test
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I0647ebbeea3a4705599966974bfec2318a3e1e4e
Clang's static analyzer flagged the following potential null pointer
dereferences. Looks like a transitive caller of this function has
```
if (change) *change = foo;
```
...and no nullness checks between that and these unconditional
assignments to `*change`.
> system/core/fs_mgr/fs_mgr_overlayfs.cpp:1100:13: warning: Dereference
of null pointer (loaded from variable 'change')
[clang-analyzer-core.NullDereference] >
system/core/fs_mgr/fs_mgr_overlayfs.cpp:1167:17: warning: Dereference of
null pointer (loaded from variable 'change')
[clang-analyzer-core.NullDereference]
Bug: None
Test: TreeHugger
Change-Id: I656e3b0f56b18ec3ca3d1db773feb81adf163122
Handle write IO during snapshot merge. When merge
is completed, dm-snapshot-merge issues WRITE IO
to indicate the completion of merge for a specific
operation. Snapuserd daemon tracks the merge completion
process in the COW header; this is required to handle
resuming merge operation gracefully if there is a crash
during merge.
Bug: 168311203
Test: vts_libsnapshot_test, cow_snapuserd_test
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I4fc8cc23a6ec5b26b7ae3339212efdd3b9a367e8
This is required for merge IO path. During merge process,
kernel scans the metadata page from backwards when merge
is initiated. Since, merge ordering should follow our internal
COW format, read the COW operations from backwards and populate the metadata.
Additionally, Kernel can merge successive operations if the two chunk IDs
are contiguous. This can be problematic when there is a crash
during merge; specifically when the merge operation has dependency.
These dependencies can only happen during copy operations of the
overlapping regions. To avoid this problem, we make sure that
copy operations are merged individually.
Test: cow_snapuserd_test
Bug: 168311203
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Ic9c52b323ce58af897cfa343bf9277c8f1f022e3
If host system is Android Q and guest system is S, then reenable DSU in
the guest system (`adb shell gsi_tool enable -s`) would create an empty
DSU active indicator file.
In this case, use the default slot name "DSU" if DSU active indicator
file is non-existent or empty.
Bug: 172541102
Bug: 168571434
Test: Boot GSI S on Pixel Q with DSU
Test: Verify reenable DSU works
Test: adb shell gsi_tool enable -s && adb reboot
Change-Id: Ie59e4378d1aa4dca085c399a75abd4e662340030
It looks like in some rare scenarios device-mapper won't create an
uevent while handling DM_DEV_REMOVE ioctl.
Since failure to generate uevent will result in ueventd not cleaning up
/dev paths in user space, it should be ok to just fail DeleteDevice call
without aborting the entire process.
Test: presubmit
Bug: 171266986
Change-Id: Iece28e6e02c35ac4bf33b9be74dfe1bbbb466bd4
This will test the IO operation
between dm-snapshot/dm-user/snapuserd daemon. This test was broken
after cow format and daemon related changes.
Test: cow_snapuserd_test
Bug: 168311203
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I3e5f435332957a2549fd029c84efe13efb98b909
DSU slotting support is added in Android R, so
android::gsi::GetActiveDsu() is guaranteed to fail if DSU guest system
is S and host is Q.
In that case, just assume the the DSU slot to be "dsu".
Bug: 172541102
Bug: 168571434
Test: Boot GSI S on Q pixel with DSU
Change-Id: I96e191907ce2fedf8c22b7887e930a7c455eb593
Certain ops (label, footer) do not have actual block mappings, so ignore
these.
Bug: NA
Test: apply OTA with VABC
Change-Id: I0b9ce27239553d8126c17767f35c2651df951ea0
This is needed to create and stack device-mapper devices. The kernel
complains (or rejects) the table otherwise.
Bug: N/A
Test: manual test
Change-Id: I2bb3e55b7d999522c4c990b4ab7c46bcb78553a8
All cases where we want to append are done via label, so we can remove
the far more complicated open mode for append. Since this only leaves
open, we can remove the mode entirely.
Bug: 172026020
Test: cow_api_test
Change-Id: Ibe305e56b434da25952a129764398f606ca58aff
This will be used by payload_generator to estimate the COW size without
using extra storage space.
Bug: 168554689
Test: cow_api_test, ota_from_target_files
Change-Id: I095c809e7d81eff5321b86f4c6bdfb6e9467e84e