diff --git a/src/chunkserver/copyset_node.cpp b/src/chunkserver/copyset_node.cpp index b9594e0739..02eb26797a 100755 --- a/src/chunkserver/copyset_node.cpp +++ b/src/chunkserver/copyset_node.cpp @@ -281,7 +281,7 @@ uint64_t CopysetNode::GetHashCode(const ChunkRequest* request) { version = request->version(); } if (version == curve::common::kBaseFileVersion) { - hashcode = std::hash{} (request->fileid()); + hashcode = std::hash{} (request->chunkid()); } else { // judge if has originfileId if (request->has_originfileid()) { @@ -298,7 +298,7 @@ uint64_t CopysetNode::GetHashCode(const ChunkRequest* request) { break; default: - hashcode = std::hash{} (request->fileid()); + hashcode = std::hash{} (request->chunkid()); break; } // has no originfileId it is the origin file just use the fileid @@ -314,7 +314,7 @@ uint64_t CopysetNode::GetHashCode(const ChunkRequest* request) { break; default: - hashcode = std::hash{} (request->fileid()); + hashcode = std::hash{} (request->chunkid()); break; } } diff --git a/src/chunkserver/op_request.cpp b/src/chunkserver/op_request.cpp index 9696650863..000d512f30 100755 --- a/src/chunkserver/op_request.cpp +++ b/src/chunkserver/op_request.cpp @@ -219,6 +219,15 @@ void DeleteChunkRequest::OnApply(uint64_t index, void DeleteChunkRequest::OnApplyFromLog(std::shared_ptr datastore, const ChunkRequest &request, const butil::IOBuf &data) { + uint64_t originfiledid = request.originfileid(); + uint64_t filedid = request.fileid(); + VLOG(9) << "DeleteChunkRequest::OnApplyFromLog: " + << " logic pool id: " << request.logicpoolid() + << " copyset id: " << request.copysetid() + << " chunkid: " << request.chunkid() + << " originfileid: " << originfiledid + << " fileid: " << filedid + << " version: " << request.version(); // NOTE: 处理过程中优先使用参数传入的datastore/request auto ret = datastore->DeleteChunk(request.chunkid(), request.sn(), @@ -650,6 +659,15 @@ void WriteChunkRequest::OnApply(uint64_t index, void WriteChunkRequest::OnApplyFromLog(std::shared_ptr datastore, const ChunkRequest &request, const butil::IOBuf &data) { + uint64_t originfiledid = request.originfileid(); + uint64_t filedid = request.fileid(); + VLOG(9) << "WriteChunkRequest::OnApplyFromLog: " + << " logic pool id: " << request.logicpoolid() + << " copyset id: " << request.copysetid() + << " chunkid: " << request.chunkid() + << " originfileid: " << originfiledid + << " fileid: " << filedid + << " version: " << request.version(); // NOTE: 处理过程中优先使用参数传入的datastore/request uint32_t cost; std::string cloneSourceLocation; diff --git a/src/client/request_context.h b/src/client/request_context.h index 3eb6d999d7..2b3ab9f0e6 100644 --- a/src/client/request_context.h +++ b/src/client/request_context.h @@ -123,8 +123,8 @@ struct CURVE_CACHELINE_ALIGNMENT RequestContext { FileType filetype_; std::vector cloneChain_; - uint64_t originFileId_; - uint64_t chunkIndex_; + uint64_t originFileId_ = 0; + uint64_t chunkIndex_ = 0; uint32_t version_; diff --git a/src/client/request_sender.cpp b/src/client/request_sender.cpp index 6c2623a9fe..4b50797cd5 100644 --- a/src/client/request_sender.cpp +++ b/src/client/request_sender.cpp @@ -115,8 +115,11 @@ int RequestSender::WriteChunk(RequestContext *ctx, request.set_chunkindex(ctx->chunkIndex_); request.set_version(ctx->version_); - if (ctx->filetype_ == FileType::INODE_CLONE_PAGEFILE) { + if (ctx->originFileId_ != 0) { request.set_originfileid(ctx->originFileId_); + } + + if (ctx->filetype_ == FileType::INODE_CLONE_PAGEFILE) { for (int i = 0; i < ctx->cloneChain_.size(); i++) { auto cinfo = request.add_clones(); cinfo->set_fileid(ctx->cloneChain_[i].fileId); diff --git a/src/client/splitor.cpp b/src/client/splitor.cpp index f2dda7d598..417b9b8149 100644 --- a/src/client/splitor.cpp +++ b/src/client/splitor.cpp @@ -206,11 +206,10 @@ bool Splitor::AssignInternal(IOTracker* iotracker, MetaCache* metaCache, ctx->sourceInfo_ = CalcRequestSourceInfo(iotracker, metaCache, chunkidx); } - if (fileInfo->filetype == FileType::INODE_CLONE_PAGEFILE) { - ret = AssignCloneFileInfo( - iotracker, &templist, mdsclient, - fileInfo, chunkidx, chunkIdInfo); - } + + ret = AssignCloneFileInfo( + iotracker, &templist, mdsclient, + fileInfo, chunkidx, chunkIdInfo); targetlist->insert(targetlist->end(), templist.begin(), templist.end()); @@ -454,8 +453,11 @@ int Splitor::AssignCloneFileInfo(IOTracker* iotracker, ChunkIndex chunkidx, const ChunkIDInfo &chunkIdInfo) { for (auto& ctx : *targetlist) { + // always take originFileId ctx->originFileId_ = chunkIdInfo.originFileId_; - ctx->cloneChain_ = fileInfo->cloneChain; + if (fileInfo->filetype == FileType::INODE_CLONE_PAGEFILE) { + ctx->cloneChain_ = fileInfo->cloneChain; + } } return 0; }