diff options
-rw-r--r-- | payload_generator/delta_diff_utils.cc | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/payload_generator/delta_diff_utils.cc b/payload_generator/delta_diff_utils.cc index c0962bf9..4ee1024f 100644 --- a/payload_generator/delta_diff_utils.cc +++ b/payload_generator/delta_diff_utils.cc @@ -493,30 +493,44 @@ bool DeltaMovedAndZeroBlocks(vector<AnnotatedOperation>* aops, old_blocks_map_it->second.pop_back(); } + if (chunk_blocks == -1) + chunk_blocks = new_num_blocks; + // Produce operations for the zero blocks split per output extent. - // TODO(deymo): Produce ZERO operations instead of calling DeltaReadFile(). size_t num_ops = aops->size(); new_visited_blocks->AddExtents(new_zeros); for (const Extent& extent : new_zeros) { - TEST_AND_RETURN_FALSE(DeltaReadFile(aops, - "", - new_part, - vector<Extent>(), // old_extents - vector<Extent>{extent}, // new_extents - {}, // old_deflates - {}, // new_deflates - "<zeros>", - chunk_blocks, - version, - blob_file)); + if (version.OperationAllowed(InstallOperation::ZERO)) { + for (uint64_t offset = 0; offset < extent.num_blocks(); + offset += chunk_blocks) { + uint64_t num_blocks = + std::min(static_cast<uint64_t>(extent.num_blocks()) - offset, + static_cast<uint64_t>(chunk_blocks)); + InstallOperation operation; + operation.set_type(InstallOperation::ZERO); + *(operation.add_dst_extents()) = + ExtentForRange(extent.start_block() + offset, num_blocks); + aops->push_back({.name = "<zeros>", .op = operation}); + } + } else { + TEST_AND_RETURN_FALSE(DeltaReadFile(aops, + "", + new_part, + {}, // old_extents + {extent}, // new_extents + {}, // old_deflates + {}, // new_deflates + "<zeros>", + chunk_blocks, + version, + blob_file)); + } } LOG(INFO) << "Produced " << (aops->size() - num_ops) << " operations for " << utils::BlocksInExtents(new_zeros) << " zeroed blocks"; // Produce MOVE/SOURCE_COPY operations for the moved blocks. num_ops = aops->size(); - if (chunk_blocks == -1) - chunk_blocks = new_num_blocks; uint64_t used_blocks = 0; old_visited_blocks->AddExtents(old_identical_blocks); new_visited_blocks->AddExtents(new_identical_blocks); |