Commit graph

1091 commits

Author SHA1 Message Date
Sandeep Patil
5ba1c068a2 fiemap_writer: Add PinStatus check for fiemap writes.
Note that the check needs the kernel built with latest f2fs.

Bug: 122138114
Test: fiemap_writer_test /dev/block/sda21 \
      --gtest_filter=VerifyBlockWritesF2fs.CheckWrites

Change-Id: I0afbc14241f74ed368438a64afbdb97e3376f1f6
Signed-off-by: Sandeep Patil <sspatil@google.com>
2019-01-17 15:57:40 -08:00
Jaegeuk Kim
2fdbdfddac Merge "zram: support zram_writeback" 2019-01-17 21:03:15 +00:00
David Anderson
b43440ba79 Merge "init: Add support for GSI installations in first-stage mount." 2019-01-17 18:42:58 +00:00
Treehugger Robot
ccb06c7b2b Merge "Retry mounts on -EAGAIN" 2019-01-17 04:10:19 +00:00
David Anderson
0e330f12bc init: Add support for GSI installations in first-stage mount.
Bug: 121209697
Test: gsi boots
Change-Id: I69db0f8e999da366e46728b1008602f543cd79f6
2019-01-16 17:45:07 -08:00
Daniel Rosenberg
5620c6ce0c Retry mounts on -EAGAIN
F2fs may return -EAGAIN on mounting with checkpoint=disable. This
signals that the required garbage collection was taking a while, and
that more garbage collection is required, and will be resumed by
attempting to mount again.

Test: Start device with checkpointing set up with an f2fs userdata
      partition that is in need of heavy garbage collection.
      Mount should fail with EAGAIN and retry
Bug: 122917966

Change-Id: I83341f68e5cffa5f1bd569dfb2037ad5d3cbd7a3
2019-01-16 17:24:50 -08:00
Bo Hu
c8b83f3874 Merge "disable darwin build for libdm" 2019-01-16 20:38:43 +00:00
Treehugger Robot
72c06c5f68 Merge "fs_mgr: avb check avb_slot_data" 2019-01-16 16:53:17 +00:00
Treehugger Robot
cb33207a62 Merge "init: Allow first-stage mounts in the second stage if they're formattable." 2019-01-15 23:06:34 +00:00
bohu
54aa061c32 disable darwin build for libdm
bug: 122886514

Change-Id: I260e2d097023500f63f6fc217610f2868e842117
2019-01-15 22:57:00 +00:00
Mark Salyzyn
7d6431d852 fs_mgr: overlayfs: test fix problems with runtime apex bind mounts
bind mounts create administrivia in /proc/mounts that can not be
easily discerned to confirm expectations.  We squash the stutter,
and filter out overlay backing references for /system/<path>/<file>.

Test: adb-remount-test.sh
Bug: 122737045
Change-Id: I61342f5f76f54a1a8201a52efb8054acde100a6f
2019-01-15 11:42:03 -08:00
Jaegeuk Kim
2aedc82f02 zram: support zram_writeback
This patch supports zram_writeback enabled by fstab in two ways.

e.g.,
/dev/block/zram0 none swap defaults
    zramsize=1073741824,max_comp_streams=8,zram_loopback_path=/data/unencrypted/zram_swap

==> loopback size is 512MB by default.

Or,
/dev/block/zram0 none swap defaults
    zramsize=1073741824,max_comp_streams=8,zram_loopback_path=/data/unencrypted/zram_swap,zram_loopback_size=1G

==> loopback size can be specified by "zram_loopback_size=%s" with "GB" or "MB".

Or,
/dev/block/zram0 none swap defaults
    zramsize=1073741824,max_comp_streams=8,zram_backing_dev_path=/dev/block/partition

Bug: 74582279
Bug: 122659265
Change-Id: I66a2e6953b4743a34cf732dd0f5b5256c901f247
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2019-01-15 16:07:59 +00:00
David Anderson
42c32bf9af init: Allow first-stage mounts in the second stage if they're formattable.
If /metadata is wiped, but is specified as a first-stage mount, it'll
fail to mount and then skipped as a mount in the second stage. Rather
than add a new flag, this patch piggy-backs on "formattable" since
otherwise there is no way the file system will be formatted.

Bug: 121209697
Test: flashall -w && reboot
Change-Id: If36a12251f398a99b9423713a8bfbe8c33523b66
2019-01-14 17:36:02 -08:00
Mark Salyzyn
71df3ca70f adb remount documentation error
It is not adb reboot -R, it is adb remount -R

Bug: 122602260
Test: view file in gitties
Change-Id: I7c419b0b7f98cc0f5bb69284f5998515e9b8408e
2019-01-14 13:25:01 -08:00
bohu
91c4bd75c8 disable darwin build for libfstab
It broke mac sdk build

Change-Id: I5435cea7747d36c2ea46ed2e6c1c51bb032c6585
2019-01-11 14:26:56 -08:00
Mark Salyzyn
6a56a2a94f fs_mgr: avb check avb_slot_data
Damaged avb metadata can result in avb_slot_verify returning a
nullptr in avb_slot_data.  Instead of an illegal access
violation in first_stage_init, we return the verify_result so
that it can be acted upon.

Test: confirm happenstance damaged vbmeta does not crash init.
Change-Id: I15be5bd32760bcc3418c5d8a943b016c0ddd56bc
2019-01-11 10:19:29 -08:00
Bowgo Tsai
1b1a1fdbb1 Skip building libfs_avb for darwin host
Bug: 112103720
Bug: 117960205
Test: build
Change-Id: If0bb8d15a62947e3af3bf02485a210715db90fdd
2019-01-11 11:41:01 +08:00
David Anderson
34ad8ca773 Merge "liblp: Add helpers for modifying groups." 2019-01-11 01:45:21 +00:00
Treehugger Robot
fce33ca0bf Merge "libfs_avb: Switch to range-for for GetHashtreeDescriptor" 2019-01-11 00:14:52 +00:00
Treehugger Robot
29bc428f28 Merge "libfs_avb: refactoring" 2019-01-11 00:14:15 +00:00
Treehugger Robot
3c1cdaf54d Merge changes from topic "fsmgr_system_other"
* changes:
  fs_mgr: overlayfs clears readonly on scratch devices
  liblp: BLKROSET 0 prior to FlashPartitionTable
  fs_mgr: system_other does not want overlayfs.
2019-01-10 21:11:20 +00:00
David Anderson
c6c6e66813 liblp: Add helpers for modifying groups.
These are needed for non-A/B OTAs.

Bug: 122473283
Test: liblp_test gtest
Change-Id: Ib30614f1691dbea0a56c5a98aadc84fc26d1e639
2019-01-10 11:49:15 -08:00
Yifan Hong
ccdba57545 fs_mgr: overlayfs clears readonly on scratch devices
Fixes adb-remount-test and flashstation because the scratch device
was set to readonly before.

Test: adb-remount-test

Change-Id: I12551d1ed99fb7cfd04f84fcc2b77d3cb94275b2
Fixes: 122454600
Fixes: 122602260
2019-01-10 10:49:05 -08:00
Bowgo Tsai
7bf0479bb9 libfs_avb: Switch to range-for for GetHashtreeDescriptor
Bug: None
Test: boot a device
Change-Id: I9d0bdced5fa08cd4bf125c478504c45e5cfbcd4e
2019-01-10 18:12:17 +08:00
Bowgo Tsai
d79dd84479 libfs_avb: refactoring
This commit has the following changes:

    1. Builds libfs_avb via "fs_mgr/libfs_avb/Android.bp" instead of
       "fs_mgr/Android.bp", and removes the libfs_avb source
       dependencies on "fs_mgr/fs_mgr_priv.h".

    2. Moves static functions in fs_avb.cpp into util.cpp or
       avb_util.cpp, depending on whether the function is related to
       AVB or not.

    3. Introduces two host unit tests: libfs_avb_test and
       libfs_avb_internal_test, the former is to test public
       <fs_avb/fs_avb.h> APIs, while the latter is to test libfs_avb
       internal functions.

    4. Splits fs_avb_unittest_util.* into:
       - fs_avb_test_util.* (host static lib: libfs_avb_test_util),
       - basic_test.cpp (host executable: libfs_avb_test)

Bug: 112103720
Bug: 117960205
Test: atest libfs_avb_test
Test: atest libfs_avb_internal_test
Test: boot a device
Change-Id: I11d6c9e9019e20b594d9321b9a28118d4806e5a7
2019-01-10 18:11:48 +08:00
Justin Yun
d3e2a78a99 Exclude mount entries for vendor overlay
When testing adb-remount with overlayfs, vendor overlay may fail the
test because there are unexpected overlayfs uses by vendor overlay.
By excluding mount entries for vendor overlay, the test runs
regardless of vendor overlay mount.

Bug: 122231184
Test: run adb-remount-test.sh with vendor overlay mount
Change-Id: I795774b27d5e5f973792337813b67487a5d72e29
2019-01-10 00:40:33 +00:00
Yifan Hong
e7f492dc61 liblp: BLKROSET 0 prior to FlashPartitionTable
Test: OTA after cppreopt
Change-Id: I0c611588fac73fbd8d1502cb57481f3363e0cbe8
Fixes: 122487294
2019-01-09 16:20:33 -08:00
Yifan Hong
acf859a891 fs_mgr: system_other does not want overlayfs.
system wants overlayfs, and system_other is a valid candidate;
but system_other does not want overlayfs.

Addresses these denials:
avc: denied { read write } for comm="tune2fs" name="sda6" dev="tmpfs" ino=15114
  scontext=u:r:fsck:s0 tcontext=u:object_r:system_block_device:s0 tclass=blk_file permissive=0
avc: denied { read } for comm="e2fsck" name="sda6" dev="tmpfs" ino=15114
  scontext=u:r:fsck:s0 tcontext=u:object_r:system_block_device:s0 tclass=blk_file permissive=0
avc: denied { read write } for comm="e2fsck" name="sda6" dev="tmpfs" ino=15114
  scontext=u:r:fsck:s0 tcontext=u:object_r:system_block_device:s0 tclass=blk_file permissive=0

Fixes: 122454600
Test: boot, no tune2fs and e2fsck denials

Change-Id: Icce20f1463cfde034a56f25590cba9f8fe5f41a4
2019-01-09 16:20:33 -08:00
Treehugger Robot
55c083901d Merge "fs_mgr: overlayfs_mount_scratch don't write to system_other" 2019-01-09 01:33:37 +00:00
Bowgo Tsai
cd0d77da33 Merge "Support host build for libdm and libfstab" 2019-01-09 00:32:43 +00:00
Yifan Hong
3be2c7a14b fs_mgr: overlayfs_mount_scratch don't write to system_other
This change removes this denial:
avc: denied { write } for comm="init" name="sda6" dev="tmpfs" \
    ino=25715 scontext=u:r:init:s0 tcontext=u:object_r:system_block_device:s0 \
    tclass=blk_file permissive=0

The reason is that during any mount_all in init,
fs_mgr_overlayfs_mount_all() will mount a list of candidates for
scratch, which includes system_other. However, in order to probe
if /overlay directory exist in the partition, it only needs read
access to the block device, and mount the partition as readonly.
If the block device is a true candidate (i.e. it does have /overlay),
re-mount it as writable.

Test: flash, wipe, boot, denial goes away, cppreopt is successful
Test: boot the second time, no denials (no cppreopt this time)

Fixes: 122454600

Change-Id: I465b363eac755d79711e4f82955cd98450527122
2019-01-08 15:01:32 -08:00
Treehugger Robot
6eec7f031e Merge "fs_mgr: Add a helper for creating one-off dynamic partitions." 2019-01-08 19:18:25 +00:00
Bowgo Tsai
fa416f9bec Support host build for libdm and libfstab
The host builds for both libs are needed for libfs_avb host unit test.
Also replaces strlcat()/strlcpy() with snprintf() because the former
doesn't have a glibc version. Or switch char* to std::string*.

Bug: 112103720
Bug: 117960205
Test: m libdm ARCH=x86_64
Test: m libfstab ARCH=x86_64
Test: atest libdm_test
Test: atest fs_mgr_unit_test
Test: boot a device

Change-Id: Id9b92b5286b8ed9ab0d80f18ab5802dcfeb83dfa
2019-01-08 17:56:56 +08:00
David Anderson
908f07b0b8 fs_mgr: Add a helper for creating one-off dynamic partitions.
This will be used by gsid to invoke mkfs.ext4 on the userdata_gsi
partition. Since the extents are not located on the super partition, we
need a helper method that takes in an LpMetadata.

Bug: 121210348
Test: manual test
Change-Id: I00467ace8a745fb0c0d130babfda1a2d5d97c208
2019-01-07 18:31:54 -08:00
Mark Salyzyn
df8cf18804 fs_mgr: overlayfs: if existing scratch mountpoint is system_empty
On first mount check if overlays are setup, if not and there is
no space, then umount and make a filesystem and try again.

Test: adb_remount_test.sh
Bug: 119885423
Change-Id: I3a76ff5b53474976f72e9db326b26838f7df5ba8
2019-01-07 22:41:27 +00:00
Mark Salyzyn
b3c0074917 fs_mgr: overlayfs test fix adb_sh
Some commands like 'adb_sh grep " rw," /proc/mounts' do not preserve
the embedded spaces when transferred to the device and thus do not
entirely behave as expected.  There are several commands issued this
way throughout the test that are similarly broken.  To add
consistency, pass any arguments that are not explicitly (double)
quoted and contain embedded spaces as quoted to preserve.

Also devices that report the kernel internal device /dev/root in
/proc/mounts should be suppressed when investigating whether
overlayfs is needed.  If /dev/root is reported, then we should assume
that the mount point / represents it for the following df command
when trying to determine if the partition is right-sized.

When there is only one device attached, and a serial number is not
specified, correctly determine this condition to progress to
the testing.

Test: adb_remount_test.sh
Bug: 122231184
Change-Id: I913e297dd272d6691110bb5d7a7c7f54321b6833
2019-01-07 21:39:56 +00:00
Yifan Hong
789d905b50 Merge "Add none to supported fs type" 2019-01-07 18:26:19 +00:00
Treehugger Robot
32b695daa7 Merge changes from topic "fiemap-writer-1"
* changes:
  fiemap_writer: enforce filesystem optimal block size alignment
  fiemap_writer: Fix file pinning / pinning status check code.
2019-01-07 01:48:46 +00:00
Bowgo Tsai
a99a1f275c Skip building libfs_avb unittest for Mac
Bug: 117960205
Test: m libfs_avb_host_unittest
Change-Id: Ib53efe3e36a3f70134b2431c2c0bfed52fdd3df6
2019-01-06 13:41:45 +08:00
Sandeep Patil
eb28e0c44b fiemap_writer: enforce filesystem optimal block size alignment
... instead of using the block size from the underlying block device.

Bug: 121211685
Test: fiemap_writer_test /dev/block/sda21 (on blueline)

Change-Id: I6038d3f06505a397280b0482e33814b4883be9a2
Signed-off-by: Sandeep Patil <sspatil@google.com>
2019-01-05 17:38:31 -08:00
Sandeep Patil
d2b2e21f59 fiemap_writer: Fix file pinning / pinning status check code.
The IsFilePinned() function is still not being called because I am still
seeing # blocks moved when I run following test on
aosp_blueline-userdebug.

 $ fiemap_writer_test /dev/block/sda21 \
 --gtest_filter=FiemapWriterTest.CheckWriteError

Bug: 122138114
Test: fiemap_writer_test /dev/block/sda21

Change-Id: I08d74093a082674d621772d202143d2f32e7c665
Signed-off-by: Sandeep Patil <sspatil@google.com>
2019-01-05 15:29:54 -08:00
Treehugger Robot
0dd3725982 Merge "Adding libfs_avb unittest framework" 2019-01-05 10:57:13 +00:00
Treehugger Robot
aed2ee9664 Merge "fs_mgr_avb: introducing class VBMetaData" 2019-01-05 06:41:14 +00:00
Yifan Hong
ea1c779067 Add none to supported fs type
Test: mount sdcard in recovery on cuttlefish
Change-Id: I23b0ce418f8240cfdaa2d560678989067d746de6
2019-01-04 15:28:30 -08:00
David Anderson
126e481972 liblp: Allow GSI metadata to bypass slot suffixing checks.
Bug: 121210348
Test: manual test
Change-Id: I40634c72b0255197a5c16e23553f4cf54bc32579
2019-01-03 18:19:43 -08:00
David Anderson
189727089e liblp: Add API for adding predetermined linear extents to partitions
Bug: 121210348
Test: manual test
Change-Id: Ie9af456d5193e962a3bcf0cc5dcd22e794d143f6
2019-01-03 18:18:45 -08:00
Sandeep Patil
ac535f9713 Merge "fiemap_writer: First cut implementation with write() support." 2019-01-03 15:56:15 +00:00
Bowgo Tsai
b92fc1f423 fs_mgr_avb: introducing class VBMetaData
Currently vbmeta images are stored in AvbSlotVerifyData defined in
libavb, which contains some fields that isn't needed by fs_mgr.
e.g., loaded_partition, rollback_indexes. Adding a new class VBMetaData
to replace it.

Bug: 112103720
Bug: 117960205
Test: boot crosshatch
Change-Id: I480461dad3c6aca7e028097662a3b06c3aa6646d
2019-01-03 18:17:56 +08:00
Bowgo Tsai
583540330c Adding libfs_avb unittest framework
This commit adds the fundamental test framework for the upcoming
changes in libfs_avb. It replies on 'avbtool' to append AVB
metadata and then extracts the vbmeta content into an internal
|vbmeta_images_| variable for comparison later.

Bug: 117960205
Test: m libfs_avb_host_unittest
Test: ./out/host/linux-x86/nativetest/libfs_avb_host_unittest/libfs_avb_host_unittest
Test: atest --rebuild-module-info
Test: atest libfs_avb_host_unittest

Change-Id: I0cb8e8f04bc4b8628576565e7ff1920d7c81ecac
2019-01-02 09:58:08 +00:00
Sandeep Patil
faa257ee0f fiemap_writer: First cut implementation with write() support.
The library is meant to help write to a file using its FIEMAP and the
raw block device.

Bug: 121211685
Test: fiemap_writer_test /data/local/tmp/foo.raw /dev/block/sda21
Test: fiemap_writer_test /data/local/tmp/foo.raw /dev/block/sda21 1073741824
Test: fiemap_writer_test /data/local/tmp/foo.raw /dev/block/sda21 \
      --gtest_filter=FiemapWriter.CheckBlockDevicePath
Test: fiemap_writer_test /data/local/tmp/foo.raw /dev/block/sda21 32768 \
      --gtest_filter=FiemapWriter.CheckWriteError
Test: fiemap_writer_test /data/local/tmp/foo.raw /dev/block/sda21 \
      --gtest_filter=VerifyBlockWritesExt4.CheckWrites
Test: fiemap_writer_test /data/local/tmp/foo.raw /dev/block/sda21 \
      --gtest_filter=VerifyBlockWritesF2fs.CheckWrites

Change-Id: I7b580afddc829c1064ebb52b7a6c7600a2fb2772
Signed-off-by: Sandeep Patil <sspatil@google.com>
2018-12-29 11:11:30 -08:00