| 798 | } |
| 799 | |
| 800 | Status DataCache::Partition::CloseFilesAndVerifySizes() { |
| 801 | if (trace_replay_) return Status::OK(); |
| 802 | int64_t total_size = 0; |
| 803 | for (auto& file : cache_files_) { |
| 804 | uint64_t sz_on_disk; |
| 805 | // Close the backing files before checking sizes as some filesystems (e.g. XFS) |
| 806 | // preallocate the file beyond EOF. Closing the file removes any preallocation. |
| 807 | file->Close(); |
| 808 | kudu::Env* env = kudu::Env::Default(); |
| 809 | KUDU_RETURN_IF_ERROR(env->GetFileSizeOnDisk(file->path(), &sz_on_disk), |
| 810 | "CloseFilesAndVerifySizes()"); |
| 811 | total_size += sz_on_disk; |
| 812 | uint64_t logical_sz; |
| 813 | KUDU_RETURN_IF_ERROR(env->GetFileSize(file->path(), &logical_sz), |
| 814 | "CloseFilesAndVerifySizes()"); |
| 815 | DCHECK_LE(logical_sz, FLAGS_data_cache_file_max_size_bytes); |
| 816 | } |
| 817 | if (total_size > capacity_) { |
| 818 | return Status(Substitute("Partition $0 consumed $1 bytes, exceeding capacity of $2 " |
| 819 | "bytes", path_, total_size, capacity_)); |
| 820 | } |
| 821 | return Status::OK(); |
| 822 | } |
| 823 | |
| 824 | void DataCache::Partition::ReleaseResources() { |
| 825 | std::unique_lock<SpinLock> partition_lock(lock_); |