Merge "libsnapshot: Print merge completion ops" am: 51858a0494 am: 38a82623ef
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1584487 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ida43f88d5efb52726a6149da3b1954f6d62411a0
This commit is contained in:
commit
eb0df60cd2
5 changed files with 26 additions and 1 deletions
|
|
@ -237,6 +237,7 @@ void CowReader::InitializeMerge() {
|
|||
[](CowOperation& op) { return IsMetadataOp(op); }),
|
||||
ops_.get()->end());
|
||||
|
||||
set_total_data_ops(ops_->size());
|
||||
// We will re-arrange the vector in such a way that
|
||||
// kernel can batch merge. Ex:
|
||||
//
|
||||
|
|
|
|||
|
|
@ -142,6 +142,10 @@ class CowReader : public ICowReader {
|
|||
|
||||
void InitializeMerge();
|
||||
|
||||
void set_total_data_ops(uint64_t size) { total_data_ops_ = size; }
|
||||
|
||||
uint64_t total_data_ops() { return total_data_ops_; }
|
||||
|
||||
private:
|
||||
bool ParseOps(std::optional<uint64_t> label);
|
||||
|
||||
|
|
@ -152,6 +156,7 @@ class CowReader : public ICowReader {
|
|||
uint64_t fd_size_;
|
||||
std::optional<uint64_t> last_label_;
|
||||
std::shared_ptr<std::vector<CowOperation>> ops_;
|
||||
uint64_t total_data_ops_;
|
||||
};
|
||||
|
||||
} // namespace snapshot
|
||||
|
|
|
|||
|
|
@ -424,6 +424,7 @@ bool Snapuserd::ProcessMergeComplete(chunk_t chunk, void* buffer) {
|
|||
}
|
||||
|
||||
SNAP_LOG(DEBUG) << "Merge success: " << merged_ops_cur_iter << "chunk: " << chunk;
|
||||
merge_initiated_ = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -445,6 +446,19 @@ chunk_t Snapuserd::GetNextAllocatableChunkId(chunk_t chunk) {
|
|||
return next_chunk;
|
||||
}
|
||||
|
||||
void Snapuserd::CheckMergeCompletionStatus() {
|
||||
CowHeader header;
|
||||
|
||||
if (merge_initiated_) {
|
||||
reader_->GetHeader(&header);
|
||||
SNAP_LOG(INFO) << "Merge-status: Total-Merged-ops: " << header.num_merge_ops
|
||||
<< " Total-data-ops: " << reader_->total_data_ops();
|
||||
} else {
|
||||
SNAP_LOG(INFO) << "Merge was not initiated. Total-Merged-ops: " << header.num_merge_ops
|
||||
<< " Total-data-ops: " << reader_->total_data_ops();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the metadata from COW device and
|
||||
* construct the metadata as required by the kernel.
|
||||
|
|
@ -818,11 +832,13 @@ bool Snapuserd::ReadMetadata() {
|
|||
<< " Num Sector: " << ChunkToSector(data_chunk_id)
|
||||
<< " Replace-ops: " << replace_ops << " Zero-ops: " << zero_ops
|
||||
<< " Copy-ops: " << copy_ops << " Areas: " << vec_.size()
|
||||
<< " Num-ops-merged: " << header.num_merge_ops;
|
||||
<< " Num-ops-merged: " << header.num_merge_ops
|
||||
<< " Total-data-ops: " << reader_->total_data_ops();
|
||||
|
||||
// Total number of sectors required for creating dm-user device
|
||||
num_sectors_ = ChunkToSector(data_chunk_id);
|
||||
metadata_read_done_ = true;
|
||||
merge_initiated_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ class Snapuserd final {
|
|||
const std::string& GetMiscName() { return misc_name_; }
|
||||
uint64_t GetNumSectors() { return num_sectors_; }
|
||||
bool IsAttached() const { return ctrl_fd_ >= 0; }
|
||||
void CheckMergeCompletionStatus();
|
||||
void CloseFds() {
|
||||
ctrl_fd_ = {};
|
||||
cow_fd_ = {};
|
||||
|
|
@ -141,6 +142,7 @@ class Snapuserd final {
|
|||
std::map<sector_t, const CowOperation*> chunk_map_;
|
||||
|
||||
bool metadata_read_done_ = false;
|
||||
bool merge_initiated_ = false;
|
||||
BufferSink bufsink_;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ void SnapuserdServer::RunThread(std::shared_ptr<DmUserHandler> handler) {
|
|||
|
||||
auto misc_name = handler->misc_name();
|
||||
LOG(INFO) << "Handler thread about to exit: " << misc_name;
|
||||
handler->snapuserd()->CheckMergeCompletionStatus();
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(lock_);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue