curvefs/metaserver: fix trash bugs#2948
Conversation
1e01fc6 to
f6cd9d5
Compare
|
cicheck |
f6cd9d5 to
914faf4
Compare
914faf4 to
21bb6a3
Compare
| * @param[in] logIndex: the index of raft log | ||
| * @return | ||
| */ | ||
| MetaStatusCode UpdateDeletingKey(const Inode& inode, int64_t logIndex); |
There was a problem hiding this comment.
UpdateDeletingKey to AddDeletedInode maybe more clearer
| */ | ||
| MetaStatusCode UpdateDeletingKey(const Inode& inode, int64_t logIndex); | ||
|
|
||
| MetaStatusCode ClearDelKey(const Key4Inode& key); |
| return kvStorage_->Open(); | ||
| } | ||
|
|
||
| void MetaStoreImpl::LoadDeletedInodes() { |
There was a problem hiding this comment.
LoadDeletedInodes is the responsibility of InodeManager, Each partition has one InodeManager and InodeStorage, you can load deleted inodes with InodeManager and add to trash_ in InodeManager by pass and the deleted inode loaded are all belong to this partition and trash.
| LOG(ERROR) << "Begin transaction failed"; | ||
| return MetaStatusCode::STORAGE_INTERNAL_ERROR; | ||
| } | ||
| auto rc = txn->HSet(table4DelInode_, skey , inode); |
There was a problem hiding this comment.
The value does not need to be the entire inode, dtime is enough
| } | ||
|
|
||
| void TrashImpl::Add(uint64_t inodeId, uint64_t dtime) { | ||
| void TrashImpl::Add(uint64_t inodeId, uint64_t dtime, bool deleted) { |
There was a problem hiding this comment.
tell reboot or not
| LockGuard lg(itemsMutex_); | ||
| trashItems_.erase(inodeId); | ||
| auto it = std::find(trashItems_.begin(), trashItems_.end(), item); | ||
| if (it != trashItems_.end()) { |
There was a problem hiding this comment.
The remove of rocksdb data can do here also.
| } | ||
|
|
||
| if (needAddTrash) { | ||
| inodeStorage_->UpdateDeletingKey(old, logIndex); |
There was a problem hiding this comment.
add and delete op all deal in trash is better.
21bb6a3 to
57748b1
Compare
1eb1450 to
d635cf6
Compare
610f6ab to
288bc9c
Compare
288bc9c to
2700f65
Compare
|
cicheck |
0304c53 to
3b5db6a
Compare
|
cicheck |
3b5db6a to
e304ccd
Compare
|
|
||
| namespace storage { | ||
|
|
||
| #define DELETEPREFIXINKV "deleting:" |
| return absl::StrCat(type, kDelimiter, absl::string_view(buf, sizeof(buf))); | ||
| } | ||
|
|
||
| std::string NameGenerator::FormatDel(KEY_TYPE type, uint32_t partitionId) { |
|
|
||
| NameGenerator::NameGenerator(uint32_t partitionId) | ||
| : tableName4Inode_(Format(kTypeInode, partitionId)), | ||
| tableName4DelInode_(FormatDel(kTypeInode, partitionId)), |
There was a problem hiding this comment.
Add a new type like 'kTypeDelInode'
|
cicheck |
e304ccd to
cee94ad
Compare
|
cicheck |
cee94ad to
b36a0aa
Compare
|
cicheck |
b36a0aa to
bf8a57d
Compare
|
cicheck |
2 similar comments
|
cicheck |
|
cicheck |
bf8a57d to
e56d6a6
Compare
|
cicheck |
| { | ||
| LockGuard lgItems(itemsMutex_); | ||
| trashItems_.insert(temp.begin(), temp.end()); | ||
| trashItems_.swap(temp); |
There was a problem hiding this comment.
Can not swap, the trashItem already has some new item
| } | ||
|
|
||
| std::unordered_map<uint64_t, uint64_t> temp; | ||
| std::map<uint64_t, uint64_t> temp; |
There was a problem hiding this comment.
unordered_map is space friendly here
| } | ||
| LockGuard lg(itemsMutex_); | ||
| trashItems_.erase(inodeId); | ||
| auto it = trashItems_.find(inodeId); |
There was a problem hiding this comment.
don't need find here and can erase directly
| << ", partitionId = " << partitionId_ | ||
| trashItems_.emplace(inodeId, dtime); | ||
|
|
||
| VLOG(6) << "Add trash item success" |
There was a problem hiding this comment.
Don't remove fsId and partitionId, inodeId can be same in different fs
| std::map<std::string, uint64_t>* item, const std::string prefix) { | ||
| std::string sprefix = absl::StrCat("0", ":", prefix); | ||
| VLOG(3) << "load deleted inodes from: " << options_.dataDir | ||
| << ", " << sprefix << ", " << prefix; |
| } | ||
| delete it; | ||
| VLOG(3) << "load deleted inodes end, size is: " << item->size() | ||
| << ", " << counts << ", " << options_.dataDir; |
| void InodeStorage::LoadDeletedInodes(std::map<std::string, uint64_t> * inodes) { | ||
| VLOG(6) << "load deleted key start with: " << table4DelInode_; | ||
| kvStorage_->GetPrefix(inodes, table4DelInode_); | ||
| VLOG(6) << "oad deleted over"; |
| inodeStorage_->LoadDeletedInodes(&items); | ||
| VLOG(3) << "build trash items size: " << items.size(); | ||
| std::vector<std::string> names; | ||
| for (auto iter : items) { |
| LOG(ERROR) << "DeleteInodeAndData fail, fsId = " << fsId_ | ||
| << ", inodeId = " << it->first | ||
| << ", ret = " << MetaStatusCode_Name(ret); | ||
| RemoveDeletedInode(it->first); |
There was a problem hiding this comment.
RemoveDeleteInode in func Remove
| } | ||
| } | ||
|
|
||
| void TrashImpl::RemoveDeletedInode(uint64_t inodeId) { |
There was a problem hiding this comment.
Maybe void is not good. Some warning log may need if Remove fail.
e56d6a6 to
941d39b
Compare
|
cicheck |
3 similar comments
|
cicheck |
|
cicheck |
|
cicheck |
941d39b to
54430cf
Compare
|
cicheck |
1 similar comment
|
cicheck |
54430cf to
d86bba3
Compare
|
cicheck |
What problem does this PR solve?
Issue Number: #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