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

Issue 2725: add direct sending Acquire/ReleaseDevices from Volume to DA #2911

Merged
merged 10 commits into from
Jan 28, 2025
3 changes: 3 additions & 0 deletions cloud/blockstore/config/storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1107,4 +1107,7 @@ message TStorageServiceConfig
// When enabled, tag "use-intermediate-write-buffer" will be added
// after scrubbing finds a mismatch
optional bool AutomaticallyEnableBufferCopyingAfterChecksumMismatch = 403;

// Enabling direct sending AcquireDevices to disk agent.
optional bool NonReplicatedVolumeDirectAcquireEnabled = 404;
}
1 change: 1 addition & 0 deletions cloud/blockstore/libs/storage/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ TDuration MSeconds(ui32 value)
xxx(VolumeProxyCacheRetryDuration, TDuration, Seconds(15) )\
\
xxx(UseDirectCopyRange, bool, false )\
xxx(NonReplicatedVolumeDirectAcquireEnabled, bool, false )\
xxx(MaxShadowDiskFillBandwidth, ui32, 512 )\
xxx(MaxShadowDiskFillIoDepth, ui32, 1 )\
xxx(BackgroundOperationsTotalBandwidth, ui32, 1024 )\
Expand Down
1 change: 1 addition & 0 deletions cloud/blockstore/libs/storage/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ class TStorageConfig
bool GetYdbViewerServiceEnabled() const;

bool GetAutomaticallyEnableBufferCopyingAfterChecksumMismatch() const;
[[nodiscard]] bool GetNonReplicatedVolumeDirectAcquireEnabled() const;
};

ui64 GetAllocationUnit(
Expand Down
11 changes: 11 additions & 0 deletions cloud/blockstore/libs/storage/core/proto_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,15 @@ ui64 GetVolumeRequestId(const TEvDiskAgent::TEvZeroDeviceBlocksRequest& request)
return request.Record.GetVolumeRequestId();
}

TString LogDevices(const TVector<NProto::TDeviceConfig>& devices)
{
TStringBuilder sb;
sb << "( ";
for (const auto& d: devices) {
sb << d.GetDeviceUUID() << "@" << d.GetAgentId() << " ";
}
sb << ")";
return sb;
}

} // namespace NCloud::NBlockStore::NStorage
1 change: 1 addition & 0 deletions cloud/blockstore/libs/storage/core/proto_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,5 @@ TBlockRange64 BuildRequestBlockRange(
ui64 GetVolumeRequestId(const TEvDiskAgent::TEvWriteDeviceBlocksRequest& request);
ui64 GetVolumeRequestId(const TEvDiskAgent::TEvZeroDeviceBlocksRequest& request);

TString LogDevices(const TVector<NProto::TDeviceConfig>& devices);
} // namespace NCloud::NBlockStore::NStorage
Original file line number Diff line number Diff line change
Expand Up @@ -879,19 +879,6 @@ bool ToLogicalBlocks(NProto::TDeviceConfig& device, ui32 logicalBlockSize)

////////////////////////////////////////////////////////////////////////////////

TString LogDevices(const TVector<NProto::TDeviceConfig>& devices)
{
TStringBuilder sb;
sb << "( ";
for (const auto& d: devices) {
sb << d.GetDeviceUUID() << "@" << d.GetAgentId() << " ";
}
sb << ")";
return sb;
}

////////////////////////////////////////////////////////////////////////////////

void TDiskRegistryActor::OnDiskAcquired(
TVector<TAgentAcquireDevicesCachedRequest> sentAcquireRequests)
{
Expand Down Expand Up @@ -943,6 +930,9 @@ void TDiskRegistryActor::SendCachedAcquireRequestsToAgent(
const TActorContext& ctx,
const NProto::TAgentConfig& config)
{
if (Config->GetNonReplicatedVolumeDirectAcquireEnabled()) {
return;
}
auto& acquireCacheByAgentId = State->GetAcquireCacheByAgentId();
auto cacheIt = acquireCacheByAgentId.find(config.GetAgentId());
if (cacheIt == acquireCacheByAgentId.end()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,4 @@ class TDiskRegistryActor final
TDiskRegistryStateSnapshot MakeNewLoadState(
NProto::TDiskRegistryStateBackup&& backup);
bool ToLogicalBlocks(NProto::TDeviceConfig& device, ui32 logicalBlockSize);
TString LogDevices(const TVector<NProto::TDeviceConfig>& devices);

} // namespace NCloud::NBlockStore::NStorage
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "disk_registry_actor.h"

#include <cloud/blockstore/libs/storage/api/disk_agent.h>
#include <cloud/blockstore/libs/storage/core/proto_helpers.h>

#include <cloud/blockstore/libs/kikimr/events.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "disk_registry_actor.h"
#include <cloud/blockstore/libs/storage/core/proto_helpers.h>

#include <cloud/blockstore/libs/storage/api/disk_agent.h>

Expand Down
22 changes: 22 additions & 0 deletions cloud/blockstore/libs/storage/testlib/disk_agent_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class TDiskAgentMock final
HFunc(TEvDiskAgent::TEvZeroDeviceBlocksRequest, HandleZeroDeviceBlocks);
HFunc(TEvDiskAgent::TEvChecksumDeviceBlocksRequest, HandleChecksumDeviceBlocks);
HFunc(TEvDiskAgent::TEvDirectCopyBlocksRequest, HandleDirectCopyBlocks);
HFunc(TEvDiskAgent::TEvAcquireDevicesRequest, HandleAcquireDevicesRequest);
HFunc(TEvDiskAgent::TEvReleaseDevicesRequest, HandleReleaseDevicesRequest);

default:
Y_ABORT("Unexpected event %x", ev->GetTypeRewrite());
Expand Down Expand Up @@ -315,6 +317,26 @@ class TDiskAgentMock final
{
State->CreateDirectCopyActorFunc(ev, ctx, SelfId());
}

void HandleAcquireDevicesRequest(
TEvDiskAgent::TEvAcquireDevicesRequest::TPtr& ev,
const NActors::TActorContext& ctx)
{
auto response =
std::make_unique<TEvDiskAgent::TEvAcquireDevicesResponse>();

Reply(ctx, *ev, std::move(response));
}

void HandleReleaseDevicesRequest(
TEvDiskAgent::TEvReleaseDevicesRequest::TPtr& ev,
const NActors::TActorContext& ctx)
{
auto response =
std::make_unique<TEvDiskAgent::TEvReleaseDevicesResponse>();

Reply(ctx, *ev, std::move(response));
}
};

} // namespace NCloud::NBlockStore::NStorage
1 change: 1 addition & 0 deletions cloud/blockstore/libs/storage/volume/ut/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SRCS(
volume_state_ut.cpp
volume_ut.cpp
volume_ut_checkpoint.cpp
volume_ut_session.cpp
volume_ut_stats.cpp
)

Expand Down
6 changes: 6 additions & 0 deletions cloud/blockstore/libs/storage/volume/volume_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,9 @@ STFUNC(TVolumeActor::StateWork)
HFunc(
TEvDiskRegistry::TEvAcquireDiskResponse,
HandleAcquireDiskResponse);
HFunc(
TEvVolumePrivate::TEvDevicesAcquireFinished,
HandleDevicesAcquireFinished);
HFunc(
TEvVolumePrivate::TEvAcquireDiskIfNeeded,
HandleAcquireDiskIfNeeded);
Expand All @@ -1060,6 +1063,9 @@ STFUNC(TVolumeActor::StateWork)
HFunc(
TEvDiskRegistry::TEvReleaseDiskResponse,
HandleReleaseDiskResponse);
HFunc(
TEvVolumePrivate::TEvDevicesReleaseFinished,
HandleDevicesReleasedFinished);
HFunc(
TEvDiskRegistry::TEvAllocateDiskResponse,
HandleAllocateDiskResponse);
Expand Down
26 changes: 26 additions & 0 deletions cloud/blockstore/libs/storage/volume/volume_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,12 +716,26 @@ class TVolumeActor final
const TEvDiskRegistry::TEvAcquireDiskResponse::TPtr& ev,
const NActors::TActorContext& ctx);

void HandleDevicesAcquireFinishedImpl(
const NProto::TError& error,
const NActors::TActorContext& ctx);

void AcquireDisk(
const NActors::TActorContext& ctx,
TString clientId,
NProto::EVolumeAccessMode accessMode,
ui64 mountSeqNumber);

void SendAcquireDevicesToAgents(
TString clientId,
NProto::EVolumeAccessMode accessMode,
ui64 mountSeqNumber,
const NActors::TActorContext& ctx);

void HandleDevicesAcquireFinished(
const TEvVolumePrivate::TEvDevicesAcquireFinished::TPtr& ev,
const NActors::TActorContext& ctx);

void AcquireDiskIfNeeded(const NActors::TActorContext& ctx);

void ScheduleAcquireDiskIfNeeded(const NActors::TActorContext& ctx);
Expand All @@ -742,8 +756,20 @@ class TVolumeActor final
const TEvDiskRegistry::TEvReleaseDiskResponse::TPtr& ev,
const NActors::TActorContext& ctx);

void HandleDevicesReleasedFinishedImpl(
const NProto::TError& error,
const NActors::TActorContext& ctx);

void ReleaseDisk(const NActors::TActorContext& ctx, const TString& clientId);

void SendReleaseDevicesToAgents(
const TString& clientId,
const NActors::TActorContext& ctx);

void HandleDevicesReleasedFinished(
const TEvVolumePrivate::TEvDevicesReleaseFinished::TPtr& ev,
const NActors::TActorContext& ctx);

void HandleAllocateDiskResponse(
const TEvDiskRegistry::TEvAllocateDiskResponse::TPtr& ev,
const NActors::TActorContext& ctx);
Expand Down
Loading
Loading