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

Dir lock #885

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Dir lock #885

wants to merge 29 commits into from

Conversation

yvxiang
Copy link
Collaborator

@yvxiang yvxiang commented Mar 21, 2017

(#527)

yangce added 29 commits March 10, 2017 13:28
StatusCode status = namespace_->GetDirLockStatus(path);
std::string parent_path(path, 0, path.find_last_of("/"));
FileInfo info;
if (!namespace_->CheckDirLockPermission(parent_path, request->uuid(), &info)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这info是干啥的啊,而且为啥是在外面剥掉一层才传进去。。

}
*info = root_path_;
return true;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

如果path不是/,就不检查根目录的状态了?

if (status == kDirUnlock) {
namespace_->SetDirLockStatus(path, kDirLocked, request->uuid());
namespace_->SetDirLockStatus(path, kDirLocked, request->uuid(), &log);
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个if的嵌套我没太懂啊。。。为啥不能是if(locked)() else if (cleaning) else if (unlock)?

status = kOK;
need_log_remote = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

log.entries_size()是不是就行了。而且LogRemote检查是不是更好

if (block_mapping_manager_->CheckBlocksClosed(blocks)) {
NameServerLog log;
if (request->force_unlock()) {
namespace_->SetDirLockStatus(path, kDirUnlock, "", &log);
Copy link
Collaborator

Choose a reason for hiding this comment

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

这块价格注释解释下为啥有这么个选项吧

FileInfo info;
for (size_t i = 0; i < paths.size() - 1; i++) {
EncodingStoreKey(entry_id, paths[i], &file_key);
bool r = GetFromStore(file_key, &info);
Copy link
Collaborator

Choose a reason for hiding this comment

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

这r是干嘛的。。。

entry_id = info.entry_id();
}
EncodingStoreKey(entry_id, paths[paths.size() - 1], &file_key);
bool r = GetFromStore(file_key, &info);
Copy link
Collaborator

Choose a reason for hiding this comment

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

还有这个r。。。

if (!LookUp(path, &info)) {
return;
}
if (GetFileType(info.type()) == kDefault) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

话说kDefault这个很奇特啊。。为啥一个file的type是default==

leveldb::Iterator* it = db_->NewIterator(leveldb::ReadOptions());
for (it->Seek(key_start); it->Valid(); it->Next()) {
leveldb::Slice key = it->key();
if (key.compare(key_end)>=0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

少空格

return true;
}

bool NameSpace::CheckDirLockPermission(const FileInfo& file_info,
Copy link
Collaborator

Choose a reason for hiding this comment

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

这和上面那个啥关系啊。。为啥不是互相调用?

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.

None yet

2 participants