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/client: fix update nlink error #1901

Merged
merged 1 commit into from
Sep 8, 2022

Conversation

SeanHai
Copy link
Contributor

@SeanHai SeanHai commented Sep 7, 2022

Signed-off-by: wanghai01 seanhaizi@163.com

What problem does this PR solve?

fix the update inode nlink logic, the previous logic will update nlink incorrect at:
未命名绘图

The fixed logic is every update of nlink to metaserver should refresh from metaserver first.

Issue Number: #1904

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

@SeanHai
Copy link
Contributor Author

SeanHai commented Sep 7, 2022

recheck

@@ -52,13 +52,11 @@ constexpr int kAccessTime = 1 << 0;
constexpr int kChangeTime = 1 << 1;
constexpr int kModifyTime = 1 << 2;

#define REFRESH_NLINK_IF_NEED \
#define REFRESH_NLINK \
Copy link
Contributor

Choose a reason for hiding this comment

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

you can move this macro to source file, the header file doesn't directly use it.

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

CURVEFS_ERROR UpdateParentInodeMCTimeAndInvalidNlink(
fuse_ino_t parent, FsFileType type);
CURVEFS_ERROR UpdateParentMCTimeAndNlink(
fuse_ino_t parent, FsFileType type, int32_t nlink);
Copy link
Contributor

Choose a reason for hiding this comment

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

As for the third argument nlink, I only saw you passed either 1 or -1, does other values exist, like 2/3 or -2/-3? And if not, a proper way is using an enum to represent 1 or -1.

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

@@ -580,7 +580,7 @@ CURVEFS_ERROR FuseClient::UpdateParentInodeMCTimeAndInvalidNlink(
parentInodeWrapper->UpdateTimestampLocked(kModifyTime | kChangeTime);

if (FsFileType::TYPE_DIRECTORY == type) {
parentInodeWrapper->InvalidateNlink();
parentInodeWrapper->UpdateNlinkLocked(nlink);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a bug here? we changed the timestamp and nlink of an inode, but we don't call ShipToFlush which means the updated fields don't persist to metaserver?

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 update of nlink is done in metaserver and client at same time, the nlink in client is just to show, it need refresh first from metaserver when update to metaserver.

The update of time will set inode to dirty and flush backgroud

}

void UpdateNlinkLocked(uint32_t nlink) {
inode_.set_nlink(inode_.nlink() + nlink);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we mark inode dirty and also set corresponding field in dirtyAttr?

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 update of nlink is done in metaserver and client at same time, the nlink in client is just to show, it need refresh first from metaserver when update to metaserver.

Signed-off-by: wanghai01 <seanhaizi@163.com>
Copy link
Contributor

@Wine93 Wine93 left a comment

Choose a reason for hiding this comment

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

LGTM!

@SeanHai SeanHai merged commit bab48e0 into opencurve:master Sep 8, 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.

3 participants