Skip to content

Commit 47a5267

Browse files
xu-chaojiewu-hanqing
authored andcommitted
mds:fix updatechunkserverstat bug & add some logs
Signed-off-by: Hanqing Wu <wuhanqing@corp.netease.com>
1 parent 6d39feb commit 47a5267

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

src/chunkserver/chunkserver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ int ChunkServer::Run(int argc, char** argv) {
294294
heartbeatOptions.chunkFilePool = chunkfilePool;
295295
heartbeatOptions.chunkserverId = metadata.id();
296296
heartbeatOptions.chunkserverToken = metadata.token();
297+
heartbeatOptions.useChunkFilePoolAsWalPool = useChunkFilePoolAsWalPool;
297298
LOG_IF(FATAL, heartbeat_.Init(heartbeatOptions) != 0)
298299
<< "Failed to init Heartbeat manager.";
299300

src/chunkserver/datastore/file_pool.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ bool FilePool::ScanInternal() {
524524
}
525525
}
526526

527-
currentState_.capacity = tmpvec.size();
528527
currentState_.preallocatedChunksLeft = tmpvec.size();
529528

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

542-
size_t FilePool::Capacity() {
543-
return currentState_.capacity;
544-
}
545-
546541
FilePoolState FilePool::GetState() const {
547542
return currentState_;
548543
}

src/chunkserver/datastore/file_pool.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ struct FilePoolState {
7373
uint32_t metaPageSize = 0;
7474
// io alignment
7575
uint32_t blockSize = 0;
76-
// filepool Capacity
77-
uint64_t capacity = 0;
7876
};
7977

8078
struct FilePoolMeta {
@@ -173,8 +171,6 @@ class CURVE_CACHELINE_ALIGNMENT FilePool {
173171
*/
174172
virtual size_t Size();
175173

176-
virtual size_t Capacity();
177-
178174
/**
179175
* Get the allocation status of FilePool
180176
*/

src/chunkserver/heartbeat.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,17 @@ int Heartbeat::BuildRequest(HeartbeatRequest* req) {
250250
// leftWalSegmentSize will be 0 when CHUNK and WAL share file pool
251251
uint64_t leftWalSegmentSize = metric->GetWalSegmentLeftCount()
252252
* walSegmentFileSize;
253-
uint64_t chunkPoolSize = options_.chunkFilePool->Capacity() *
254-
options_.chunkFilePool->GetFilePoolOpt().fileSize;
255-
stats->set_chunkfilepoolsize(chunkPoolSize);
256-
stats->set_chunksizeusedbytes(usedChunkSize+usedWalSegmentSize);
257-
stats->set_chunksizeleftbytes(leftChunkSize+leftWalSegmentSize);
253+
// CHUNK and WAL share file pool
254+
uint64_t totalSize = 0;
255+
if (options_.useChunkFilePoolAsWalPool) {
256+
totalSize = usedChunkSize + usedWalSegmentSize +
257+
leftChunkSize + leftWalSegmentSize;
258+
} else {
259+
totalSize = usedChunkSize + leftChunkSize;
260+
}
261+
stats->set_chunkfilepoolsize(totalSize);
262+
stats->set_chunksizeusedbytes(usedChunkSize + usedWalSegmentSize);
263+
stats->set_chunksizeleftbytes(leftChunkSize + leftWalSegmentSize);
258264
stats->set_chunksizetrashedbytes(trashedChunkSize);
259265
req->set_allocated_stats(stats);
260266

src/chunkserver/heartbeat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct HeartbeatOptions {
7070
uint32_t port;
7171
uint32_t intervalSec;
7272
uint32_t timeout;
73+
bool useChunkFilePoolAsWalPool;
7374
CopysetNodeManager* copysetNodeManager;
7475

7576
std::shared_ptr<LocalFileSystem> fs;

src/fs/ext4_filesystem_impl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,11 @@ int Ext4FileSystemImpl::Write(int fd,
346346
continue;
347347
}
348348
LOG(ERROR) << "IOBuf::pcut_into_file_descriptor failed: "
349-
<< strerror(errno);
349+
<< strerror(errno)
350+
<< ", fd: " << fd
351+
<< ", offset: " << offset
352+
<< ", remainLength: " << remainLength
353+
<< ", length: " << length;
350354
return -errno;
351355
}
352356

src/mds/topology/topology_service_manager.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,9 @@ void TopologyServiceManager::RegistChunkServer(
8282

8383
std::string hostIp = request->hostip();
8484
uint32_t port = request->port();
85-
ChunkServerStat stat;
8685
bool useChunkFilePoolAsWalPool = false;
8786
uint32_t useChunkFilePoolAsWalPoolReserve;
8887
bool useChunkFilepool = false;
89-
if (request->has_chunkfilepoolsize()) {
90-
stat.chunkFilepoolSize = request->chunkfilepoolsize();
91-
}
9288
if (request->has_usechunkfilepoolaswalpool()) {
9389
useChunkFilepool = true;
9490
useChunkFilePoolAsWalPool = request->usechunkfilepoolaswalpool();
@@ -135,7 +131,7 @@ void TopologyServiceManager::RegistChunkServer(
135131
response->set_statuscode(kTopoErrCodeSuccess);
136132
response->set_chunkserverid(cs.GetId());
137133
response->set_token(cs.GetToken());
138-
topoStat_->UpdateChunkServerStat(cs.GetId(), stat);
134+
139135
topologyChunkAllocator_->UpdateChunkFilePoolAllocConfig(
140136
useChunkFilepool, useChunkFilePoolAsWalPool,
141137
useChunkFilePoolAsWalPoolReserve);
@@ -172,8 +168,6 @@ void TopologyServiceManager::RegistChunkServer(
172168
response->set_statuscode(kTopoErrCodeSuccess);
173169
response->set_chunkserverid(cs.GetId());
174170
response->set_token(cs.GetToken());
175-
topoStat_->UpdateChunkServerStat(cs.GetId(),
176-
stat);
177171
topologyChunkAllocator_->UpdateChunkFilePoolAllocConfig(
178172
useChunkFilepool, useChunkFilePoolAsWalPool,
179173
useChunkFilePoolAsWalPoolReserve);
@@ -253,6 +247,9 @@ void TopologyServiceManager::RegistChunkServer(
253247
response->set_token(chunkserver.GetToken());
254248
ChunkServerStat stat;
255249
stat.chunkFilepoolSize = request->chunkfilepoolsize();
250+
stat.chunkSizeUsedBytes = 0;
251+
stat.chunkSizeLeftBytes = stat.chunkFilepoolSize;
252+
stat.chunkSizeTrashedBytes = 0;
256253
topoStat_->UpdateChunkServerStat(chunkserver.GetId(), stat);
257254
topologyChunkAllocator_->UpdateChunkFilePoolAllocConfig(
258255
useChunkFilepool, useChunkFilePoolAsWalPool,

0 commit comments

Comments
 (0)