diff --git a/src/chunkserver/chunkserver.cpp b/src/chunkserver/chunkserver.cpp index d982f068f5..5e6fb7491a 100644 --- a/src/chunkserver/chunkserver.cpp +++ b/src/chunkserver/chunkserver.cpp @@ -299,6 +299,7 @@ int ChunkServer::Run(int argc, char** argv) { heartbeatOptions.chunkFilePool = chunkfilePool; heartbeatOptions.chunkserverId = metadata.id(); heartbeatOptions.chunkserverToken = metadata.token(); + heartbeatOptions.useChunkFilePoolAsWalPool = useChunkFilePoolAsWalPool; LOG_IF(FATAL, heartbeat_.Init(heartbeatOptions) != 0) << "Failed to init Heartbeat manager."; diff --git a/src/chunkserver/datastore/chunkserver_chunkfile_v2.cpp b/src/chunkserver/datastore/chunkserver_chunkfile_v2.cpp index bd7a86056d..1ccf320fd8 100644 --- a/src/chunkserver/datastore/chunkserver_chunkfile_v2.cpp +++ b/src/chunkserver/datastore/chunkserver_chunkfile_v2.cpp @@ -1237,7 +1237,7 @@ CSErrorCode CSChunkFile_V2::Delete(SequenceNum sn) { if (ret < 0) return CSErrorCode::InternalError; - DVLOG(9) << "Chunk deleted." + LOG(INFO) << "Chunk deleted." << "ChunkID: " << chunkId_ << ", request sn: " << sn << ", chunk sn: " << metaPage_.sn; diff --git a/src/chunkserver/datastore/file_pool.cpp b/src/chunkserver/datastore/file_pool.cpp index 4c7af601b2..8a4430b0c4 100644 --- a/src/chunkserver/datastore/file_pool.cpp +++ b/src/chunkserver/datastore/file_pool.cpp @@ -524,7 +524,6 @@ bool FilePool::ScanInternal() { } } - currentState_.capacity = tmpvec.size(); currentState_.preallocatedChunksLeft = tmpvec.size(); std::unique_lock lk(mtx_); @@ -539,10 +538,6 @@ size_t FilePool::Size() { return tmpChunkvec_.size(); } -size_t FilePool::Capacity() { - return currentState_.capacity; -} - FilePoolState FilePool::GetState() const { return currentState_; } diff --git a/src/chunkserver/datastore/file_pool.h b/src/chunkserver/datastore/file_pool.h index 4c2a2a8d7d..25c1662529 100644 --- a/src/chunkserver/datastore/file_pool.h +++ b/src/chunkserver/datastore/file_pool.h @@ -73,8 +73,6 @@ struct FilePoolState { uint32_t metaPageSize = 0; // io alignment uint32_t blockSize = 0; - // filepool Capacity - uint64_t capacity = 0; }; struct FilePoolMeta { @@ -173,8 +171,6 @@ class CURVE_CACHELINE_ALIGNMENT FilePool { */ virtual size_t Size(); - virtual size_t Capacity(); - /** * Get the allocation status of FilePool */ diff --git a/src/chunkserver/heartbeat.cpp b/src/chunkserver/heartbeat.cpp index efb5c1f423..41bfbd4f55 100644 --- a/src/chunkserver/heartbeat.cpp +++ b/src/chunkserver/heartbeat.cpp @@ -250,11 +250,17 @@ int Heartbeat::BuildRequest(HeartbeatRequest* req) { // leftWalSegmentSize will be 0 when CHUNK and WAL share file pool uint64_t leftWalSegmentSize = metric->GetWalSegmentLeftCount() * walSegmentFileSize; - uint64_t chunkPoolSize = options_.chunkFilePool->Capacity() * - options_.chunkFilePool->GetFilePoolOpt().fileSize; - stats->set_chunkfilepoolsize(chunkPoolSize); - stats->set_chunksizeusedbytes(usedChunkSize+usedWalSegmentSize); - stats->set_chunksizeleftbytes(leftChunkSize+leftWalSegmentSize); + // CHUNK and WAL share file pool + uint64_t totalSize = 0; + if (options_.useChunkFilePoolAsWalPool) { + totalSize = usedChunkSize + usedWalSegmentSize + + leftChunkSize + leftWalSegmentSize; + } else { + totalSize = usedChunkSize + leftChunkSize; + } + stats->set_chunkfilepoolsize(totalSize); + stats->set_chunksizeusedbytes(usedChunkSize + usedWalSegmentSize); + stats->set_chunksizeleftbytes(leftChunkSize + leftWalSegmentSize); stats->set_chunksizetrashedbytes(trashedChunkSize); req->set_allocated_stats(stats); diff --git a/src/chunkserver/heartbeat.h b/src/chunkserver/heartbeat.h index 2a047506fa..b4c30d0d9f 100644 --- a/src/chunkserver/heartbeat.h +++ b/src/chunkserver/heartbeat.h @@ -70,6 +70,7 @@ struct HeartbeatOptions { uint32_t port; uint32_t intervalSec; uint32_t timeout; + bool useChunkFilePoolAsWalPool; CopysetNodeManager* copysetNodeManager; std::shared_ptr fs; diff --git a/src/fs/ext4_filesystem_impl.cpp b/src/fs/ext4_filesystem_impl.cpp index 4116146f42..6ed6430a27 100644 --- a/src/fs/ext4_filesystem_impl.cpp +++ b/src/fs/ext4_filesystem_impl.cpp @@ -346,7 +346,11 @@ int Ext4FileSystemImpl::Write(int fd, continue; } LOG(ERROR) << "IOBuf::pcut_into_file_descriptor failed: " - << strerror(errno); + << strerror(errno) + << ", fd: " << fd + << ", offset: " << offset + << ", remainLength: " << remainLength + << ", length: " << length; return -errno; } diff --git a/src/mds/topology/topology_service_manager.cpp b/src/mds/topology/topology_service_manager.cpp index e648ff5a48..3fa0dd3fa1 100644 --- a/src/mds/topology/topology_service_manager.cpp +++ b/src/mds/topology/topology_service_manager.cpp @@ -82,13 +82,9 @@ void TopologyServiceManager::RegistChunkServer( std::string hostIp = request->hostip(); uint32_t port = request->port(); - ChunkServerStat stat; bool useChunkFilePoolAsWalPool = false; uint32_t useChunkFilePoolAsWalPoolReserve; bool useChunkFilepool = false; - if (request->has_chunkfilepoolsize()) { - stat.chunkFilepoolSize = request->chunkfilepoolsize(); - } if (request->has_usechunkfilepoolaswalpool()) { useChunkFilepool = true; useChunkFilePoolAsWalPool = request->usechunkfilepoolaswalpool(); @@ -135,7 +131,7 @@ void TopologyServiceManager::RegistChunkServer( response->set_statuscode(kTopoErrCodeSuccess); response->set_chunkserverid(cs.GetId()); response->set_token(cs.GetToken()); - topoStat_->UpdateChunkServerStat(cs.GetId(), stat); + topologyChunkAllocator_->UpdateChunkFilePoolAllocConfig( useChunkFilepool, useChunkFilePoolAsWalPool, useChunkFilePoolAsWalPoolReserve); @@ -172,8 +168,6 @@ void TopologyServiceManager::RegistChunkServer( response->set_statuscode(kTopoErrCodeSuccess); response->set_chunkserverid(cs.GetId()); response->set_token(cs.GetToken()); - topoStat_->UpdateChunkServerStat(cs.GetId(), - stat); topologyChunkAllocator_->UpdateChunkFilePoolAllocConfig( useChunkFilepool, useChunkFilePoolAsWalPool, useChunkFilePoolAsWalPoolReserve); @@ -253,6 +247,9 @@ void TopologyServiceManager::RegistChunkServer( response->set_token(chunkserver.GetToken()); ChunkServerStat stat; stat.chunkFilepoolSize = request->chunkfilepoolsize(); + stat.chunkSizeUsedBytes = 0; + stat.chunkSizeLeftBytes = stat.chunkFilepoolSize; + stat.chunkSizeTrashedBytes = 0; topoStat_->UpdateChunkServerStat(chunkserver.GetId(), stat); topologyChunkAllocator_->UpdateChunkFilePoolAllocConfig( useChunkFilepool, useChunkFilePoolAsWalPool, diff --git a/src/mds/topology/topology_stat.cpp b/src/mds/topology/topology_stat.cpp index c420030395..43433b5763 100644 --- a/src/mds/topology/topology_stat.cpp +++ b/src/mds/topology/topology_stat.cpp @@ -56,7 +56,17 @@ void TopologyStatImpl::UpdateChunkServerStat(ChunkServerIdType csId, int64_t diffUsed = stat.chunkSizeUsedBytes - it->second.chunkSizeUsedBytes; physicalPoolStats_[belongPhysicalPoolId].chunkFilePoolUsed += diffUsed; - + VLOG(3) << "UpdateChunkServerStat, chunkserver stat update," + << " chunkserverId = " + << csId + << ", chunkFilePoolSize = " + << stat.chunkFilepoolSize + << ", chunkFilePoolUsed = " + << stat.chunkSizeUsedBytes + << ", diff = " + << diff + << ", diffUsed = " + << diffUsed; if (chunkFilePoolAllocHelp_->GetUseChunkFilepool()) { if (stat.chunkSizeUsedBytes > (stat.chunkFilepoolSize * available / 100)) {