Whamcloud - gitweb
AOSP: e2fsdroid: Don't skip unusable blocks in BaseFS.
authorDavid Anderson <dvander@google.com>
Fri, 14 Feb 2020 20:44:48 +0000 (12:44 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 21 Mar 2020 03:18:01 +0000 (23:18 -0400)
commitc25ec972c9c667ed18ee32acea11404f017a5693
tree1663f3b3eec1e9fa52dc828ad6d3e0897b24cd0c
parent58ecfa7f51f02617fdb52b4fa1a05d1d69ad2d0b
AOSP: e2fsdroid: Don't skip unusable blocks in BaseFS.

Currently, basefs_allocator will iterate through blocks owned by an
inode until it finds a block that is free. This effectively ignores the
logical to physical block mapping, which can lead to a bigger delta in
the final image.

An example of how this can happen is if the BaseFS has a deduplicated
block (D), that is not deduplicated in the new image:

  Old image: 1 2 3 D 4 5
  New image: 1 2 3 ? 4 5

If the allocator sees that "D" is not usable, and skips to block "4",
we will have a non-ideal assignment.

  Bad image: 1 2 3 4 5 ?

This patch refactors get_next_block() to acquire at most one block. It's
called a single time, and then only called in a loop if absolutely no
blocks can be acquired from anywhere else.

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

Bug: 139201772
Test: manual test
Change-Id: I354f0dee1ee191dba0e1f90491ed591dba388f7f
From AOSP commit: a495b54f89b2ec0e46be8e3564e4852c6434687c
contrib/android/basefs_allocator.c