-
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
[feat]curvefs: client: optimize rmdir #2516
base: master
Are you sure you want to change the base?
Conversation
Currently, the statistical information recorded in xattr is updated to the metaserver asynchronously. In the scenario where the client exits abnormally, the recorded information may be inaccurate. It is not suitable to use this in the scenario where the deletion directory is judged to be empty and has strong consistency requirements. |
Yes, I forget the xattr is updated asynchronously, But the dentryCacheManager method Listdentry is too heavy for rmdir, maybe we should add one method IsEmpty which call Listdentry once? |
d0a06f8
to
8d9f5e1
Compare
cicheck |
Hi @201341, thank you for your contribute, there is a bit complex for |
Got it, Looking forward to the new solution. |
d40f03f
to
6b03012
Compare
cicheck |
@Wine93 The code is ok. |
MetaStatusCode ret = MetaStatusCode::OK; | ||
dentryList->clear(); | ||
ret = metaClient_->ListDentry(fsId_, parent, marker, 1, false, | ||
dentryList); |
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.
indentation
@@ -156,5 +156,26 @@ CURVEFS_ERROR DentryCacheManagerImpl::ListDentry(uint64_t parent, | |||
return CURVEFS_ERROR::OK; | |||
} | |||
|
|||
CURVEFS_ERROR DentryCacheManagerImpl::CheckDirEmpty(uint64_t parent, | |||
std::list<Dentry> *dentryList) { |
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.
indentation
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.
the second line is larger than 80 characters?
@@ -156,5 +156,26 @@ CURVEFS_ERROR DentryCacheManagerImpl::ListDentry(uint64_t parent, | |||
return CURVEFS_ERROR::OK; | |||
} | |||
|
|||
CURVEFS_ERROR DentryCacheManagerImpl::CheckDirEmpty(uint64_t parent, | |||
std::list<Dentry> *dentryList) { | |||
std::string marker = ""; |
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.
The initial value is empty string already.
ret = metaClient_->ListDentry(fsId_, parent, marker, 1, false, | ||
dentryList); | ||
VLOG(6) << "ListDentry fsId = " << fsId_ << ", parent = " << parent | ||
<< ", last = " << marker << ", count = 1 " |
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.
Maybe you should trim the trailing whitespace:
<< ", last = " << marker << ", count = 1"
CURVEFS_ERROR RenameOperator::CheckOverwrite() { | ||
if (dstDentry_.flag() & DentryFlag::TYPE_FILE_FLAG) { | ||
return CURVEFS_ERROR::OK; | ||
} | ||
|
||
std::list<Dentry> dentrys; | ||
auto rc = dentryManager_->ListDentry(dstDentry_.inodeid(), &dentrys, 1); | ||
auto rc = dentryManager_->CheckDirEmpty(dstDentry_.inodeid(), |
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.
The purpose we add the CheckDirEmpty
is to check whether the directory is empty, it no need to list entries, so the behavior maybe like:
bool yes;
auto rc = dentryManager_->CheckDirEmpty(ino, &yes);
if (rc != CURVEFS_ERROR::OK) {
// handler error
} else if (yes) {
// do something for empty directory
} else {
// do something for non-empty directory
}
Maybe you should add a RPC to do it, the checker should handled in metaserver and it should only return yes
or no
.
cc @SeanHai
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.
OK, Got it.
6e77268
to
8f918e6
Compare
Signed-off-by: swj <1186093704@qq.com>
cicheck |
1 similar comment
cicheck |
@201341 please resolve the conflict. |
What problem does this PR solve?
when rmdir, it uses ListDentry to check if dir is empty, which cost to mush.
Issue Number: #xxx
Problem Summary:
What is changed and how it works?
What's Changed:
How it Works:
Side effects(Breaking backward compatibility? Performance regression?):
Check List