aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2017-10-27 23:39:45 -0700
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-11-02 04:42:49 +0000
commitba30867b0174463bebefc92198ee24ec9e4bdfa3 (patch)
tree1422024a19eae60caa2c60c5cf532ca27d203a30
parent43da85312213fdfd591ce66f6751a20dd01834fd (diff)
downloadrecovery-ba30867b0174463bebefc92198ee24ec9e4bdfa3.tar.gz
update_verifier: Fix the wrong computation with group_range_count.
'group_range_count' doesn't properly consider the pair-wise range structure. It may split the ranges into wrong pairs if it evaluates to an odd number. For example, for an input range string of "6,0,2,10,12,20,22" with 4 threads, group_range_count becomes 1. It would then try to verify (0,2), (2,10), (10,12) and (12,20). Note that (2,10) and (12,20) are not valid ranges to be verified, and with (20,22) uncovered. Bug: 68343761 Test: Trigger update_verifier verification. Check the number of verified blocks against the one in care_map.txt. Change-Id: I7c5769325d9866be06c45e7dbcc0c8ea266de714 (cherry picked from commit 62caeb5f48c9d7b1a8ed97c4a021195b8499b804) (cherry picked from commit 559a6d1d2ae2e5145641e1eb16e2c015d756d8c9)
-rw-r--r--update_verifier/update_verifier.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/update_verifier/update_verifier.cpp b/update_verifier/update_verifier.cpp
index faebbede..ba7b7aec 100644
--- a/update_verifier/update_verifier.cpp
+++ b/update_verifier/update_verifier.cpp
@@ -137,11 +137,12 @@ static bool read_blocks(const std::string& partition, const std::string& range_s
LOG(ERROR) << "Error in parsing range string.";
return false;
}
+ range_count /= 2;
std::vector<std::future<bool>> threads;
size_t thread_num = std::thread::hardware_concurrency() ?: 4;
- thread_num = std::min(thread_num, range_count / 2);
- size_t group_range_count = range_count / thread_num;
+ thread_num = std::min(thread_num, range_count);
+ size_t group_range_count = (range_count + thread_num - 1) / thread_num;
for (size_t t = 0; t < thread_num; t++) {
auto thread_func = [t, group_range_count, &dm_block_device, &ranges, &partition]() {
@@ -154,7 +155,8 @@ static bool read_blocks(const std::string& partition, const std::string& range_s
return false;
}
- for (size_t i = 1 + group_range_count * t; i < group_range_count * (t + 1) + 1; i += 2) {
+ for (size_t i = group_range_count * 2 * t + 1;
+ i < std::min(group_range_count * 2 * (t + 1) + 1, ranges.size()); i += 2) {
unsigned int range_start, range_end;
bool parse_status = android::base::ParseUint(ranges[i], &range_start);
parse_status = parse_status && android::base::ParseUint(ranges[i + 1], &range_end);