Skip to content

Commit ba30867

Browse files
Tao Baoandroid-build-team Robot
Tao Bao
authored and
android-build-team Robot
committed
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 559a6d1)
1 parent 43da853 commit ba30867

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

update_verifier/update_verifier.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,12 @@ static bool read_blocks(const std::string& partition, const std::string& range_s
137137
LOG(ERROR) << "Error in parsing range string.";
138138
return false;
139139
}
140+
range_count /= 2;
140141

141142
std::vector<std::future<bool>> threads;
142143
size_t thread_num = std::thread::hardware_concurrency() ?: 4;
143-
thread_num = std::min(thread_num, range_count / 2);
144-
size_t group_range_count = range_count / thread_num;
144+
thread_num = std::min(thread_num, range_count);
145+
size_t group_range_count = (range_count + thread_num - 1) / thread_num;
145146

146147
for (size_t t = 0; t < thread_num; t++) {
147148
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
154155
return false;
155156
}
156157

157-
for (size_t i = 1 + group_range_count * t; i < group_range_count * (t + 1) + 1; i += 2) {
158+
for (size_t i = group_range_count * 2 * t + 1;
159+
i < std::min(group_range_count * 2 * (t + 1) + 1, ranges.size()); i += 2) {
158160
unsigned int range_start, range_end;
159161
bool parse_status = android::base::ParseUint(ranges[i], &range_start);
160162
parse_status = parse_status && android::base::ParseUint(ranges[i + 1], &range_end);

0 commit comments

Comments
 (0)