Commit graph

22 commits

Author SHA1 Message Date
Alessio Balsini
c352179e10 fiemap: add image_test and writer_test tests to presubmit
Add fiemap_image_test and fiemap_writer_test to TEST_MAPPING to be run
by TH as presubmits.
Because of a bug under investigation, the actual
fiemap_image_test_presubmit is used instead of the original, that has
one test case disabled.

Bug: none
Test: TH, fiemap_image_test, fiemap_writer_test
Change-Id: I63b5e69b5c245a18eceb1e5896df7bd0577f289b
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-05 22:08:29 +00:00
Alessio Balsini
f6034544c0 fiemap: fix fiemap size and log message when last extent
Fix the total fiemap struct plus extents size allocation.
Fix also the logging in IsLastExtent, that was printing error messages
every time.

Bug: none
Test: fiemap_*_test
Change-Id: I85c6af63ba3a75b993a5e8ad7d7170dc7af59582
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-05 18:27:40 +00:00
Alessio Balsini
272ef868f1 Extra logging for metadata errors
Increase logging in metadata image management.

Bug: none
Test: m
Change-Id: Ie49ca9ac90cd593c95d31f4651ae724d617d5695
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-04 20:49:59 +00:00
David Anderson
c13586faea remount: Use /data for backing scratch storage.
Currently, this is only enabled for Virtual A/B devices. When /data uses
F2FS, then proper pinning support must be enabled.

Because /data cannot be mounted in recovery, we can't delete the scratch
image backed by /data while in fastbootd. Instead, we mark it as
disabled in /metadata. The remount command now has an init script that
checks for and removes a disabled scratch partition.

Bug: 134949511
Test: adb remount on V A/B device with patched F2FS
Change-Id: Ifc8720378259654472d3822e97059b6c366f601d
2020-01-28 12:04:38 -08:00
Howard Chen
62f35129d4 Merge "Refine the first stage mount for DSU" 2020-01-16 05:33:09 +00:00
Yifan Hong
b5c0ad7b21 Merge "Merge VtsFiemapWriterTest into fiemap_writer_test" 2020-01-14 00:11:14 +00:00
Yifan Hong
d90c32fbe2 Merge VtsFiemapWriterTest into fiemap_writer_test
Delete AndroidTest.xml for VtsFiemapWriterTest and use auto-generated
test config for fiemap_writer_test.

Also add fiemap_writer_test to vts-core and device-tests.

Also require_root for fiemap_writer_test.

Test: atest fiemap_writer_test
Fixes: 144300653
Change-Id: Ifc3808ea56331809b58f0c02de2caac250d78352
2020-01-13 13:53:17 -08:00
Howard Chen
a841bd48f8 Refine the first stage mount for DSU
* Open the ImageManager according to the saved DSU slot.
* Load the saved install_dir when it presents. This is required
  when installing to an external storage and the current code
  seems to break it.
* Remove an unnecessary C++ using.

Test: gsi_tool install
Bug: 144247097

Change-Id: I5b7be25787f235518a25abacefa612c33861f6ef
2020-01-09 07:47:35 +00:00
Yifan Hong
cd232f9734 SnapshotManager expose no space error
When there is not enough space on /userdata, CreateUpdateSnapshot
returns SnapshotManager::Return with ErrorCode::NO_SPACE.

Test: libsnapshot_test
Bug: 138808058

Change-Id: If2effe63f6a4324eff8d05d4db4ce98be8190262
2020-01-07 14:20:44 -08:00
Yifan Hong
e4b44fc501 ImageManager returns FiemapStatus.
IImageManager::CreateBackingImage and ZeroFillNewImage now returns
FiemapStatus, which is an error code and provides more information
about the reason of error.

In particular, the error code is NO_SPACE if disk space is full during
allocation / writing.

Bug: 138808058
Test: libsnapshot_test

Change-Id: I500a3d9f55a2d7e60438b5b4ae70f8b5fed162fa
2020-01-07 13:01:58 -08:00
Yifan Hong
6170c7a02f libfiemap: Create/Open returns FiemapStatus
Add variants to SplitFiemap::Create and FiemapWriter::Open that
returns a FiemapStatus and take a unique_ptr<T>* out parameter to
get more information on the reason of the failure.

Test: fiemap_writer_test
Test: fiemap_image_test
Bug: 138808058
Change-Id: Iea77ac9810f98c2202e038b7aede15dd2d137b2b
2020-01-07 13:01:58 -08:00
Yifan Hong
0ede9b43e5 libfiemap: delete unuseful check
Just let fallocate fails. It also doesn't check for the delta between
the old file and the new file.

Test: unit tests
Change-Id: I05e12b097a973d9fe7fe696cc472bd7ec2d180c7
2019-12-27 15:36:41 -08:00
David Anderson
4e5b505751 Merge "libfiemap: Add a MapAllImages() helper." 2019-12-27 21:13:51 +00:00
David Anderson
31a35038a0 Merge "libfiemap: Add a way to get the block device path of a mapped image." 2019-12-27 21:13:33 +00:00
David Anderson
8edafa2393 Merge "libfiemap: Add helpers to remove images from recovery." 2019-12-27 20:28:48 +00:00
David Anderson
d5745cce70 libfiemap: Add a MapAllImages() helper.
This adds a helper for first-stage init to easily map partitions backed
by /data. This can be used for the scratch partition as well as DSU
partitions.

Bug: 134949511
Test: fiemap_image_test
Change-Id: I46246b41ce19442d1476b9959e34df0e1bff58c3
2019-12-25 22:32:31 -08:00
David Anderson
e1c879c816 Merge "fs_mgr: Move libfiemap into libfs_mgr, and introduce libfs_mgr_binder." 2019-12-24 04:37:05 +00:00
David Anderson
734047a231 libfiemap: Add a way to get the block device path of a mapped image.
This is needed for adb remount, to find the scratch device if it is
already mapped. Note that on devices without metadata encryption, this
cannot be done by querying device-mapper, since scratch will be a loop
device.

Bug: 134949511
Test: fiemap_image_test
Change-Id: Ia25d279c6f8a4838be32a8c01aefc67b5ec1e002
2019-12-20 16:41:35 -08:00
David Anderson
f41c7bbb96 libfiemap: Add helpers to remove images from recovery.
ImageManager can map images in recovery, but not delete them, because
/data is not mounted. libsnapshot handles this by storing extra state
files, but this is complex to manage and inconvenient for
fs_mgr_overlayfs.

Instead, this patch introduces two new calls:

 - DisableImage(), which indicates the image should not be used. This is
   implemented by adding a new DISABLED attribute to
   LpPartitionMetadata. CreateLogicalPartitions ignores this flag, and
   thus recovery/fastbootd can disable the scratch partition and
   communicate that it can be deleted. This cannot be called from binder
   since it is intended for recovery/first-stage init only.

 - RemoveDisabledImages(), which walks the images for a given folder on
   /metadata and deletes any that are disabled. This can be called from
   binder.

Note that there is no metadata version bump for this flag. It's
considered to be included in the flag list for minor version 1, and
currently is not used for the actual super partition.

Bug: 134949511
Test: adb remount, fastboot flash system
Test: fiemap_image_test
Change-Id: Iaeca2d1eddb5637dd9a20202cafd11ae60b4d0e3
2019-12-20 16:41:35 -08:00
David Anderson
43482de3f9 fs_mgr: Move libfiemap into libfs_mgr, and introduce libfs_mgr_binder.
This eliminates libfiemap as a standalone library and instead bundles it
into libfs_mgr. All consumers of libfiemap need libfs_mgr, and having
them tightly coupled reduces linkage complexity.

When to use libfs_mgr: In recovery, first-stage-init, or when libfiemap
or overlayfs is not used.

When to use libfs_mgr_binder: When not in recovery/first-stage init, and
overlayfs or libfiemap is needed. In this case, IImageManager will proxy
over binder to gsid.

Bug: 134949511
Test: builds, fiemap_writer/image_test passes.
Change-Id: I4c1a5698afdbf9b3bf87accec98254c1fb6f4e0e
2019-12-20 16:41:34 -08:00
David Anderson
71b287bfd7 libfiemap: Fix fallocate() usage.
This fixes two bugs in how we use fallocate(). First, using ZERO_RANGE
is a mechanism to allocate holes, not blocks. Instead we should be
passing no flags.

The reason this code worked is because of our explicit writes to the
file, which is intended to defeat lazy block allocation. This is not
necessary for F2FS with proper file pinning support, so we now skip this
when possible.

Together, these fixes improve the speed of "adb remount" when backed
by libfiemap.

Bug: 134949511
Test: adb remount when backed by /data
Change-Id: I746053d183e0c83d56979d9c3fa6d96b40b5e478
2019-12-17 15:04:08 -08:00
David Anderson
4fe398018b fs_mgr: Move libfiemap back to fs_mgr from system/gsid.
Bug: 134949511
Test: builds
Change-Id: I07943acce5d4671975afef6d8da1bdbeef43c39d
2019-12-16 20:10:26 -08:00