Skip to content

Commit

Permalink
fix trash bug: When deleting partition, delete all trace node
Browse files Browse the repository at this point in the history
Signed-off-by: UniverseParticle <[email protected]>
  • Loading branch information
UniverseParticle committed Dec 13, 2023
1 parent d25dff5 commit d6b335e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions curvefs/src/metaserver/inode_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ void InodeStorage::LoadDeletedInodes(std::map<std::string, uint64_t> * inodes) {
VLOG(6) << "load deleted over";
}

MetaStatusCode InodeStorage::RemoveAllDeletedInode() {
VLOG(6) << "remove all deleted key start with: " << table4DelInode_;
auto s = kvStorage_->HClear(table4DelInode_);
if (s.ok()) {
VLOG(6) << "remove all deleted key over";
return MetaStatusCode::OK;
}
LOG(ERROR) << "remove all deleted key failed, status = " << s.ToString();
return MetaStatusCode::STORAGE_INTERNAL_ERROR;
}

MetaStatusCode InodeStorage::Get(const Key4Inode& key, Inode* inode) {
ReadLockGuard lg(rwLock_);
std::string skey = conv_.SerializeToString(key);
Expand Down
2 changes: 2 additions & 0 deletions curvefs/src/metaserver/inode_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class InodeStorage {

MetaStatusCode RemoveDeletedInode(const Key4Inode& key);

MetaStatusCode RemoveAllDeletedInode();

void LoadDeletedInodes(std::map<std::string, uint64_t> * inodes);

/**
Expand Down
4 changes: 4 additions & 0 deletions curvefs/src/metaserver/trash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ void TrashImpl::RemoveDeletedInode(uint64_t inodeId) {
}
}

void TrashImpl::RemoveDeleteNode() {
inodeStorage_->RemoveAllDeletedInode();
}

bool TrashImpl::NeedDelete(uint64_t dtime) {
// for compatibility, if fs recycleTimeHour is 0, use old trash logic
// if fs recycleTimeHour is 0, use trash wait until expiredAfterSec
Expand Down
4 changes: 4 additions & 0 deletions curvefs/src/metaserver/trash.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class Trash {
virtual void StopScan() = 0;

virtual bool IsStop() = 0;

virtual void RemoveDeleteNode() = 0;
};

class TrashImpl : public Trash {
Expand Down Expand Up @@ -117,6 +119,8 @@ class TrashImpl : public Trash {
copysetNode_ = node;
}

void RemoveDeleteNode() override;

private:
bool NeedDelete(uint64_t dtime);

Expand Down
1 change: 1 addition & 0 deletions curvefs/src/metaserver/trash_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ void TrashManager::Remove(uint32_t partitionId) {
LOG(INFO) << "Remove partition from trash manager, partitionId = "
<< partitionId;
it->second->StopScan();
it->second->RemoveDeleteNode();
trashs_.erase(it);
} else {
LOG(INFO) << "Remove partition from trash manager, "
Expand Down

0 comments on commit d6b335e

Please sign in to comment.