libsnapshot: configure threshold size
Test: th Change-Id: Iba59fdc3e1188dd343314d129806d2c4c94aa8c5
This commit is contained in:
parent
db560090e4
commit
28801377a5
1 changed files with 11 additions and 4 deletions
|
@ -20,6 +20,7 @@
|
|||
#include <android-base/scopeguard.h>
|
||||
#include <android-base/strings.h>
|
||||
|
||||
#include "android-base/properties.h"
|
||||
#include "snapuserd_core.h"
|
||||
|
||||
namespace android {
|
||||
|
@ -104,7 +105,9 @@ bool UpdateVerify::VerifyBlocks(const std::string& partition_name,
|
|||
}
|
||||
|
||||
loff_t file_offset = offset;
|
||||
const uint64_t read_sz = kBlockSizeVerify;
|
||||
auto verify_block_size = android::base::GetUintProperty<uint>("ro.virtual_ab.verify_block_size",
|
||||
kBlockSizeVerify);
|
||||
const uint64_t read_sz = verify_block_size;
|
||||
|
||||
void* addr;
|
||||
ssize_t page_size = getpagesize();
|
||||
|
@ -130,7 +133,7 @@ bool UpdateVerify::VerifyBlocks(const std::string& partition_name,
|
|||
}
|
||||
|
||||
bytes_read += to_read;
|
||||
file_offset += (skip_blocks * kBlockSizeVerify);
|
||||
file_offset += (skip_blocks * verify_block_size);
|
||||
if (file_offset >= dev_sz) {
|
||||
break;
|
||||
}
|
||||
|
@ -184,7 +187,9 @@ bool UpdateVerify::VerifyPartition(const std::string& partition_name,
|
|||
* latency.
|
||||
*/
|
||||
int num_threads = kMinThreadsToVerify;
|
||||
if (dev_sz > kThresholdSize) {
|
||||
auto verify_threshold_size = android::base::GetUintProperty<uint>(
|
||||
"ro.virtual_ab.verify_threshold_size", kThresholdSize);
|
||||
if (dev_sz > verify_threshold_size) {
|
||||
num_threads = kMaxThreadsToVerify;
|
||||
}
|
||||
|
||||
|
@ -192,11 +197,13 @@ bool UpdateVerify::VerifyPartition(const std::string& partition_name,
|
|||
off_t start_offset = 0;
|
||||
const int skip_blocks = num_threads;
|
||||
|
||||
auto verify_block_size =
|
||||
android::base::GetUintProperty("ro.virtual_ab.verify_block_size", kBlockSizeVerify);
|
||||
while (num_threads) {
|
||||
threads.emplace_back(std::async(std::launch::async, &UpdateVerify::VerifyBlocks, this,
|
||||
partition_name, dm_block_device, start_offset, skip_blocks,
|
||||
dev_sz));
|
||||
start_offset += kBlockSizeVerify;
|
||||
start_offset += verify_block_size;
|
||||
num_threads -= 1;
|
||||
if (start_offset >= dev_sz) {
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue