Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curvefs/client: fix client core dump error #2157

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions curvefs/src/client/fuse_s3_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ using curvefs::mds::topology::MemcacheServerInfo;

CURVEFS_ERROR FuseS3Client::Init(const FuseClientOption &option) {
FuseClientOption opt(option);
// init kvcache
if (FLAGS_supportKVcache && !InitKVCache(option.kvClientManagerOpt)) {
return CURVEFS_ERROR::INTERNAL;
}
initbgFetchThread_ = false;

CURVEFS_ERROR ret = FuseClient::Init(opt);
if (ret != CURVEFS_ERROR::OK) {
return ret;
}

// init kvcache
if (FLAGS_supportKVcache && !InitKVCache(option.kvClientManagerOpt)) {
return CURVEFS_ERROR::INTERNAL;
}

// set fs S3Option
const auto& s3Info = fsInfo_->detail().s3info();
::curve::common::S3InfoOption fsS3Option;
Expand Down Expand Up @@ -92,6 +94,7 @@ CURVEFS_ERROR FuseS3Client::Init(const FuseClientOption &option) {

bgFetchStop_.store(false, std::memory_order_release);
bgFetchThread_ = Thread(&FuseS3Client::BackGroundFetch, this);
initbgFetchThread_ = true;
GetTaskFetchPool();
return ret;
}
Expand Down Expand Up @@ -370,7 +373,9 @@ void FuseS3Client::travelChunks(fuse_ino_t ino, google::protobuf::Map<uint64_t,

void FuseS3Client::UnInit() {
bgFetchStop_.store(true, std::memory_order_release);
bgFetchThread_.join();
if (initbgFetchThread_) {
bgFetchThread_.join();
}
FuseClient::UnInit();
s3Adaptor_->Stop();
curve::common::S3Adapter::Shutdown();
Expand Down
15 changes: 7 additions & 8 deletions curvefs/src/client/fuse_s3_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@ using curve::common::GetObjectAsyncCallBack;
class FuseS3Client : public FuseClient {
public:
FuseS3Client()
: FuseClient(),
s3Adaptor_(std::make_shared<S3ClientAdaptorImpl>()) {}
: FuseClient(), s3Adaptor_(std::make_shared<S3ClientAdaptorImpl>()) {}

FuseS3Client(const std::shared_ptr<MdsClient> &mdsClient,
const std::shared_ptr<MetaServerClient> &metaClient,
const std::shared_ptr<InodeCacheManager> &inodeManager,
const std::shared_ptr<DentryCacheManager> &dentryManager,
const std::shared_ptr<S3ClientAdaptor> &s3Adaptor)
: FuseClient(mdsClient, metaClient,
inodeManager, dentryManager),
const std::shared_ptr<MetaServerClient> &metaClient,
const std::shared_ptr<InodeCacheManager> &inodeManager,
const std::shared_ptr<DentryCacheManager> &dentryManager,
const std::shared_ptr<S3ClientAdaptor> &s3Adaptor)
: FuseClient(mdsClient, metaClient, inodeManager, dentryManager),
s3Adaptor_(s3Adaptor) {}

CURVEFS_ERROR Init(const FuseClientOption &option) override;
Expand Down Expand Up @@ -120,6 +118,7 @@ class FuseS3Client : public FuseClient {
// s3 adaptor
std::shared_ptr<S3ClientAdaptor> s3Adaptor_;

bool initbgFetchThread_;
Thread bgFetchThread_;
std::atomic<bool> bgFetchStop_;
std::mutex fetchMtx_;
Expand Down
2 changes: 1 addition & 1 deletion curvefs/src/client/rpcclient/mds_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ bool MdsClientImpl::AllocOrGetMemcacheCluster(uint32_t fsId,
return ret;
};

return ReturnError(rpcexcutor_.DoRPCTask(task, mdsOpt_.mdsMaxRetryMS));
return 0 == ReturnError(rpcexcutor_.DoRPCTask(task, mdsOpt_.mdsMaxRetryMS));
}

FSStatusCode MdsClientImpl::AllocS3ChunkId(uint32_t fsId, uint32_t idNum,
Expand Down
1 change: 1 addition & 0 deletions curvefs/test/client/test_fuse_s3_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ TEST_F(TestFuseS3Client, test_Init_with_KVCache) {
.WillOnce(DoAll(SetArgPointee<1>(memcacheCluster), Return(false)));

ASSERT_EQ(CURVEFS_ERROR::INTERNAL, testclient->Init(opt));
testclient->UnInit();
}
curvefs::client::common::FLAGS_supportKVcache = false;
}
Expand Down