Skip to content

Commit

Permalink
issue-2725: correct issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vladstepanyuk committed Jan 17, 2025
1 parent 010bdce commit bfa8c07
Show file tree
Hide file tree
Showing 9 changed files with 423 additions and 210 deletions.
59 changes: 17 additions & 42 deletions cloud/blockstore/libs/storage/core/acquire_devices_actor.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "acquire_release_devices.h"
#include "acquire_release_devices_actors.h"

#include <cloud/blockstore/libs/storage/core/proto_helpers.h>
#include <cloud/storage/core/libs/actors/helpers.h>
Expand All @@ -11,6 +11,9 @@
#include <util/string/join.h>

namespace NCloud::NBlockStore::NStorage::NAcquireReleaseDevices {

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

using namespace NActors;

namespace {
Expand Down Expand Up @@ -39,14 +42,7 @@ class TAcquireDevicesActor final
public:
TAcquireDevicesActor(
const TActorId& owner,
TVector<NProto::TDeviceConfig> devices,
TString diskId,
TString clientId,
NProto::EVolumeAccessMode accessMode,
ui64 mountSeqNumber,
ui32 volumeGeneration,
TDuration requestTimeout,
bool muteIOErrors,
TAcquireReleaseDevicesInfo acquireDevicesInfo,
NLog::EComponent component);

void Bootstrap(const TActorContext& ctx);
Expand Down Expand Up @@ -104,24 +100,17 @@ class TAcquireDevicesActor final

TAcquireDevicesActor::TAcquireDevicesActor(
const TActorId& owner,
TVector<NProto::TDeviceConfig> devices,
TString diskId,
TString clientId,
NProto::EVolumeAccessMode accessMode,
ui64 mountSeqNumber,
ui32 volumeGeneration,
TDuration requestTimeout,
bool muteIOErrors,
TAcquireReleaseDevicesInfo acquireDevicesInfo,
NLog::EComponent component)
: Owner(owner)
, Devices(std::move(devices))
, DiskId(std::move(diskId))
, ClientId(std::move(clientId))
, AccessMode(accessMode)
, MountSeqNumber(mountSeqNumber)
, VolumeGeneration(volumeGeneration)
, RequestTimeout(requestTimeout)
, MuteIOErrors(muteIOErrors)
, Devices(std::move(acquireDevicesInfo.Devices))
, DiskId(std::move(acquireDevicesInfo.DiskId))
, ClientId(std::move(acquireDevicesInfo.ClientId))
, AccessMode(acquireDevicesInfo.AccessMode.value())
, MountSeqNumber(acquireDevicesInfo.MountSeqNumber.value())
, VolumeGeneration(acquireDevicesInfo.VolumeGeneration)
, RequestTimeout(acquireDevicesInfo.RequestTimeout)
, MuteIOErrors(acquireDevicesInfo.MuteIOErrors)
, Component(component)
{
SortBy(Devices, [](auto& d) { return d.GetNodeId(); });
Expand Down Expand Up @@ -375,27 +364,13 @@ STFUNC(TAcquireDevicesActor::StateAcquire)
TActorId CreateAcquireDevicesActor(
const NActors::TActorContext& ctx,
const TActorId& owner,
TVector<NProto::TDeviceConfig> devices,
TString diskId,
TString clientId,
NProto::EVolumeAccessMode accessMode,
ui64 mountSeqNumber,
ui32 volumeGeneration,
TDuration requestTimeout,
bool muteIOErrors,
NLog::EComponent component)
TAcquireReleaseDevicesInfo acquireDevicesInfo,
NActors::NLog::EComponent component)
{
return NCloud::Register<TAcquireDevicesActor>(
ctx,
owner,
std::move(devices),
diskId,
std::move(clientId),
accessMode,
mountSeqNumber,
volumeGeneration,
requestTimeout,
muteIOErrors,
std::move(acquireDevicesInfo),
component);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,29 @@ using TEvDevicesAcquireFinished =
using TEvDevicesReleaseFinished =
TRequestEvent<TDevicesReleaseFinished, EvDevicesReleaseFinished>;

struct TAcquireReleaseDevicesInfo
{
TVector<NProto::TDeviceConfig> Devices;
TString DiskId;
TString ClientId;
std::optional<NProto::EVolumeAccessMode>
AccessMode; // Only AcquireDevicesActor need it.
std::optional<ui64> MountSeqNumber; // Only AcquireDevicesActor need it.
ui32 VolumeGeneration;
TDuration RequestTimeout;
bool MuteIOErrors;
};

TActorId CreateAcquireDevicesActor(
const NActors::TActorContext& ctx,
const TActorId& owner,
TVector<NProto::TDeviceConfig> devices,
TString diskId,
TString clientId,
NProto::EVolumeAccessMode accessMode,
ui64 mountSeqNumber,
ui32 volumeGeneration,
TDuration requestTimeout,
bool muteIOErrors,
TAcquireReleaseDevicesInfo acquireDevicesInfo,
NActors::NLog::EComponent component);

TActorId CreateReleaseDevicesActor(
const NActors::TActorContext& ctx,
const TActorId& owner,
TString diskId,
TString clientId,
ui32 volumeGeneration,
TDuration requestTimeout,
TVector<NProto::TDeviceConfig> devices,
bool muteIOErrors,
TAcquireReleaseDevicesInfo releaseDevicesInfo,
NActors::NLog::EComponent component);

} // namespace NCloud::NBlockStore::NStorage::NAcquireReleaseDevices
49 changes: 16 additions & 33 deletions cloud/blockstore/libs/storage/core/release_devices_actor.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "acquire_release_devices.h"
#include "acquire_release_devices_actors.h"

#include <cloud/blockstore/libs/storage/core/proto_helpers.h>
#include <cloud/storage/core/libs/actors/helpers.h>
Expand All @@ -10,6 +10,9 @@
#include <util/string/join.h>

namespace NCloud::NBlockStore::NStorage::NAcquireReleaseDevices {

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

using namespace NActors;

namespace {
Expand All @@ -21,11 +24,11 @@ class TReleaseDevicesActor final
{
private:
const TActorId Owner;
TVector<NProto::TDeviceConfig> Devices;
const TString DiskId;
const TString ClientId;
const ui32 VolumeGeneration;
const TDuration RequestTimeout;
TVector<NProto::TDeviceConfig> Devices;
bool MuteIOErrors;
NLog::EComponent Component;

Expand All @@ -36,12 +39,7 @@ class TReleaseDevicesActor final
public:
TReleaseDevicesActor(
const TActorId& owner,
TString diskId,
TString clientId,
ui32 volumeGeneration,
TDuration requestTimeout,
TVector<NProto::TDeviceConfig> devices,
bool muteIoErrors,
TAcquireReleaseDevicesInfo releaseDevicesInfo,
NLog::EComponent component);

void Bootstrap(const TActorContext& ctx);
Expand Down Expand Up @@ -81,20 +79,15 @@ class TReleaseDevicesActor final

TReleaseDevicesActor::TReleaseDevicesActor(
const TActorId& owner,
TString diskId,
TString clientId,
ui32 volumeGeneration,
TDuration requestTimeout,
TVector<NProto::TDeviceConfig> devices,
bool muteIOErrors,
TAcquireReleaseDevicesInfo releaseDevicesInfo,
NLog::EComponent component)
: Owner(owner)
, DiskId(std::move(diskId))
, ClientId(std::move(clientId))
, VolumeGeneration(volumeGeneration)
, RequestTimeout(requestTimeout)
, Devices(std::move(devices))
, MuteIOErrors(muteIOErrors)
, Devices(std::move(releaseDevicesInfo.Devices))
, DiskId(std::move(releaseDevicesInfo.DiskId))
, ClientId(std::move(releaseDevicesInfo.ClientId))
, VolumeGeneration(releaseDevicesInfo.VolumeGeneration)
, RequestTimeout(releaseDevicesInfo.RequestTimeout)
, MuteIOErrors(releaseDevicesInfo.MuteIOErrors)
, Component(component)
{}

Expand Down Expand Up @@ -249,25 +242,15 @@ TString TReleaseDevicesActor::LogTargets() const
} // namespace

TActorId CreateReleaseDevicesActor(
const TActorContext& ctx,
const NActors::TActorContext& ctx,
const TActorId& owner,
TString diskId,
TString clientId,
ui32 volumeGeneration,
TDuration requestTimeout,
TVector<NProto::TDeviceConfig> devices,
bool muteIOErrors,
TAcquireReleaseDevicesInfo releaseDevicesInfo,
NActors::NLog::EComponent component)
{
return NCloud::Register<TReleaseDevicesActor>(
ctx,
owner,
std::move(diskId),
std::move(clientId),
volumeGeneration,
requestTimeout,
std::move(devices),
muteIOErrors,
releaseDevicesInfo,
component);
}
} // namespace NCloud::NBlockStore::NStorage::NAcquireReleaseDevices
Original file line number Diff line number Diff line change
Expand Up @@ -188,24 +188,6 @@ void TDiskRegistryActor::BeforeDie(const NActors::TActorContext& ctx)
MakeTabletIsDeadError(E_REJECTED, __LOCATION__));
}
PendingDiskDeallocationRequests.clear();

for (auto& [_, requestInfo]: PendingAcquireDiskRequests) {
NCloud::Reply(
ctx,
*requestInfo,
std::make_unique<TEvDiskRegistry::TEvAcquireDiskResponse>(
MakeTabletIsDeadError(E_REJECTED, __LOCATION__)));
}
PendingAcquireDiskRequests.clear();

for (auto& [_, requestInfo]: PendingReleaseDiskRequests) {
NCloud::Reply(
ctx,
*requestInfo,
std::make_unique<TEvDiskRegistry::TEvReleaseDiskResponse>(
MakeTabletIsDeadError(E_REJECTED, __LOCATION__)));
}
PendingReleaseDiskRequests.clear();
}

void TDiskRegistryActor::OnDetach(const TActorContext& ctx)
Expand Down Expand Up @@ -726,14 +708,6 @@ STFUNC(TDiskRegistryActor::StateWork)
TEvDiskRegistryPrivate::TEvDiskRegistryAgentListExpiredParamsCleanup,
TDiskRegistryActor::HandleDiskRegistryAgentListExpiredParamsCleanup);

HFunc(
NAcquireReleaseDevices::TEvDevicesAcquireFinished,
HandleDevicesAcquireFinished);

HFunc(
NAcquireReleaseDevices::TEvDevicesReleaseFinished,
HandleDevicesReleaseFinished);

default:
if (!HandleRequests(ev) && !HandleDefaultEvents(ev, SelfId())) {
HandleUnexpectedEvent(ev, TBlockStoreComponents::DISK_REGISTRY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <cloud/blockstore/libs/storage/api/disk_agent.h>
#include <cloud/blockstore/libs/storage/api/disk_registry.h>
#include <cloud/blockstore/libs/storage/api/service.h>
#include <cloud/blockstore/libs/storage/core/acquire_release_devices.h>
#include <cloud/blockstore/libs/storage/core/acquire_release_devices_actors.h>
#include <cloud/blockstore/libs/storage/core/config.h>
#include <cloud/blockstore/libs/storage/core/monitoring_utils.h>
#include <cloud/blockstore/libs/storage/core/pending_request.h>
Expand Down Expand Up @@ -86,9 +86,6 @@ class TDiskRegistryActor final

THashMap<TDiskId, TVector<TRequestInfoPtr>> PendingDiskDeallocationRequests;

THashMap<NActors::TActorId, TRequestInfoPtr> PendingAcquireDiskRequests;
THashMap<NActors::TActorId, TRequestInfoPtr> PendingReleaseDiskRequests;

bool BrokenDisksDestructionInProgress = false;
bool DisksNotificationInProgress = false;
bool UsersNotificationInProgress = false;
Expand Down Expand Up @@ -246,16 +243,9 @@ class TDiskRegistryActor final
NProto::TError error);

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

void HandleDevicesAcquireFinished(
const NAcquireReleaseDevices::TEvDevicesAcquireFinished::TPtr& ev,
const NActors::TActorContext& ctx);
void OnDiskAcquired(
TVector<NAcquireReleaseDevices::TAgentAcquireDevicesCachedRequest>
sentAcquireRequests);
void HandleDevicesReleaseFinished(
const NAcquireReleaseDevices::TEvDevicesReleaseFinished::TPtr& ev,
const NActors::TActorContext& ctx);
void OnDiskReleased(
const TVector<
NAcquireReleaseDevices::TAgentReleaseDevicesCachedRequest>&
Expand Down
Loading

0 comments on commit bfa8c07

Please sign in to comment.