Skip to content

Commit

Permalink
issue-2376: implement special switches to disable TwoStageReads and T…
Browse files Browse the repository at this point in the history
…hreeStageWrites for hdd fs (#2377)

* issue-2376: implement special switches to disable TwoStageReads and ThreeStageWrites for hdd fs

* update

* update
  • Loading branch information
yegorskii authored Oct 30, 2024
1 parent 6488b71 commit 19f3351
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 21 deletions.
6 changes: 6 additions & 0 deletions cloud/filestore/config/storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -450,4 +450,10 @@ message TStorageConfig
// rewriting the data belonging to this range.
optional uint32 CompactRangeGarbagePercentageThreshold = 401;
optional uint32 CompactRangeAverageBlobSizeThreshold = 402;

// Disables ThreeStageWrite for HDD filesystems.
optional bool ThreeStageWriteDisabledForHDD = 403;

// Disables TwoStageRead for HDD filesystems.
optional bool TwoStageReadDisabledForHDD = 404;
}
2 changes: 2 additions & 0 deletions cloud/filestore/libs/storage/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ using TAliases = NProto::TStorageConfig::TFilestoreAliases;
NCloud::NProto::AUTHORIZATION_IGNORE )\
\
xxx(TwoStageReadEnabled, bool, false )\
xxx(TwoStageReadDisabledForHDD, bool, false )\
xxx(ThreeStageWriteEnabled, bool, false )\
xxx(ThreeStageWriteThreshold, ui32, 64_KB )\
xxx(ThreeStageWriteDisabledForHDD, bool, false )\
xxx(UnalignedThreeStageWriteEnabled, bool, false )\
xxx(ReadAheadCacheMaxNodes, ui32, 1024 )\
xxx(ReadAheadCacheMaxResultsPerNode, ui32, 32 )\
Expand Down
3 changes: 3 additions & 0 deletions cloud/filestore/libs/storage/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ class TStorageConfig
TVector<TString> GetDestroyFilestoreDenyList() const;

bool GetSSProxyFallbackMode() const;

bool GetTwoStageReadDisabledForHDD() const;
bool GetThreeStageWriteDisabledForHDD() const;
};

} // namespace NCloud::NFileStore::NStorage
13 changes: 12 additions & 1 deletion cloud/filestore/libs/storage/service/service_actor_readdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ namespace {

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

bool IsTwoStageReadEnabled(const NProto::TFileStore& fs)
{
const auto isHdd = fs.GetStorageMediaKind() == NProto::STORAGE_MEDIA_HYBRID
|| fs.GetStorageMediaKind() == NProto::STORAGE_MEDIA_HDD;
const auto disabledAsHdd = isHdd &&
fs.GetFeatures().GetTwoStageReadDisabledForHDD();
return !disabledAsHdd && fs.GetFeatures().GetTwoStageReadEnabled();
}

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

class TReadDataActor final: public TActorBootstrapped<TReadDataActor>
{
private:
Expand Down Expand Up @@ -647,7 +658,7 @@ void TStorageServiceActor::HandleReadData(
msg->Record.SetFileSystemId(fsId);
}

if (!filestore.GetFeatures().GetTwoStageReadEnabled()) {
if (!IsTwoStageReadEnabled(filestore)) {
// If two-stage read is disabled, forward the request to the tablet in
// the same way as all other requests.
ForwardRequest<TEvService::TReadDataMethod>(ctx, ev);
Expand Down
17 changes: 15 additions & 2 deletions cloud/filestore/libs/storage/service/service_actor_writedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ namespace {

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

bool IsThreeStageWriteEnabled(const NProto::TFileStore& fs)
{
const auto isHdd = fs.GetStorageMediaKind() == NProto::STORAGE_MEDIA_HYBRID
|| fs.GetStorageMediaKind() == NProto::STORAGE_MEDIA_HDD;
const auto disabledAsHdd = isHdd &&
fs.GetFeatures().GetThreeStageWriteDisabledForHDD();
return !disabledAsHdd && fs.GetFeatures().GetThreeStageWriteEnabled();
}

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

class TWriteDataActor final: public TActorBootstrapped<TWriteDataActor>
{
private:
Expand Down Expand Up @@ -478,7 +489,9 @@ void TStorageServiceActor::HandleWriteData(
msg->Record.SetFileSystemId(fsId);
}

if (!filestore.GetFeatures().GetThreeStageWriteEnabled()) {
const auto threeStageWriteAllowed = IsThreeStageWriteEnabled(filestore);

if (!threeStageWriteAllowed) {
// If three-stage write is disabled, forward the request to the tablet
// in the same way as all other requests.
ForwardRequest<TEvService::TWriteDataMethod>(ctx, ev);
Expand All @@ -493,7 +506,7 @@ void TStorageServiceActor::HandleWriteData(
blockSize);
const bool threeStageWriteEnabled =
range.Length >= filestore.GetFeatures().GetThreeStageWriteThreshold()
&& filestore.GetFeatures().GetThreeStageWriteEnabled()
&& threeStageWriteAllowed
&& (range.IsAligned()
|| StorageConfig->GetUnalignedThreeStageWriteEnabled());
if (threeStageWriteEnabled) {
Expand Down
Loading

0 comments on commit 19f3351

Please sign in to comment.