| 571 | } |
| 572 | |
| 573 | void FlashEnv::UpdateFlashFile(const std::string& fname, uint64_t fsize) { |
| 574 | std::string local_fname = FlashEnv::FlashPath(fname) + fname; |
| 575 | Status copy_status = CopyToLocal(local_fname, dfs_env_, fname, fsize, vanish_allowed_); |
| 576 | |
| 577 | MutexLock l(&update_flash_mutex_); |
| 578 | if (copy_status.ok()) { |
| 579 | UpdateFlashTask& task = update_flash_waiting_files_[fname]; |
| 580 | LOG(INFO) << "[env_flash] copy to local success, id: " << task.id << ", prio: " << task.priority |
| 581 | << ", file: " << local_fname.c_str() |
| 582 | << ", pend: " << update_flash_threads_.GetPendingTaskNum(); |
| 583 | update_flash_waiting_files_.erase(fname); |
| 584 | } else { |
| 585 | UpdateFlashTask& task = update_flash_waiting_files_[fname]; |
| 586 | LOG(WARNING) << "[env_flash] copy to local fail [" << copy_status.ToString().c_str() |
| 587 | << "], id: " << task.id << ", prio: " << task.priority |
| 588 | << ", file: " << local_fname.c_str() |
| 589 | << ", pend: " << update_flash_threads_.GetPendingTaskNum(); |
| 590 | |
| 591 | task.priority >>= 1; // cut down priority to half |
| 592 | if (task.priority > 0) { |
| 593 | UpdateFlashFileParam* param = new UpdateFlashFileParam; |
| 594 | param->flash_env = this; |
| 595 | param->fname = fname; |
| 596 | param->fsize = fsize; |
| 597 | |
| 598 | task.id = update_flash_threads_.Schedule(UpdateFlashFileFunc, param, (double)task.priority, |
| 599 | update_flash_retry_interval_millis_); |
| 600 | LOG(INFO) << "[env_flash] schedule copy to local after " |
| 601 | << update_flash_retry_interval_millis_ << " ms, id: " << task.id |
| 602 | << ", prio: " << task.priority << ", file: " << local_fname.c_str(); |
| 603 | } else { |
| 604 | LOG(INFO) << "[env_flash] abort schedule copy to local, file: " << local_fname.c_str(); |
| 605 | update_flash_waiting_files_.erase(fname); |
| 606 | } |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | void FlashEnv::TryRollbackPersistentCacheFiles() { |
| 611 | for (auto& flash_path : flash_paths_) { |
no test coverage detected