Skip to content

Commit

Permalink
Use the same naming for the shadow disk
Browse files Browse the repository at this point in the history
  • Loading branch information
drbasic committed Mar 27, 2024
1 parent fa3c71d commit 9fa6a1d
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void TDiskRegistryActor::ExecuteAllocateCheckpoint(
args.CheckpointReplica.GetSourceDiskId(),
args.CheckpointReplica.GetCheckpointId(),
&result);
args.CheckpointDiskId = result.CheckpointDiskId;
args.ShadowDiskId = result.ShadowDiskId;
}

void TDiskRegistryActor::CompleteAllocateCheckpoint(
Expand All @@ -85,7 +85,7 @@ void TDiskRegistryActor::CompleteAllocateCheckpoint(
auto response =
std::make_unique<TEvDiskRegistry::TEvAllocateCheckpointResponse>(
std::move(args.Error));
response->Record.SetCheckpointDiskId(args.CheckpointDiskId);
response->Record.SetShadowDiskId(args.ShadowDiskId);

NCloud::Reply(ctx, *args.RequestInfo, std::move(response));
}
Expand Down
40 changes: 20 additions & 20 deletions cloud/blockstore/libs/storage/disk_registry/disk_registry_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ TString TCheckpointInfo::MakeUniqueId(
}

// static
TString TCheckpointInfo::MakeCheckpointDiskId(
TString TCheckpointInfo::MakeShadowDiskId(
const TString& sourceDiskId,
const TString& checkpointId)
{
return sourceDiskId + "/" + checkpointId;
return sourceDiskId + "-" + checkpointId;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -2034,12 +2034,12 @@ NProto::TError TDiskRegistryState::AllocateCheckpoint(
return MakeError(E_ARGUMENT, "Can't create checkpoint for checkpoint");
}

auto checkpointDiskId =
TCheckpointInfo::MakeCheckpointDiskId(sourceDiskId, checkpointId);
auto shadowDiskId =
TCheckpointInfo::MakeShadowDiskId(sourceDiskId, checkpointId);
auto checkpointMediaKind = GetCheckpointShadowDiskType(diskInfo.MediaKind);

TAllocateDiskParams diskParams{
checkpointDiskId,
shadowDiskId,
diskInfo.CloudId,
diskInfo.FolderId,
{}, // PlacementGroupId
Expand Down Expand Up @@ -2084,12 +2084,12 @@ NProto::TError TDiskRegistryState::AllocateCheckpoint(
return error;
}

result->CheckpointDiskId = checkpointDiskId;
result->ShadowDiskId = shadowDiskId;

TCheckpointInfo checkpointInfo{
sourceDiskId,
checkpointId,
checkpointDiskId};
shadowDiskId};
Checkpoints[checkpointInfo.UniqueId()] = std::move(checkpointInfo);
return error;
}
Expand All @@ -2109,12 +2109,12 @@ NProto::TError TDiskRegistryState::DeallocateCheckpoint(
<< sourceDiskId.Quote() << " not found");
}

const auto checkpointDiskId = checkpointInfo->CheckpointDiskId;
const auto shadowDiskId = checkpointInfo->ShadowDiskId;

Checkpoints.erase(id);

MarkDiskForCleanup(db, checkpointDiskId);
return DeallocateDisk(db, checkpointDiskId);
MarkDiskForCleanup(db, shadowDiskId);
return DeallocateDisk(db, shadowDiskId);
}

NProto::TError TDiskRegistryState::GetCheckpointDataState(
Expand All @@ -2133,12 +2133,12 @@ NProto::TError TDiskRegistryState::GetCheckpointDataState(
}

const auto* checkpointDisk =
Disks.FindPtr(checkpointInfo->CheckpointDiskId);
Disks.FindPtr(checkpointInfo->ShadowDiskId);
if (!checkpointDisk) {
return MakeError(
E_NOT_FOUND,
TStringBuilder()
<< "Disk " << checkpointInfo->CheckpointDiskId.Quote()
<< "Disk " << checkpointInfo->ShadowDiskId.Quote()
<< " not found");
}

Expand All @@ -2164,12 +2164,12 @@ NProto::TError TDiskRegistryState::SetCheckpointDataState(
<< sourceDiskId.Quote() << " not found");
}

auto* checkpointDisk = Disks.FindPtr(checkpointInfo->CheckpointDiskId);
auto* checkpointDisk = Disks.FindPtr(checkpointInfo->ShadowDiskId);
if (!checkpointDisk) {
return MakeError(
E_NOT_FOUND,
TStringBuilder()
<< "Disk " << checkpointInfo->CheckpointDiskId.Quote()
<< "Disk " << checkpointInfo->ShadowDiskId.Quote()
<< " not found");
}

Expand All @@ -2183,7 +2183,7 @@ NProto::TError TDiskRegistryState::SetCheckpointDataState(
checkpointDisk->CheckpointReplica.SetState(checkpointState);
checkpointDisk->CheckpointReplica.SetStateTs(now.MicroSeconds());
db.UpdateDisk(
BuildDiskConfig(checkpointInfo->CheckpointDiskId, *checkpointDisk));
BuildDiskConfig(checkpointInfo->ShadowDiskId, *checkpointDisk));
return MakeError(S_OK);
}

Expand Down Expand Up @@ -2786,10 +2786,10 @@ void TDiskRegistryState::DeleteCheckpointByDisk(
for (const auto& [id, checkpointInfo]: Checkpoints) {
if (checkpointInfo.SourceDiskId == diskId)
{
disksToDelete.push_back(checkpointInfo.CheckpointDiskId);
disksToDelete.push_back(checkpointInfo.ShadowDiskId);
checkpointsToDelete.push_back(id);
}
if (checkpointInfo.CheckpointDiskId == diskId)
if (checkpointInfo.ShadowDiskId == diskId)
{
checkpointsToDelete.push_back(id);
}
Expand Down Expand Up @@ -3094,10 +3094,10 @@ NProto::EDiskState TDiskRegistryState::GetDiskState(const TDiskId& diskId) const
return disk->State;
}

NProto::TError TDiskRegistryState::GetCheckpointDiskId(
NProto::TError TDiskRegistryState::GetShadowDiskId(
const TDiskId& sourceDiskId,
const TCheckpointId& checkpointId,
TDiskId* checkpointDiskId) const
TDiskId* shadowDiskId) const
{
auto id = TCheckpointInfo::MakeUniqueId(sourceDiskId, checkpointId);
const auto* checkpointInfo = Checkpoints.FindPtr(id);
Expand All @@ -3109,7 +3109,7 @@ NProto::TError TDiskRegistryState::GetCheckpointDiskId(
<< sourceDiskId.Quote() << " not found");
}

*checkpointDiskId = checkpointInfo->CheckpointDiskId;
*shadowDiskId = checkpointInfo->ShadowDiskId;
return MakeError(S_OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,20 @@ struct TCheckpointInfo
{
TString SourceDiskId;
TString CheckpointId;
TString CheckpointDiskId;
TString ShadowDiskId;

TCheckpointInfo() = default;

TCheckpointInfo(
TString sourceDiskId,
TString checkpointId,
TString checkpointDiskId)
TString shadowDiskId)
: SourceDiskId(std::move(sourceDiskId))
, CheckpointId(std::move(checkpointId))
, CheckpointDiskId(std::move(checkpointDiskId))
, ShadowDiskId(std::move(shadowDiskId))
{}

static TString MakeCheckpointDiskId(
static TString MakeShadowDiskId(
const TString& sourceDiskId,
const TString& checkpointId);

Expand Down Expand Up @@ -400,7 +400,7 @@ class TDiskRegistryState

struct TAllocateCheckpointResult: public TAllocateDiskResult
{
TString CheckpointDiskId;
TString ShadowDiskId;
};

NProto::TError AllocateDisk(
Expand Down Expand Up @@ -443,10 +443,10 @@ class TDiskRegistryState

NProto::TError GetDiskInfo(const TDiskId& diskId, TDiskInfo& diskInfo) const;
NProto::EDiskState GetDiskState(const TDiskId& diskId) const;
NProto::TError GetCheckpointDiskId(
NProto::TError GetShadowDiskId(
const TDiskId& sourceDiskId,
const TCheckpointId& checkpointId,
TDiskId* checkpointDiskId) const;
TDiskId* shadowDiskId) const;

bool FilterDevicesAtUnavailableAgents(TDiskInfo& diskInfo) const;

Expand Down
Loading

0 comments on commit 9fa6a1d

Please sign in to comment.