Skip to content

Commit

Permalink
3
Browse files Browse the repository at this point in the history
  • Loading branch information
ken90242 committed Jan 22, 2024
1 parent 290ad3a commit dada6b2
Show file tree
Hide file tree
Showing 16 changed files with 235 additions and 131 deletions.
1 change: 0 additions & 1 deletion curvefs/src/client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ cc_library(
"//external:brpc",
"//external:gflags",
"//external:glog",
"//external:json",
"//src/client:curve_client",
"//src/common:curve_common",
"//src/common:curve_s3_adapter",
Expand Down
55 changes: 0 additions & 55 deletions curvefs/src/client/curve_fuse_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ using ::curvefs::client::filesystem::EntryOut;
using ::curvefs::client::filesystem::FileOut;
using ::curvefs::client::filesystem::IsListWarmupXAttr;
using ::curvefs::client::filesystem::IsWarmupXAttr;
using ::curvefs::client::filesystem::IsS3ConfigXAttr;
using ::curvefs::client::filesystem::StrAttr;
using ::curvefs::client::filesystem::StrEntry;
using ::curvefs::client::filesystem::StrMode;
Expand Down Expand Up @@ -424,58 +423,6 @@ FuseClient* Client() {
return g_ClientInstance;
}


void UpdateS3Config(fuse_req_t req,
fuse_ino_t ino,
const char* name,
const char* value) {

if (g_ClientInstance->GetFsInfo()->fstype() != FSType::TYPE_S3) {
LOG(ERROR) << "updating s3 config only works for s3";
return;
}

const std::string fsName = g_ClientInstance->GetFsInfo()->fsname();
const curvefs::common::S3Info oldS3Info = g_ClientInstance->GetFsInfo()->detail().s3info();
curvefs::common::S3Info newS3Info(oldS3Info);

Json::CharReaderBuilder builder;
Json::CharReaderBuilder::strictMode(&builder.settings_);
std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
Json::Value rootNode;
JSONCPP_STRING errormsg;
FSStatusCode statusCode;
if (!reader->parse(value, value + strlen(value), &rootNode, &errormsg)) {
statusCode = FSStatusCode::INTERNAL_ERROR;
LOG(ERROR) << "Error parsing the input value ' "
<< value
<< " ': " << errormsg;
fuse_reply_err(req, FSStatusCode::INTERNAL_ERROR);
return;
}

FuseS3Client* g_S3ClientInstance = dynamic_cast<FuseS3Client*>(g_ClientInstance);
if (!g_S3ClientInstance) {
LOG(ERROR) << "Dynamic cast from FuseClient to FuseS3Client failed";
fuse_reply_err(req, FSStatusCode::INTERNAL_ERROR);
return;
}

newS3Info.set_ak(rootNode["ak"].asString());
newS3Info.set_sk(rootNode["sk"].asString());
newS3Info.set_bucketname(rootNode["bucketname"].asString());
newS3Info.set_endpoint(rootNode["endpoint"].asString());

FsInfo fsInfo;
statusCode = g_S3ClientInstance->UpdateS3Info(fsName, newS3Info, fsInfo);
if (statusCode == FSStatusCode::OK) {
g_ClientInstance->SetFsInfo(std::make_shared<FsInfo>(fsInfo));
return;
}

fuse_reply_err(req, statusCode);
}

void TriggerWarmup(fuse_req_t req,
fuse_ino_t ino,
const char* name,
Expand Down Expand Up @@ -974,8 +921,6 @@ void FuseOpSetXattr(fuse_req_t req,

if (IsWarmupXAttr(name)) {
return TriggerWarmup(req, ino, name, value, size);
} else if (IsS3ConfigXAttr(name)) {
return UpdateS3Config(req, ino, name, value);
}
rc = client->FuseOpSetXattr(req, ino, name, value, size, flags);
return fs->ReplyError(req, rc);
Expand Down
1 change: 0 additions & 1 deletion curvefs/src/client/curve_fuse_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include <json/json.h>

#include "curvefs/src/client/fuse_common.h"

Expand Down
5 changes: 0 additions & 5 deletions curvefs/src/client/filesystem/xattr.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const char XATTR_DIR_RFBYTES[] = "curve.dir.rfbytes";
const char XATTR_DIR_PREFIX[] = "curve.dir";
const char XATTR_WARMUP_OP[] = "curvefs.warmup.op";
const char XATTR_WARMUP_OP_LIST[] = "curvefs.warmup.op.list";
const char XATTR_S3_CONFIG[] = "curvefs.s3.config";

inline bool IsSpecialXAttr(const std::string& key) {
static std::map<std::string, bool> xattrs {
Expand All @@ -70,10 +69,6 @@ inline bool IsListWarmupXAttr(const std::string& key) {
return key == XATTR_WARMUP_OP_LIST;
}

inline bool IsS3ConfigXAttr(const std::string& key) {
return key == XATTR_S3_CONFIG;
}

} // namespace filesystem
} // namespace client
} // namespace curvefs
Expand Down
6 changes: 0 additions & 6 deletions curvefs/src/client/fuse_s3_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,6 @@ CURVEFS_ERROR FuseS3Client::Truncate(InodeWrapper *inode, uint64_t length) {
return s3Adaptor_->Truncate(inode, length);
}

FSStatusCode FuseS3Client::UpdateS3Info(const std::string& fsName,
const curvefs::common::S3Info& s3Info,
FsInfo& fsInfo) {
return mdsClient_->UpdateS3Info(fsName, s3Info, &fsInfo);
}

CURVEFS_ERROR FuseS3Client::FuseOpFlush(fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info *fi) {
(void)req;
Expand Down
4 changes: 0 additions & 4 deletions curvefs/src/client/fuse_s3_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ class FuseS3Client : public FuseClient {

CURVEFS_ERROR Truncate(InodeWrapper *inode, uint64_t length) override;

FSStatusCode UpdateS3Info(const std::string& fsName,
const curvefs::common::S3Info& s3Info,
FsInfo& fsInfo);

private:
bool InitKVCache(const KVClientManagerOpt &opt);

Expand Down
2 changes: 0 additions & 2 deletions curvefs/src/client/metric/client_metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ namespace metric {
struct MDSClientMetric {
static const std::string prefix;

InterfaceMetric updateS3Info;
InterfaceMetric mountFs;
InterfaceMetric umountFs;
InterfaceMetric getFsInfo;
Expand All @@ -62,7 +61,6 @@ struct MDSClientMetric {
MDSClientMetric()
: mountFs(prefix, "mountFs"),
umountFs(prefix, "umountFs"),
updateS3Info(prefix, "updateS3Info"),
getFsInfo(prefix, "getFsInfo"),
getMetaServerInfo(prefix, "getMetaServerInfo"),
getMetaServerListInCopysets(prefix, "getMetaServerListInCopysets"),
Expand Down
11 changes: 0 additions & 11 deletions curvefs/src/client/rpcclient/base_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ namespace rpcclient {
using ::curvefs::mds::space::SpaceService_Stub;


void MDSBaseClient::UpdateS3Info(const std::string& fsName,
const curvefs::common::S3Info& s3Info,
UpdateS3InfoResponse* response, brpc::Controller* cntl,
brpc::Channel* channel) {
UpdateS3InfoRequest request;
request.set_fsname(fsName);
request.mutable_s3info()->CopyFrom(s3Info);
curvefs::mds::MdsService_Stub stub(channel);
stub.UpdateS3Info(cntl, &request, response, nullptr);
}

void MDSBaseClient::MountFs(const std::string& fsName,
const Mountpoint& mountPt,
MountFsResponse* response, brpc::Controller* cntl,
Expand Down
6 changes: 0 additions & 6 deletions curvefs/src/client/rpcclient/base_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ using curvefs::mds::FsInfo;
using curvefs::mds::FsStatus;
using curvefs::mds::GetFsInfoRequest;
using curvefs::mds::GetFsInfoResponse;
using curvefs::mds::UpdateS3InfoRequest;
using curvefs::mds::UpdateS3InfoResponse;
using curvefs::mds::MountFsRequest;
using curvefs::mds::MountFsResponse;
using curvefs::mds::GetLatestTxIdRequest;
Expand Down Expand Up @@ -145,10 +143,6 @@ class MDSBaseClient {
public:
virtual ~MDSBaseClient() = default;

virtual void UpdateS3Info(const std::string& fsName, const curvefs::common::S3Info& s3Info,
UpdateS3InfoResponse* response, brpc::Controller* cntl,
brpc::Channel* channel);

virtual void MountFs(const std::string& fsName, const Mountpoint& mountPt,
MountFsResponse* response, brpc::Controller* cntl,
brpc::Channel* channel);
Expand Down
31 changes: 0 additions & 31 deletions curvefs/src/client/rpcclient/mds_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,6 @@ MdsClientImpl::Init(const ::curve::client::MetaServerOption &mdsOpt,
[&](int addrindex, uint64_t rpctimeoutMS, brpc::Channel *channel, \
brpc::Controller *cntl) -> int

FSStatusCode MdsClientImpl::UpdateS3Info(const std::string& fsName,
const curvefs::common::S3Info& s3Info, FsInfo* fsInfo) {
auto task = RPCTask {
(void)addrindex;
(void)rpctimeoutMS;
mdsClientMetric_.updateS3Info.qps.count << 1;
LatencyUpdater updater(&mdsClientMetric_.updateS3Info.latency);
UpdateS3InfoResponse response;
mdsbasecli_->UpdateS3Info(fsName, s3Info, &response, cntl, channel);
if (cntl->Failed()) {
mdsClientMetric_.updateS3Info.eps.count << 1;
LOG(WARNING) << "UpdateS3Info Failed, errorcode = " << cntl->ErrorCode()
<< ", error content:" << cntl->ErrorText()
<< ", log id = " << cntl->log_id();
return -cntl->ErrorCode();
}

FSStatusCode ret = response.statuscode();
if (ret != FSStatusCode::OK) {
LOG(WARNING) << "UpdateS3Info: fsname = " << fsName
<< ", s3Info = " << s3Info.ShortDebugString()
<< ", errcode = " << ret
<< ", errmsg = " << FSStatusCode_Name(ret);
} else if (response.has_fsinfo()) {
fsInfo->CopyFrom(response.fsinfo());
}
return ret;
};
return ReturnError(rpcexcutor_.DoRPCTask(task, mdsOpt_.mdsMaxRetryMS));
}

FSStatusCode MdsClientImpl::MountFs(const std::string& fsName,
const Mountpoint& mountPt, FsInfo* fsInfo) {
auto task = RPCTask {
Expand Down
7 changes: 0 additions & 7 deletions curvefs/src/client/rpcclient/mds_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ namespace curvefs {
namespace client {
namespace rpcclient {

using curvefs::common::S3Info;
using curvefs::mds::GetLatestTxIdRequest;
using curvefs::mds::GetLatestTxIdResponse;
using curvefs::mds::CommitTxRequest;
Expand All @@ -76,9 +75,6 @@ class MdsClient {
virtual FSStatusCode Init(const ::curve::client::MetaServerOption &mdsOpt,
MDSBaseClient *baseclient) = 0;

virtual FSStatusCode UpdateS3Info(const std::string& fsName,
const S3Info& s3Info, FsInfo* fsInfo) = 0;

virtual FSStatusCode MountFs(const std::string& fsName,
const Mountpoint& mountPt, FsInfo* fsInfo) = 0;

Expand Down Expand Up @@ -175,9 +171,6 @@ class MdsClientImpl : public MdsClient {
FSStatusCode Init(const ::curve::client::MetaServerOption &mdsOpt,
MDSBaseClient *baseclient) override;

FSStatusCode UpdateS3Info(const std::string& fsName, const S3Info& s3Info,
FsInfo* fsInfo) override;

FSStatusCode MountFs(const std::string& fsName, const Mountpoint& mountPt,
FsInfo* fsInfo) override;

Expand Down
2 changes: 2 additions & 0 deletions curvefs/src/tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ cc_library(
"copyset/*.cpp",
"delete/*.cpp",
"umount/*.cpp",
"update/*.cpp",
]),
hdrs = glob([
"*.h",
Expand All @@ -55,6 +56,7 @@ cc_library(
"copyset/*.h",
"delete/*.h",
"umount/*.h",
"update/*.h",
]),
copts = CURVE_DEFAULT_COPTS,
visibility = ["//visibility:public"],
Expand Down
2 changes: 2 additions & 0 deletions curvefs/src/tools/curvefs_tool_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const char kCreateTopologyCmd[] = "create-topology";
const char kCreateFsCmd[] = "create-fs";
// umount
const char kUmountFsCmd[] = "umount-fs";
// update-s3info
const char kUpdateS3InfoCmd[] = "update-s3info";
// delete-fs
const char kDeleteFsCmd[] = "delete-fs";
// delete-partition
Expand Down
9 changes: 7 additions & 2 deletions curvefs/src/tools/curvefs_tool_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
#include "curvefs/src/tools/create/curvefs_create_topology_tool.h"
#include "curvefs/src/tools/curvefs_tool_define.h"
#include "curvefs/src/tools/delete/curvefs_delete_fs_tool.h"
#include "curvefs/src/tools/delete/curvefs_delete_partition_tool.h"
#include "curvefs/src/tools/list/curvefs_copysetinfo_list.h"
#include "curvefs/src/tools/list/curvefs_fsinfo_list.h"
#include "curvefs/src/tools/list/curvefs_partition_list.h"
#include "curvefs/src/tools/list/curvefs_topology_list.h"
#include "curvefs/src/tools/query/curvefs_copyset_query.h"
#include "curvefs/src/tools/query/curvefs_fs_query.h"
Expand All @@ -42,10 +44,9 @@
#include "curvefs/src/tools/status/curvefs_metaserver_status.h"
#include "curvefs/src/tools/status/curvefs_status.h"
#include "curvefs/src/tools/umount/curvefs_umount_fs_tool.h"
#include "curvefs/src/tools/update/curvefs_update_s3info.h"
#include "curvefs/src/tools/usage/curvefs_metadata_usage_tool.h"
#include "curvefs/src/tools/version/curvefs_version_tool.h"
#include "curvefs/src/tools/list/curvefs_partition_list.h"
#include "curvefs/src/tools/delete/curvefs_delete_partition_tool.h"

namespace curvefs {
namespace tools {
Expand All @@ -68,6 +69,10 @@ CurvefsToolFactory::CurvefsToolFactory() {
RegisterCurvefsTool(std::string(kCreateFsCmd),
CurvefsToolCreator<create::CreateFsTool>::Create);

// update-s3info
RegisterCurvefsTool(std::string(kUpdateS3InfoCmd),
CurvefsToolCreator<update::UpdateS3InfoTool>::Create);

// usage-metadata
RegisterCurvefsTool(std::string(kMetedataUsageCmd),
CurvefsToolCreator<usage::MatedataUsageTool>::Create);
Expand Down
Loading

0 comments on commit dada6b2

Please sign in to comment.