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

[feat]curvefs: client: optimize rmdir #2516

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

201341
Copy link
Contributor

@201341 201341 commented Jun 7, 2023

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

  • Relevant documentation/comments is changed or added
  • I acknowledge that all my contributions will be made under the project's license

@201341 201341 changed the title [feat]curvefs: client: optimal rmdir [feat]curvefs: client: optimize rmdir Jun 7, 2023
@SeanHai
Copy link
Contributor

SeanHai commented Jun 7, 2023

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.

@201341
Copy link
Contributor Author

201341 commented Jun 7, 2023

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?

@201341 201341 changed the title [feat]curvefs: client: optimize rmdir [feat]curvefs: client: optimize rmdir/readdir Jun 8, 2023
@201341 201341 force-pushed the swj/opt-rmdir branch 11 times, most recently from d0a06f8 to 8d9f5e1 Compare June 13, 2023 15:34
@201341
Copy link
Contributor Author

201341 commented Jun 14, 2023

cicheck

@201341 201341 requested review from Wine93 and ilixiaocui June 14, 2023 04:21
@wuhongsong
Copy link
Contributor

@Wine93

@Wine93
Copy link
Contributor

Wine93 commented Jun 20, 2023

Hi @201341, thank you for your contribute, there is a bit complex for readdir(), we cannot directly limit the entries of the directory cache even if there are many entries due to the performance considerations, but it's a pretty good solution for rmdir(), you can add a RPC which maybe named CheckDirEmpty() to check whether the directory is empty, and we also have a solution to solve how to read the large directory, we will publish the new version in the near future.
Thank you for your contribute again, it helps us to improve the performance of rmdir(), you can beautify the code and requested review from us again :)

@201341
Copy link
Contributor Author

201341 commented Jun 20, 2023

Hi @201341, thank you for your contribute, there is a bit complex for readdir(), we cannot directly limit the entries of the directory cache even if there are many entries due to the performance considerations, but it's a pretty good solution for rmdir(), you can add a RPC which maybe named CheckDirEmpty() to check wether the directory is empty, and we also have a solution to solve how to read the large directory, we will publish the new version in the near future. Thank you for your contribute again, it helps us to improve the performance of rmdir(), you can beautify the code and requested review from us agin :)

Got it, Looking forward to the new solution.

@201341 201341 changed the title [feat]curvefs: client: optimize rmdir/readdir [feat]curvefs: client: optimize rmdir Jun 20, 2023
@201341 201341 force-pushed the swj/opt-rmdir branch 3 times, most recently from d40f03f to 6b03012 Compare June 25, 2023 06:47
@201341
Copy link
Contributor Author

201341 commented Jun 25, 2023

cicheck

@201341
Copy link
Contributor Author

201341 commented Jun 26, 2023

@Wine93 The code is ok.

MetaStatusCode ret = MetaStatusCode::OK;
dentryList->clear();
ret = metaClient_->ListDentry(fsId_, parent, marker, 1, false,
dentryList);
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Copy link
Contributor Author

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 = "";
Copy link
Contributor

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 "
Copy link
Contributor

@Wine93 Wine93 Jun 30, 2023

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(),
Copy link
Contributor

@Wine93 Wine93 Jun 30, 2023

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, Got it.

@201341 201341 force-pushed the swj/opt-rmdir branch 7 times, most recently from 6e77268 to 8f918e6 Compare July 18, 2023 09:11
Signed-off-by: swj <1186093704@qq.com>
@201341
Copy link
Contributor Author

201341 commented Jul 19, 2023

cicheck

1 similar comment
@201341
Copy link
Contributor Author

201341 commented Jul 20, 2023

cicheck

@caoxianfei1 caoxianfei1 requested a review from SeanHai July 25, 2023 02:04
@wuhongsong
Copy link
Contributor

#2680

@Cyber-SiKu
Copy link
Contributor

@201341 please resolve the conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants