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

wip_enablesumindir #2310

Closed
wants to merge 1 commit into from
Closed

Conversation

bit-dance
Copy link
Contributor

@bit-dance bit-dance commented Mar 14, 2023

What problem does this PR solve?

When the fs mount is mounted multiple times with different enableSumInDir switches, the xattr information recorded in the metadata will be inaccurate
Issue Number: #2094

Problem Summary:
use CalAllLayerSumInfo func to update attr's mutable_xattr() and then use this summary info to update this inode's xattr() .

What is changed and how it works?

What's Changed:
fuse_client.cpp xattr_manager.h xattr_manager.cpp
How it Works:
just like above .
Side effects(Breaking backward compatibility? Performance regression?):
slow down the fs init time.

Check List

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

@@ -205,6 +205,9 @@ CURVEFS_ERROR FuseClient::FuseOpInit(void *userdata,

LOG(INFO) << "Mount " << fsName << " on " << mountpoint_.ShortDebugString()
<< " success!" << " enableSumInDir = " << enableSumInDir_;
if (enableSumInDir_) {
xattrManager_->RefreshAllXAttr();
}

fsMetric_ = std::make_shared<FSMetric>(fsName);

Copy link

Choose a reason for hiding this comment

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

,

  1. It looks like the code is trying to initialize a fuse client and refresh all xattrs if the enableSumInDir_ flag is set.

  2. There are no bugs in the code, but one improvement could be adding a log statement to indicate when the xattrManager_->RefreshAllXAttr() is called.

  3. The code should also check if enableSumInDir_ is set before calling the xattrManager_->RefreshAllXAttr() method.

  4. Another improvement could be to add a try-catch block around the xattrManager_->RefreshAllXAttr() call to handle any exceptions that might be thrown.

virtual CURVEFS_ERROR FuseOpWrite(fuse_req_t req, fuse_ino_t ino,
const char* buf, size_t size, off_t off,
struct fuse_file_info* fi,
size_t* wSize) = 0;

virtual CURVEFS_ERROR FuseOpRead(fuse_req_t req, fuse_ino_t ino,
size_t size, off_t off,
Copy link

Choose a reason for hiding this comment

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

code review

  1. The code patch looks correct and valid, without any syntax errors.
  2. It is always good to add comments above the code snippets to provide more information about the changes being made.
  3. Since the code patch is changing the signature of a virtual method, it is important to check that all derived classes override this method with the new signature.
  4. The code patch should be tested for any regressions before applying it.


return ret;
}

void XattrManager::ConcurrentGetInodeXattr(
std::stack<uint64_t> *iStack,
std::mutex *stackMutex,
Copy link

Choose a reason for hiding this comment

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

with a brief overview of the code patch. This code patch is used to refresh all xAttributes of an inode. The main logic is that a thread pool is created and each thread is responsible for getting a list of dentries and inode attributes associated with them, and then refreshing the xAttributes of the inode.

Now let's start with a detailed code review:

  1. The thread pool should be created in the constructor, so that you don't have to create a thread every time you call RefreshAllXAttr.

  2. You need to guard the stackMutex before calling ConcurrentListDentry.

  3. You should check the return value of Atomic ret, otherwise it may cause error.

  4. You should check the return value of ConcurrentListDentry and BatchGetInodeAttr.

  5. You should check the return value of AddUllStringToFirst().

  6. We should use std::lock_guard to make sure the lock is released at the end of the scope.

  7. You should check the return value of ShipToFlush().

I hope this review helps you. If there are any questions, please don't hesitate to let me know.

std::mutex *stackMutex,
Atomic<uint32_t> *inflightNum,
Atomic<bool> *ret);

void ConcurrentGetInodeXattr(
std::stack<uint64_t> *iStack,
std::mutex *stackMutex,
Copy link

Choose a reason for hiding this comment

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

the code review:

  1. The new functions RefreshAllXAttr() and RefreshInodeXAttr() look promising, but the code patch could be improved by adding a few more comments to explain the purpose and functionality of these functions.

  2. Both ConcurrentRefreshInodeXattr() and ConcurrentGetInodeXattr() should have input validation. In other words, all the passed parameters should be properly tested to ensure that they are not NULL and that they contain valid data before being used in the functions.

  3. Both functions should also use exception handling to catch any possible errors or exceptions that may occur during their execution.

  4. Lastly, it may be helpful to add logging statements at appropriate places to help with debugging and troubleshooting if any issues arise in the future.

@bit-dance bit-dance closed this Mar 18, 2023
@bit-dance bit-dance deleted the fix_enableSum branch May 19, 2023 07:52
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.

1 participant