platform_system_core/fs_mgr/libsnapshot
Yifan Hong b6663cfb5a libsnapshot: lock on /metadata/ota
We used to flock() on /metadata/ota/state to ensure
atomic access. However, writing the file itself is
not necessary atomic and may lead to inconsistent
states.

This change redirects flock() to the outer directory, /metadata/ota,
which is very likely to exist (see exception below).
flock() is called on this directory instead of /state. This allows
a follow-up change to turn all writes to the /metadata partition
atomic.

Note: /metadata/ota may not exist during first boot after a flash
with wipe. However, first_stage_init always checks existence of
boot indicator before even trying to flock() (via
IsSnapshotManagerNeeded() and NeedSnapshotsInFirstStageMount()). If
the boot indicator exists, /metadata/ota must exist as well.

Also add tests to ensure LockExclusive() and LockShared() works as
expected.

Test: libsnapshot_test
Test: apply OTA from older build to this, then reboot

Bug: 144549076

Change-Id: Ib4dd9e9be1a43013c328e181b9398ac0b514dbce
2019-12-04 14:49:47 -08:00
..
android/snapshot Convert SnapshotStatus to proto 2019-10-03 14:26:01 -07:00
include/libsnapshot libsnapshot: lock on /metadata/ota 2019-12-04 14:49:47 -08:00
Android.bp libsnapshot: Add a helper for handling data wipes in recovery. 2019-11-10 23:07:11 -08:00
device_info.cpp libsnapshot: Add a helper for handling data wipes in recovery. 2019-11-10 23:07:11 -08:00
device_info.h libsnapshot: Add a helper for handling data wipes in recovery. 2019-11-10 23:07:11 -08:00
dm_snapshot_internals.h pragma once for header file 2019-10-28 16:38:35 +00:00
OWNERS Sketch out libsnapshot for update_engine integration. 2019-07-17 20:30:51 -07:00
partition_cow_creator.cpp SOURCE_COPY operation: implement src == dst 2019-12-02 14:58:17 -08:00
partition_cow_creator.h PartitionCowCreator accounts for extra extents 2019-12-02 12:49:38 -08:00
partition_cow_creator_test.cpp COW partition creator uses DmSnapshotCowSizeCalculator 2019-10-28 18:59:45 +00:00
snapshot.cpp libsnapshot: lock on /metadata/ota 2019-12-04 14:49:47 -08:00
snapshot_metadata_updater.cpp libsnapshot: Add snapshot metadata updater. 2019-09-17 12:55:23 -07:00
snapshot_metadata_updater.h libsnapshot: Add snapshot metadata updater. 2019-09-17 12:55:23 -07:00
snapshot_metadata_updater_test.cpp Fix build with new googletest 2019-11-10 04:08:25 +00:00
snapshot_test.cpp libsnapshot: lock on /metadata/ota 2019-12-04 14:49:47 -08:00
snapshotctl.cpp [REFACTOR] libsnapshot: Add InitiateMergeAndWait 2019-10-31 17:06:28 -07:00
snapshotctl.rc snapshotctl: merge when boot 2019-09-23 18:50:12 -07:00
test_helpers.cpp libsnapshot: Add test for accounting for hash tree 2019-12-02 13:59:48 -08:00
test_helpers.h libsnapshot: Add test for accounting for hash tree 2019-12-02 13:59:48 -08:00
utility.cpp COW device initialized by zeroing the whole first chunk 2019-10-30 17:50:59 +00:00
utility.h libsnapshot: Add EnsureMetadataMounted 2019-10-25 15:37:11 -07:00