-
Notifications
You must be signed in to change notification settings - Fork 526
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
[WIP][feat]curvefs/client: warmup manager #2234
Merged
wuhongsong
merged 1 commit into
opencurve:master
from
Cyber-SiKu:curvefs/client_warmup_manager
Feb 20, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
#include "curvefs/src/client/metric/client_metric.h" | ||
#include "curvefs/src/common/metric_utils.h" | ||
#include "curvefs/src/common/dynamic_vlog.h" | ||
#include "curvefs/src/client/warmup/warmup_manager.h" | ||
|
||
using ::curve::common::Configuration; | ||
using ::curvefs::client::CURVEFS_ERROR; | ||
|
@@ -279,25 +280,47 @@ void FuseOpGetAttr(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi) { | |
fuse_reply_attr(req, &attr, g_fuseClientOption->attrTimeOut); | ||
} | ||
|
||
int AddWarmupTask(const std::string& type, const std::string& path) { | ||
int AddWarmupTask(curvefs::client::common::WarmupType type, fuse_ino_t key, | ||
const std::string &path) { | ||
int ret = 0; | ||
switch (curvefs::client::common::GetWarmupType(type)) { | ||
case curvefs::client::common::WarmupType::kWarmupTypeList: | ||
g_ClientInstance->PutWarmTask(path); | ||
break; | ||
case curvefs::client::common::WarmupType::kWarmupTypeSingle: | ||
g_ClientInstance->FetchDentryEnqueue(path); | ||
break; | ||
default: | ||
// not support add warmup type (warmup single file/dir or filelist) | ||
LOG(ERROR) << "not support warmup type, only support single/list"; | ||
ret = ERANGE; | ||
bool result = true; | ||
switch (type) { | ||
case curvefs::client::common::WarmupType::kWarmupTypeList: | ||
result = g_ClientInstance->PutWarmFilelistTask(key); | ||
break; | ||
case curvefs::client::common::WarmupType::kWarmupTypeSingle: | ||
result = g_ClientInstance->PutWarmFileTask(key, path); | ||
break; | ||
default: | ||
// not support add warmup type (warmup single file/dir or filelist) | ||
LOG(ERROR) << "not support warmup type, only support single/list"; | ||
ret = EOPNOTSUPP; | ||
} | ||
if (!result) { | ||
ret = ERANGE; | ||
wu-hanqing marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return ret; | ||
} | ||
|
||
int Warmup(const std::string& name, const std::string& value) { | ||
void QueryWarmupTask(fuse_ino_t key, std::string *data) { | ||
curvefs::client::warmup::WarmupProgress progress; | ||
bool ret = g_ClientInstance->GetWarmupProgress(key, &progress); | ||
if (!ret) { | ||
*data = "finished"; | ||
} else { | ||
*data = std::to_string(progress.GetFinished()) + "/" + | ||
std::to_string(progress.GetTotal()); | ||
} | ||
VLOG(9) << "Warmup [" << key << "]" << *data; | ||
} | ||
|
||
int Warmup(fuse_ino_t key, const std::string& name, const std::string& value) { | ||
// warmup | ||
if (g_ClientInstance->GetFsInfo()->fstype() != FSType::TYPE_S3) { | ||
LOG(ERROR) << "warmup only support s3"; | ||
return EOPNOTSUPP; | ||
} | ||
|
||
std::vector<std::string> opTypePath; | ||
curve::common::SplitString(value, "\n", &opTypePath); | ||
if (opTypePath.size() != 3) { | ||
|
@@ -306,15 +329,17 @@ int Warmup(const std::string& name, const std::string& value) { | |
} | ||
int ret = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indent? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
fix |
||
switch (curvefs::client::common::GetWarmupOpType(opTypePath[0])) { | ||
case curvefs::client::common::WarmupOpType::kWarmupOpAdd: | ||
ret = AddWarmupTask(opTypePath[1], opTypePath[2]); | ||
if (ret != 0) { | ||
LOG(ERROR) << name << " has invalid xattr value " << value; | ||
} | ||
break; | ||
default: | ||
case curvefs::client::common::WarmupOpType::kWarmupOpAdd: | ||
ret = | ||
AddWarmupTask(curvefs::client::common::GetWarmupType(opTypePath[1]), | ||
key, opTypePath[2]); | ||
if (ret != 0) { | ||
LOG(ERROR) << name << " has invalid xattr value " << value; | ||
ret = ERANGE; | ||
} | ||
break; | ||
default: | ||
LOG(ERROR) << name << " has invalid xattr value " << value; | ||
ret = ERANGE; | ||
wu-hanqing marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return ret; | ||
} | ||
|
@@ -327,7 +352,7 @@ void FuseOpSetXattr(fuse_req_t req, fuse_ino_t ino, const char* name, | |
<< " flags " << flags; | ||
if (strcmp(name, curvefs::client::common::kCurveFsWarmupXAttr) == 0) { | ||
// warmup | ||
int code = Warmup(name, xattrValue); | ||
int code = Warmup(ino, name, xattrValue); | ||
fuse_reply_err(req, code); | ||
} else { | ||
// set xattr | ||
|
@@ -340,7 +365,18 @@ void FuseOpSetXattr(fuse_req_t req, fuse_ino_t ino, const char* name, | |
} | ||
|
||
void FuseOpGetXattr(fuse_req_t req, fuse_ino_t ino, const char *name, | ||
size_t size) { | ||
size_t size) { | ||
if (strcmp(name, curvefs::client::common::kCurveFsWarmupXAttr) == 0) { | ||
// warmup | ||
std::string data; | ||
QueryWarmupTask(ino, &data); | ||
if (size == 0) { | ||
fuse_reply_xattr(req, data.length()); | ||
} else { | ||
fuse_reply_buf(req, data.data(), data.length()); | ||
} | ||
return; | ||
} | ||
InflightGuard guard(&g_clientOpMetric->opGetXattr.inflightOpNum); | ||
LatencyUpdater updater(&g_clientOpMetric->opGetXattr.latency); | ||
std::string buf; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indenet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's ok