Commit graph

14 commits

Author SHA1 Message Date
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