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: xattr summary info support hard link #1185

Merged
merged 1 commit into from
Apr 2, 2022

Conversation

SeanHai
Copy link
Contributor

@SeanHai SeanHai commented Mar 16, 2022

What problem does this PR solve?

Issue Number: close #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

@@ -227,6 +227,9 @@ CURVEFS_ERROR InodeWrapper::LinkLocked() {
inode_.set_ctime_ns(now.tv_nsec);
inode_.set_mtime(now.tv_sec);
inode_.set_mtime_ns(now.tv_nsec);
if (inode_.type() != FsFileType::TYPE_DIRECTORY && parent != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do not record parent for FsFileType::TYPE_DIRECTORY ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why do not record parent for FsFileType::TYPE_DIRECTORY ?

To maintain unity and the parent maybe used later. Here only link and unlink need deal with spectially.

param.mode = request->mode();
param.type = request->type();
param.parent = request->parent();
param.rdev = request->rdev();
Copy link
Contributor

Choose a reason for hiding this comment

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

init param.symlink

Copy link
Contributor Author

Choose a reason for hiding this comment

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

init param.symlink

Inited in line468

Copy link
Contributor

@cw123 cw123 Mar 30, 2022

Choose a reason for hiding this comment

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

if param.type != FsFileType::TYPE_SYM_LINK

not inited

fixed

param.mode = request->mode();
param.length = 0;
param.type = FsFileType::TYPE_DIRECTORY;
param.rdev = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

param.parent not inited, it may any num in release mode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

param.parent not inited, it may any num in release mode

fixed.

}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

why UnLinkLocked handle parent , but DecreaseNLink does not handle parent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why UnLinkLocked handle parent , but DecreaseNLink does not handle parent?

The operation 'UnLinkLocked' is used for current Inode if nlink is decreased to 0 will be deleted. But 'DecreaseNLink' is only used to decrease parentInode nlink have no inode delete.

@@ -271,10 +283,29 @@ void RenameOperator::UnlinkOldInode() {
return;
}

auto rc = UnLinkInode(oldInodeId_);
auto rc = UnLinkInode(oldInodeId_, newParentId_);
Copy link
Contributor

Choose a reason for hiding this comment

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

why some unlinkinode only have one param, some have two params

Copy link
Contributor Author

@SeanHai SeanHai Mar 31, 2022

Choose a reason for hiding this comment

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

why some unlinkinode only have one param, some have two params

The UnLinkInode with one param(actual two params, with one default param) used in 'UnlinkSrcParentInode' only decrease nlink of srcParentInode and will not occured delete.
The UnLinkInode with two params used to decrease nlink of current inode maybe be deleted when nlink decreased to 0.

param.mode = request->mode();
param.type = request->type();
param.parent = request->parent();
param.rdev = request->rdev();
Copy link
Contributor

@cw123 cw123 Mar 30, 2022

Choose a reason for hiding this comment

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

if param.type != FsFileType::TYPE_SYM_LINK

not inited

fixed

if (trc == CURVEFS_ERROR::OK) {
std::shared_ptr<InodeWrapper> inodeWrapper;
trc = inodeManager_->GetInode(oldInodeId_, inodeWrapper);
if (trc == CURVEFS_ERROR::OK) {
Copy link
Member

Choose a reason for hiding this comment

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

split it into anther Operator will be better

Copy link
Contributor

Choose a reason for hiding this comment

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

agree! maybe add an operator after Precheck is better, like:

CURVEFS_ERROR RenameOperator::Check4Something() {
    if (oldInodeId_ == 0) {
        return CURVEFS_ERROR::OK;
    }

    // do something like record `oldInodeSize_` and `oldInodeType_`
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

@@ -248,6 +236,8 @@ MetaStatusCode InodeManager::UpdateInode(const UpdateInodeRequest &request) {
UPDATE_INODE(gid)
UPDATE_INODE(mode)

*(old->mutable_parent()) = request.parent();
Copy link
Member

Choose a reason for hiding this comment

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

if (request.has_parent())?

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 parent is a 'repeated' type has no 'has_*' and the parent field is Inherent property of inode like uid,gid,mode. So here can check parent_size(), but feel unnecessary.

void UpdateCache();

void GetOldInode(uint64_t *oldInodeId, int64_t *oldInodeSize,
FsFileType *oldInodeType) {
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.

fixed

std::to_string(inodeWrapper->GetLength())});
// return ok even update xattr failed
CURVEFS_ERROR trc = CURVEFS_ERROR::OK;
if (enableSumInDir_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe move the below logic into one funciton is beeter, it's too much.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@SeanHai SeanHai force-pushed the addparent branch 2 times, most recently from fd788fd to 44c4e60 Compare April 2, 2022 03:31
@SeanHai
Copy link
Contributor Author

SeanHai commented Apr 2, 2022

recheck

@SeanHai SeanHai merged commit 598eb25 into opencurve:master Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants