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

curvefs/metaserver: skip find dentry when loading from snapshot #1460

Merged
merged 1 commit into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions curvefs/src/metaserver/dentry_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@ void DentryManager::Log4Code(const std::string& request, MetaStatusCode rc) {
}
}

MetaStatusCode DentryManager::CreateDentry(const Dentry& dentry) {
MetaStatusCode DentryManager::CreateDentry(const Dentry& dentry,
bool isLoadding) {
Log4Dentry("CreateDentry", dentry);
MetaStatusCode rc;
// invoke only from snapshot loading
if (dentry.flag() & DentryFlag::TRANSACTION_PREPARE_FLAG) {
rc = dentryStorage_->HandleTx(DentryStorage::TX_OP_TYPE::PREPARE,
dentry);
} else {
rc = dentryStorage_->Insert(dentry);
rc = dentryStorage_->Insert(dentry, isLoadding);
}
Log4Code("CreateDentry", rc);
return rc;
Expand Down
2 changes: 1 addition & 1 deletion curvefs/src/metaserver/dentry_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DentryManager {
DentryManager(std::shared_ptr<DentryStorage> dentryStorage,
std::shared_ptr<TxManager> txManger);

MetaStatusCode CreateDentry(const Dentry& dentry);
MetaStatusCode CreateDentry(const Dentry& dentry, bool isLoadding = false);

MetaStatusCode DeleteDentry(const Dentry& dentry);

Expand Down
20 changes: 11 additions & 9 deletions curvefs/src/metaserver/dentry_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,20 @@ MetaStatusCode DentryStorage::Find(const Dentry& in,
return rc;
}

MetaStatusCode DentryStorage::Insert(const Dentry& dentry) {
MetaStatusCode DentryStorage::Insert(const Dentry& dentry, bool isLoadding) {
WriteLockGuard w(rwLock_);

Dentry out;
MetaStatusCode rc = Find(dentry, &out, true);
if (rc == MetaStatusCode::OK) {
if (IsSameDentry(out, dentry)) {
return MetaStatusCode::IDEMPOTENCE_OK;
if (!isLoadding) {
Dentry out;
MetaStatusCode rc = Find(dentry, &out, true);
if (rc == MetaStatusCode::OK) {
if (IsSameDentry(out, dentry)) {
return MetaStatusCode::IDEMPOTENCE_OK;
}
return MetaStatusCode::DENTRY_EXIST;
} else if (rc != MetaStatusCode::NOT_FOUND) {
return MetaStatusCode::STORAGE_INTERNAL_ERROR;
}
return MetaStatusCode::DENTRY_EXIST;
} else if (rc != MetaStatusCode::NOT_FOUND) {
return MetaStatusCode::STORAGE_INTERNAL_ERROR;
}

// MetaStatusCode::NOT_FOUND
Expand Down
2 changes: 1 addition & 1 deletion curvefs/src/metaserver/dentry_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DentryStorage {
DentryStorage(std::shared_ptr<KVStorage> kvStorage,
const std::string& tablename);

MetaStatusCode Insert(const Dentry& dentry);
MetaStatusCode Insert(const Dentry& dentry, bool isLoadding = false);

MetaStatusCode Delete(const Dentry& dentry);

Expand Down
2 changes: 1 addition & 1 deletion curvefs/src/metaserver/partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ MetaStatusCode Partition::CreateDentry(const Dentry& dentry, bool isLoadding) {
if (GetStatus() == PartitionStatus::DELETING) {
return MetaStatusCode::PARTITION_DELETING;
}
MetaStatusCode ret = dentryManager_->CreateDentry(dentry);
MetaStatusCode ret = dentryManager_->CreateDentry(dentry, isLoadding);
if (MetaStatusCode::OK == ret) {
if (!isLoadding) {
return inodeManager_->UpdateInodeWhenCreateOrRemoveSubNode(
Expand Down