AU: remove identical src/dst blocks when generating MOVE operations

This eliminates a scenario where some (or all) blocks in a file are
being moved to the same location from which they were read. It is
achieved by post-processing the sequence of source/target extents of
a MOVE operation, removing the i-th block if it is identical in both.
In practice, this removal is done rather efficiently as we identify the
largest contiguous blocks that can be removed within extents. Note that
there are four different cases to handle when removing blocks from
extents (head, tail, middle, or all).

In turn, it opens up the possibility that a delta operation (MOVE)
becomes a no-op, for example, if a file (or a kernel partition) remains
the same and does not move at all; therefore, we also care to identify
such empty operations and avoid adding them entirely.

NOTE: the correctness of this change depends on the assumption that not
all blocks in the target partition must be written during an update! It
could be that some further logic (such as cycle breaking) assumes the
opposite; that said, we now have good confidence in the robustness of
our update payloads, so we should be fine enabling this feature.

NOTE 2: once this is merged and the minimum delta generator version used
in paygen is bumped, we should re-enable the test for identical src/dst
blocks when verifying payloads.

BUG=chromium:263550
TEST=New unit test covering all cases; all unit tests pass.

Change-Id: If3bd1bf79720e076120074ad913d8bbe6c098710
Reviewed-on: https://chromium-review.googlesource.com/181515
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
2 files changed
tree: 07825c1150876a096a4575c549bcbe9c36ff1606
  1. .gitignore
  2. 99-gpio-dutflag.rules
  3. action.h
  4. action_mock.h
  5. action_pipe.h
  6. action_pipe_unittest.cc
  7. action_processor.cc
  8. action_processor.h
  9. action_processor_mock.h
  10. action_processor_unittest.cc
  11. action_unittest.cc
  12. build
  13. bzip.cc
  14. bzip.h
  15. bzip_extent_writer.cc
  16. bzip_extent_writer.h
  17. bzip_extent_writer_unittest.cc
  18. certificate_checker.cc
  19. certificate_checker.h
  20. certificate_checker_mock.h
  21. certificate_checker_unittest.cc
  22. chrome_browser_proxy_resolver.cc
  23. chrome_browser_proxy_resolver.h
  24. chrome_browser_proxy_resolver_unittest.cc
  25. clock.cc
  26. clock.h
  27. clock_interface.h
  28. connection_manager.cc
  29. connection_manager.h
  30. connection_manager_unittest.cc
  31. constants.cc
  32. constants.h
  33. cycle_breaker.cc
  34. cycle_breaker.h
  35. cycle_breaker_unittest.cc
  36. dbus_constants.h
  37. dbus_interface.h
  38. dbus_service.cc
  39. dbus_service.h
  40. delta_diff_generator.cc
  41. delta_diff_generator.h
  42. delta_diff_generator_unittest.cc
  43. delta_performer.cc
  44. delta_performer.h
  45. delta_performer_unittest.cc
  46. download_action.cc
  47. download_action.h
  48. download_action_unittest.cc
  49. error_code.h
  50. extent_mapper.cc
  51. extent_mapper.h
  52. extent_mapper_unittest.cc
  53. extent_ranges.cc
  54. extent_ranges.h
  55. extent_ranges_unittest.cc
  56. extent_writer.cc
  57. extent_writer.h
  58. extent_writer_unittest.cc
  59. fake_clock.h
  60. fake_hardware.h
  61. fake_p2p_manager.h
  62. fake_p2p_manager_configuration.h
  63. file_descriptor.cc
  64. file_descriptor.h
  65. file_writer.cc
  66. file_writer.h
  67. file_writer_mock.h
  68. file_writer_unittest.cc
  69. filesystem_copier_action.cc
  70. filesystem_copier_action.h
  71. filesystem_copier_action_unittest.cc
  72. filesystem_iterator.cc
  73. filesystem_iterator.h
  74. filesystem_iterator_unittest.cc
  75. full_update_generator.cc
  76. full_update_generator.h
  77. full_update_generator_unittest.cc
  78. gen_coverage_html
  79. generate_delta_main.cc
  80. gpio_handler.cc
  81. gpio_handler.h
  82. gpio_handler_unittest.cc
  83. gpio_handler_unittest.h
  84. gpio_mock_file_descriptor.cc
  85. gpio_mock_file_descriptor.h
  86. gpio_mock_udev_interface.cc
  87. gpio_mock_udev_interface.h
  88. graph_types.h
  89. graph_utils.cc
  90. graph_utils.h
  91. graph_utils_unittest.cc
  92. hardware.cc
  93. hardware.h
  94. hardware_interface.h
  95. http_common.cc
  96. http_common.h
  97. http_fetcher.cc
  98. http_fetcher.h
  99. http_fetcher_unittest.cc
  100. inherit-review-settings-ok
  101. install_plan.cc
  102. install_plan.h
  103. libcurl_http_fetcher.cc
  104. libcurl_http_fetcher.h
  105. LICENSE
  106. local_coverage_rate
  107. main.cc
  108. marshal.list
  109. metadata.cc
  110. metadata.h
  111. metadata_unittest.cc
  112. mock_connection_manager.h
  113. mock_dbus_interface.h
  114. mock_file_writer.h
  115. mock_gpio_handler.h
  116. mock_hardware.h
  117. mock_http_fetcher.cc
  118. mock_http_fetcher.h
  119. mock_p2p_manager.h
  120. mock_payload_state.h
  121. mock_system_state.cc
  122. mock_system_state.h
  123. multi_range_http_fetcher.cc
  124. multi_range_http_fetcher.h
  125. omaha_hash_calculator.cc
  126. omaha_hash_calculator.h
  127. omaha_hash_calculator_unittest.cc
  128. omaha_request_action.cc
  129. omaha_request_action.h
  130. omaha_request_action_unittest.cc
  131. omaha_request_params.cc
  132. omaha_request_params.h
  133. omaha_request_params_unittest.cc
  134. omaha_response.h
  135. omaha_response_handler_action.cc
  136. omaha_response_handler_action.h
  137. omaha_response_handler_action_unittest.cc
  138. p2p_manager.cc
  139. p2p_manager.h
  140. p2p_manager_unittest.cc
  141. payload_signer.cc
  142. payload_signer.h
  143. payload_signer_unittest.cc
  144. payload_state.cc
  145. payload_state.h
  146. payload_state_interface.h
  147. payload_state_unittest.cc
  148. postinstall_runner_action.cc
  149. postinstall_runner_action.h
  150. postinstall_runner_action_unittest.cc
  151. prefs.cc
  152. prefs.h
  153. prefs_interface.h
  154. prefs_mock.h
  155. prefs_unittest.cc
  156. proxy_resolver.cc
  157. proxy_resolver.h
  158. real_system_state.h
  159. run_unittests
  160. sample_omaha_v3_response.xml
  161. SConstruct
  162. setup_dev_packages
  163. simple_key_value_store.cc
  164. simple_key_value_store.h
  165. simple_key_value_store_unittest.cc
  166. subprocess.cc
  167. subprocess.h
  168. subprocess_unittest.cc
  169. system_state.cc
  170. system_state.h
  171. tarjan.cc
  172. tarjan.h
  173. tarjan_unittest.cc
  174. terminator.cc
  175. terminator.h
  176. terminator_unittest.cc
  177. test_http_server.cc
  178. test_utils.cc
  179. test_utils.h
  180. testrunner.cc
  181. topological_sort.cc
  182. topological_sort.h
  183. topological_sort_unittest.cc
  184. udev_interface.h
  185. unittest_key.pem
  186. unittest_key2.pem
  187. update_attempter.cc
  188. update_attempter.h
  189. update_attempter_mock.h
  190. update_attempter_unittest.cc
  191. update_check_scheduler.cc
  192. update_check_scheduler.h
  193. update_check_scheduler_unittest.cc
  194. update_engine.xml
  195. update_engine_client.cc
  196. update_metadata.proto
  197. UpdateEngine.conf
  198. utils.cc
  199. utils.h
  200. utils_unittest.cc
  201. WATCHLISTS
  202. zip_unittest.cc