Skip to content

Commit 32b648d

Browse files
authored
Unification of naming for index of the device in the partition config (#4620)
continue #4575 Unification of naming for index of the device in the partition config
1 parent bfc8472 commit 32b648d

9 files changed

+80
-56
lines changed

cloud/blockstore/libs/storage/partition_nonrepl/part_nonrepl_actor_base_request.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void TDiskAgentBaseRequestActor::Done(
108108

109109
for (const auto& dr: DeviceRequests) {
110110
completion.Body->RequestResults.push_back(
111-
{.DeviceIndex = dr.DeviceIdx, .Error = {}});
111+
{.DeviceIdx = dr.DeviceIdx, .Error = {}});
112112
}
113113

114114
NCloud::Send(ctx, Part, std::move(completion.Event));

cloud/blockstore/libs/storage/partition_nonrepl/part_nonrepl_events_private.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,10 @@ struct TEvNonreplPartitionPrivate
238238

239239
struct TDeviceRequestResult
240240
{
241-
// Index of device that participated in the request and the
242-
// result of the request for that device.
243-
ui32 DeviceIndex = 0;
241+
// Index of the device in the partition config.
242+
ui32 DeviceIdx = 0;
243+
244+
// Result of the request for that device.
244245
NProto::TError Error;
245246
};
246247

cloud/blockstore/libs/storage/partition_nonrepl/part_nonrepl_rdma_actor.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,13 @@ TNonreplicatedPartitionRdmaActor::SendReadRequests(
323323
const auto& r = deviceRequests[i];
324324
auto ep = AgentId2Endpoint[r.Device.GetAgentId()];
325325
Y_ABORT_UNLESS(ep);
326-
auto dr = std::make_unique<TDeviceReadRequestContext>();
326+
auto dr = std::make_unique<TDeviceReadRequestContext>(
327+
r.DeviceIdx,
328+
startBlockIndexOffset,
329+
r.DeviceBlockRange.Size(),
330+
i);
327331

328332
ui64 sz = r.DeviceBlockRange.Size() * PartConfig->GetBlockSize();
329-
dr->StartIndexOffset = startBlockIndexOffset;
330-
dr->BlockCount = r.DeviceBlockRange.Size();
331-
dr->DeviceIdx = r.DeviceIdx;
332-
dr->RequestIndex = i;
333333
startBlockIndexOffset += r.DeviceBlockRange.Size();
334334

335335
sentRequestCtx.emplace_back(r.DeviceIdx);
@@ -368,7 +368,8 @@ TNonreplicatedPartitionRdmaActor::SendReadRequests(
368368
flags,
369369
deviceRequest);
370370

371-
requests.push_back({std::move(ep), std::move(req)});
371+
requests.push_back(
372+
{.Endpoint = std::move(ep), .ClientRequest = std::move(req)});
372373
}
373374

374375
for (size_t i = 0; i < requests.size(); ++i) {
@@ -726,24 +727,23 @@ void TNonreplicatedPartitionRdmaActor::HandleAgentIsUnavailable(
726727
const auto& requestCtx = requestInfo.Value;
727728
bool needToCancel = AnyOf(
728729
requestCtx,
729-
[&](const auto& ctx)
730+
[&](const TRunningRdmaRequestInfo& item)
730731
{
731-
return laggingRows.contains(ctx.DeviceIndex) &&
732+
return laggingRows.contains(item.DeviceIdx) &&
732733
(requestInfo.IsWrite ||
733-
devices[ctx.DeviceIndex].GetAgentId() ==
734-
laggingAgentId);
734+
devices[item.DeviceIdx].GetAgentId() == laggingAgentId);
735735
});
736736

737737
if (!needToCancel) {
738738
continue;
739739
}
740740

741-
for (auto [deviceIdx, rdmaRequestId]: requestCtx) {
742-
Y_ABORT_UNLESS(deviceIdx < static_cast<ui64>(devices.size()));
743-
auto agentId = devices[deviceIdx].GetAgentId();
741+
for (const TRunningRdmaRequestInfo& item: requestCtx) {
742+
Y_ABORT_UNLESS(item.DeviceIdx < static_cast<ui64>(devices.size()));
743+
const auto& agentId = devices[item.DeviceIdx].GetAgentId();
744744

745745
auto& endpoint = AgentId2Endpoint[agentId];
746-
endpoint->CancelRequest(rdmaRequestId);
746+
endpoint->CancelRequest(item.SentRequestId);
747747
}
748748
}
749749
}

cloud/blockstore/libs/storage/partition_nonrepl/part_nonrepl_rdma_actor.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,28 @@ namespace NCloud::NBlockStore::NStorage {
3131

3232
struct TDeviceReadRequestContext: public TDeviceRequestRdmaContext
3333
{
34-
ui64 StartIndexOffset = 0;
35-
ui64 BlockCount = 0;
36-
ui32 RequestIndex = 0;
34+
const ui64 StartIndexOffset = 0;
35+
const ui64 BlockCount = 0;
36+
const ui32 RequestIndex = 0;
37+
38+
TDeviceReadRequestContext(
39+
ui32 deviceIdx,
40+
ui64 startIndexOffset,
41+
ui64 blockCount,
42+
ui32 requestIndex)
43+
: TDeviceRequestRdmaContext(deviceIdx)
44+
, StartIndexOffset(startIndexOffset)
45+
, BlockCount(blockCount)
46+
, RequestIndex(requestIndex)
47+
{}
3748
};
3849

3950
////////////////////////////////////////////////////////////////////////////////
4051

4152
class TNonreplicatedPartitionRdmaActor final
4253
: public NActors::TActorBootstrapped<TNonreplicatedPartitionRdmaActor>
4354
{
44-
struct TDeviceRequestContext
45-
{
46-
ui32 DeviceIndex = 0;
47-
ui64 SentRequestId = 0;
48-
};
49-
50-
using TRequestContext = TStackVec<TDeviceRequestContext, 2>;
55+
using TRequestContext = TStackVec<TRunningRdmaRequestInfo, 2>;
5156

5257
private:
5358
const TStorageConfigPtr Config;

cloud/blockstore/libs/storage/partition_nonrepl/part_nonrepl_rdma_actor_checksumblocks.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,17 @@ namespace {
2525

2626
struct TDeviceChecksumRequestContext: public TDeviceRequestRdmaContext
2727
{
28-
ui64 RangeStartIndex = 0;
29-
ui32 RangeSize = 0;
28+
const ui64 RangeStartIndex = 0;
29+
const ui32 RangeSize = 0;
30+
31+
TDeviceChecksumRequestContext(
32+
ui32 deviceIdx,
33+
ui64 rangeStartIndex,
34+
ui32 rangeSize)
35+
: TDeviceRequestRdmaContext(deviceIdx)
36+
, RangeStartIndex(rangeStartIndex)
37+
, RangeSize(rangeSize)
38+
{}
3039
};
3140

3241
////////////////////////////////////////////////////////////////////////////////
@@ -161,10 +170,10 @@ void TNonreplicatedPartitionRdmaActor::HandleChecksumBlocks(
161170
for (auto& r: deviceRequests) {
162171
auto ep = AgentId2Endpoint[r.Device.GetAgentId()];
163172
Y_ABORT_UNLESS(ep);
164-
auto dc = std::make_unique<TDeviceChecksumRequestContext>();
165-
dc->RangeStartIndex = r.BlockRange.Start;
166-
dc->RangeSize = r.DeviceBlockRange.Size() * PartConfig->GetBlockSize();
167-
dc->DeviceIdx = r.DeviceIdx;
173+
auto dc = std::make_unique<TDeviceChecksumRequestContext>(
174+
r.DeviceIdx,
175+
r.BlockRange.Start,
176+
r.DeviceBlockRange.Size() * PartConfig->GetBlockSize());
168177

169178
sentRequestCtx.emplace_back(r.DeviceIdx);
170179

cloud/blockstore/libs/storage/partition_nonrepl/part_nonrepl_rdma_actor_writeblocks.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,11 @@ void TNonreplicatedPartitionRdmaActor::HandleWriteBlocks(
248248
PartConfig,
249249
AssignIdToWriteAndZeroRequestsEnabled);
250250

251-
auto context = std::make_unique<TDeviceRequestRdmaContext>();
252-
context->DeviceIdx = deviceRequest.DeviceIdx;
251+
auto context = std::make_unique<TDeviceRequestRdmaContext>(
252+
deviceRequest.DeviceIdx);
253253

254-
sentRequestCtx.emplace_back(deviceRequest.DeviceIdx);
254+
sentRequestCtx.emplace_back(
255+
TRunningRdmaRequestInfo{.DeviceIdx = deviceRequest.DeviceIdx});
255256

256257
auto [req, err] = ep->AllocateRequest(
257258
requestResponseHandler,
@@ -274,12 +275,11 @@ void TNonreplicatedPartitionRdmaActor::HandleWriteBlocks(
274275
ctx,
275276
deviceRequest.Device.GetDeviceUUID());
276277

277-
using TResponse = TEvService::TEvWriteBlocksResponse;
278278
NCloud::Reply(
279279
ctx,
280280
*requestInfo,
281-
std::make_unique<TResponse>(std::move(err)));
282-
281+
std::make_unique<TEvService::TEvWriteBlocksResponse>(
282+
std::move(err)));
283283
return;
284284
}
285285

@@ -298,7 +298,8 @@ void TNonreplicatedPartitionRdmaActor::HandleWriteBlocks(
298298
request,
299299
sglist);
300300

301-
requests.push_back({std::move(ep), std::move(req)});
301+
requests.push_back(
302+
{.Endpoint = std::move(ep), .ClientRequest = std::move(req)});
302303
}
303304

304305
for (size_t i = 0; i < requests.size(); ++i) {
@@ -423,8 +424,8 @@ void TNonreplicatedPartitionRdmaActor::HandleWriteBlocksLocal(
423424
PartConfig,
424425
AssignIdToWriteAndZeroRequestsEnabled);
425426

426-
auto context = std::make_unique<TDeviceRequestRdmaContext>();
427-
context->DeviceIdx = deviceRequest.DeviceIdx;
427+
auto context = std::make_unique<TDeviceRequestRdmaContext>(
428+
deviceRequest.DeviceIdx);
428429

429430
auto [req, err] = ep->AllocateRequest(
430431
requestResponseHandler,
@@ -447,11 +448,11 @@ void TNonreplicatedPartitionRdmaActor::HandleWriteBlocksLocal(
447448
ctx,
448449
deviceRequest.Device.GetDeviceUUID());
449450

450-
using TResponse = TEvService::TEvWriteBlocksLocalResponse;
451451
NCloud::Reply(
452452
ctx,
453453
*requestInfo,
454-
std::make_unique<TResponse>(std::move(err)));
454+
std::make_unique<TEvService::TEvWriteBlocksLocalResponse>(
455+
std::move(err)));
455456

456457
return;
457458
}
@@ -472,7 +473,8 @@ void TNonreplicatedPartitionRdmaActor::HandleWriteBlocksLocal(
472473

473474
blocks += deviceRequest.DeviceBlockRange.Size();
474475

475-
requests.push_back({std::move(ep), std::move(req)});
476+
requests.push_back(
477+
{.Endpoint = std::move(ep), .ClientRequest = std::move(req)});
476478
}
477479

478480
for (size_t i = 0; i < requests.size(); ++i) {

cloud/blockstore/libs/storage/partition_nonrepl/part_nonrepl_rdma_actor_writeblocks_multi_agent.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,11 @@ void TNonreplicatedPartitionRdmaActor::HandleMultiAgentWrite(
305305
const auto sentRequestId =
306306
ep->SendRequest(std::move(req), requestInfo->CallContext);
307307

308-
RequestsInProgress.AddWriteRequest(
309-
requestId,
310-
TRequestContext{TDeviceRequestContext{
311-
.DeviceIndex = deviceRequest.DeviceIdx,
312-
.SentRequestId = sentRequestId}});
308+
TRequestContext sentRequestCtx{
309+
{.DeviceIdx = deviceRequest.DeviceIdx,
310+
.SentRequestId = sentRequestId}};
311+
312+
RequestsInProgress.AddWriteRequest(requestId, sentRequestCtx);
313313
}
314314

315315
} // namespace NCloud::NBlockStore::NStorage

cloud/blockstore/libs/storage/partition_nonrepl/part_nonrepl_rdma_actor_zeroblocks.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ void TNonreplicatedPartitionRdmaActor::HandleZeroBlocks(
130130
msg->Record.GetHeaders().GetVolumeRequestId());
131131
}
132132

133-
auto context = std::make_unique<TDeviceRequestRdmaContext>();
134-
context->DeviceIdx = r.DeviceIdx;
133+
auto context = std::make_unique<TDeviceRequestRdmaContext>(r.DeviceIdx);
135134

136135
auto [req, err] = ep->AllocateRequest(
137136
requestContext,
@@ -161,7 +160,8 @@ void TNonreplicatedPartitionRdmaActor::HandleZeroBlocks(
161160
0, // flags
162161
deviceRequest);
163162

164-
requests.push_back({std::move(ep), std::move(req)});
163+
requests.push_back(
164+
{.Endpoint = std::move(ep), .ClientRequest = std::move(req)});
165165
}
166166

167167
for (size_t i = 0; i < requests.size(); ++i) {

cloud/blockstore/libs/storage/partition_nonrepl/rdma_device_request_handler.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,21 @@ namespace NCloud::NBlockStore::NStorage {
1818

1919
struct TDeviceRequestRdmaContext: public NRdma::TNullContext
2020
{
21-
ui32 DeviceIdx = 0;
21+
// Index of the device in the partition config.
22+
const ui32 DeviceIdx;
2223

23-
TDeviceRequestRdmaContext() = default;
2424
explicit TDeviceRequestRdmaContext(ui32 deviceIdx)
2525
: DeviceIdx(deviceIdx)
2626
{}
2727
};
2828

29+
struct TRunningRdmaRequestInfo
30+
{
31+
// Index of the device in the partition config.
32+
ui32 DeviceIdx = 0;
33+
ui64 SentRequestId = 0;
34+
};
35+
2936
////////////////////////////////////////////////////////////////////////////////
3037

3138
template <typename TDerived>

0 commit comments

Comments
 (0)