-
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
wip_enablesumindir #2310
wip_enablesumindir #2310
Conversation
@@ -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); | |||
|
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.
,
-
It looks like the code is trying to initialize a fuse client and refresh all xattrs if the enableSumInDir_ flag is set.
-
There are no bugs in the code, but one improvement could be adding a log statement to indicate when the xattrManager_->RefreshAllXAttr() is called.
-
The code should also check if enableSumInDir_ is set before calling the xattrManager_->RefreshAllXAttr() method.
-
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, |
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.
code review
- The code patch looks correct and valid, without any syntax errors.
- It is always good to add comments above the code snippets to provide more information about the changes being made.
- 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.
- 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, |
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.
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:
-
The thread pool should be created in the constructor, so that you don't have to create a thread every time you call RefreshAllXAttr.
-
You need to guard the stackMutex before calling ConcurrentListDentry.
-
You should check the return value of Atomic ret, otherwise it may cause error.
-
You should check the return value of ConcurrentListDentry and BatchGetInodeAttr.
-
You should check the return value of AddUllStringToFirst().
-
We should use std::lock_guard to make sure the lock is released at the end of the scope.
-
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, |
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 code review:
-
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.
-
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.
-
Both functions should also use exception handling to catch any possible errors or exceptions that may occur during their execution.
-
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.
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