Whamcloud - gitweb
AOSP: e2fsdroid: Fix logical block sequencing in BaseFS.
authorDavid Anderson <dvander@google.com>
Fri, 14 Feb 2020 03:20:32 +0000 (19:20 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 21 Mar 2020 03:16:13 +0000 (23:16 -0400)
commit58ecfa7f51f02617fdb52b4fa1a05d1d69ad2d0b
treeba12d50fd2e795d2f6d12bbb06271624efb15a2b
parentc2481ace20e3bae25258db30529a446e83f28c89
AOSP: e2fsdroid: Fix logical block sequencing in BaseFS.

By iterating over blocks to write BaseFS, holes in the extent tree are
skipped. This is problematic because the purpose of BaseFS is to
preserve the logical to physical block assignment between builds. By not
preserving the location of holes, the assignment can be incorrect.

For example, consider the following block list for a file:
   1 2 3 0 4 5

If this is recorded as:
   1 2 3 4 5

If the first block changes to a hole, the intended mapping will not be
preserved at all:
   0 1 2 0 3

This patch makes two changes to e2fsdroid to fix this. The first change
is that holes are now recorded in BaseFS, by iterating over the extent
tree rather than the block list, and inserting zeroes where appropriate.

The second change is that the block allocator now recognizes when blocks
have been skipped (either to deduplication or to holes), and skips the
same number of logical blocks in BaseFS as well.

In a Virtual A/B simulation, this reduces the COW snapshot size by
approximately 100MB.

Bug: 139201772
Test: m target-files-package, inspect .map files
From AOSP commit: d391f3bf38cbe51718d5c3c0bb3e72b1a9978625
contrib/android/basefs_allocator.c
contrib/android/fsmap.c