diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.cpp b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.cpp index c3343b8c6..8e1212b7b 100644 --- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.cpp +++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.cpp @@ -448,5 +448,9 @@ bool SnapshotHandler::IsIouringSupported() { return android::base::GetBoolProperty("ro.virtual_ab.io_uring.enabled", false); } +bool SnapshotHandler::CheckPartitionVerification() { + return update_verify_->CheckPartitionVerification(); +} + } // namespace snapshot } // namespace android diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h index 79a5bc952..c16ad24a5 100644 --- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h +++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h @@ -47,6 +47,7 @@ #include #include #include "snapuserd_readahead.h" +#include "snapuserd_verify.h" namespace android { namespace snapshot { @@ -97,36 +98,6 @@ struct MergeGroupState { : merge_state_(state), num_ios_in_progress(n_ios) {} }; -class UpdateVerify { - public: - UpdateVerify(const std::string& misc_name); - void VerifyUpdatePartition(); - bool CheckPartitionVerification(); - - private: - enum class UpdateVerifyState { - VERIFY_UNKNOWN, - VERIFY_FAILED, - VERIFY_SUCCESS, - }; - - std::string misc_name_; - UpdateVerifyState state_; - std::mutex m_lock_; - std::condition_variable m_cv_; - - int kMinThreadsToVerify = 1; - int kMaxThreadsToVerify = 4; - uint64_t kThresholdSize = 512_MiB; - uint64_t kBlockSizeVerify = 1_MiB; - - bool IsBlockAligned(uint64_t read_size) { return ((read_size & (BLOCK_SZ - 1)) == 0); } - void UpdatePartitionVerificationState(UpdateVerifyState state); - bool VerifyPartition(const std::string& partition_name, const std::string& dm_block_device); - bool VerifyBlocks(const std::string& partition_name, const std::string& dm_block_device, - off_t offset, int skip_blocks, uint64_t dev_sz); -}; - class Worker { public: Worker(const std::string& cow_device, const std::string& backing_device, @@ -308,7 +279,7 @@ class SnapshotHandler : public std::enable_shared_from_this { MERGE_GROUP_STATE ProcessMergingBlock(uint64_t new_block, void* buffer); bool IsIouringSupported(); - bool CheckPartitionVerification() { return update_verify_->CheckPartitionVerification(); } + bool CheckPartitionVerification(); private: bool ReadMetadata(); diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_verify.cpp b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_verify.cpp index 18c1dfcd9..681734080 100644 --- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_verify.cpp +++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_verify.cpp @@ -14,12 +14,14 @@ * limitations under the License. */ -#include "snapuserd_core.h" +#include "snapuserd_verify.h" #include #include #include +#include "snapuserd_core.h" + namespace android { namespace snapshot { diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_verify.h b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_verify.h new file mode 100644 index 000000000..d07d2f836 --- /dev/null +++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_verify.h @@ -0,0 +1,64 @@ +// Copyright (C) 2023 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#pragma once + +#include +#include + +#include +#include +#include + +#include +#include + +namespace android { +namespace snapshot { + +using namespace android::storage_literals; + +class UpdateVerify { + public: + UpdateVerify(const std::string& misc_name); + void VerifyUpdatePartition(); + bool CheckPartitionVerification(); + + private: + enum class UpdateVerifyState { + VERIFY_UNKNOWN, + VERIFY_FAILED, + VERIFY_SUCCESS, + }; + + std::string misc_name_; + UpdateVerifyState state_; + std::mutex m_lock_; + std::condition_variable m_cv_; + + int kMinThreadsToVerify = 1; + int kMaxThreadsToVerify = 4; + uint64_t kThresholdSize = 512_MiB; + uint64_t kBlockSizeVerify = 1_MiB; + + bool IsBlockAligned(uint64_t read_size) { return ((read_size & (BLOCK_SZ - 1)) == 0); } + void UpdatePartitionVerificationState(UpdateVerifyState state); + bool VerifyPartition(const std::string& partition_name, const std::string& dm_block_device); + bool VerifyBlocks(const std::string& partition_name, const std::string& dm_block_device, + off_t offset, int skip_blocks, uint64_t dev_sz); +}; + +} // namespace snapshot +} // namespace android