Skip to content

Commit

Permalink
mds:fix updatechunkserverstat bug & add some logs
Browse files Browse the repository at this point in the history
Signed-off-by: Hanqing Wu <wuhanqing@corp.netease.com>
  • Loading branch information
xu-chaojie authored and wu-hanqing committed Dec 7, 2023
1 parent 6d39feb commit 47a5267
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/chunkserver/chunkserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,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.";

Expand Down
5 changes: 0 additions & 5 deletions src/chunkserver/datastore/file_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ bool FilePool::ScanInternal() {
}
}

currentState_.capacity = tmpvec.size();
currentState_.preallocatedChunksLeft = tmpvec.size();

std::unique_lock<std::mutex> lk(mtx_);
Expand All @@ -539,10 +538,6 @@ size_t FilePool::Size() {
return tmpChunkvec_.size();
}

size_t FilePool::Capacity() {
return currentState_.capacity;
}

FilePoolState FilePool::GetState() const {
return currentState_;
}
Expand Down
4 changes: 0 additions & 4 deletions src/chunkserver/datastore/file_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ struct FilePoolState {
uint32_t metaPageSize = 0;
// io alignment
uint32_t blockSize = 0;
// filepool Capacity
uint64_t capacity = 0;
};

struct FilePoolMeta {
Expand Down Expand Up @@ -173,8 +171,6 @@ class CURVE_CACHELINE_ALIGNMENT FilePool {
*/
virtual size_t Size();

virtual size_t Capacity();

/**
* Get the allocation status of FilePool
*/
Expand Down
16 changes: 11 additions & 5 deletions src/chunkserver/heartbeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/chunkserver/heartbeat.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct HeartbeatOptions {
uint32_t port;
uint32_t intervalSec;
uint32_t timeout;
bool useChunkFilePoolAsWalPool;
CopysetNodeManager* copysetNodeManager;

std::shared_ptr<LocalFileSystem> fs;
Expand Down
6 changes: 5 additions & 1 deletion src/fs/ext4_filesystem_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
11 changes: 4 additions & 7 deletions src/mds/topology/topology_service_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 47a5267

Please sign in to comment.