From 070358ec499207789c32a0e0ae5d81d3a6d83bef Mon Sep 17 00:00:00 2001 From: qkrorlqr Date: Fri, 30 Aug 2024 18:00:41 +0000 Subject: [PATCH] issue-1795: writing LargeDeletionMarkers instead of normal DeletionMarkers if the deleted range is big enough and the corresponding StorageServiceConfig params are set --- .../tablet/tablet_actor_allocatedata.cpp | 3 -- .../libs/storage/tablet/tablet_state.cpp | 4 ++ .../libs/storage/tablet/tablet_state.h | 3 ++ .../libs/storage/tablet/tablet_state_data.cpp | 45 ++++++++++++++----- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/cloud/filestore/libs/storage/tablet/tablet_actor_allocatedata.cpp b/cloud/filestore/libs/storage/tablet/tablet_actor_allocatedata.cpp index e4644d16390..8e398582b10 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_actor_allocatedata.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_actor_allocatedata.cpp @@ -199,9 +199,6 @@ void TIndexTabletActor::ExecuteTx_AllocateData( if (args.CommitId == InvalidCommitId) { return RebootTabletOnCommitOverflow(ctx, "AllocateData"); } - // TODO: We should not use this range request because tx size - // is limited. Need some generic process range mechanism after - // NBS-2979 ZeroRange( db, args.NodeId, diff --git a/cloud/filestore/libs/storage/tablet/tablet_state.cpp b/cloud/filestore/libs/storage/tablet/tablet_state.cpp index bfb74b92ab9..ea6eacfd789 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_state.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_state.cpp @@ -97,6 +97,10 @@ void TIndexTabletState::LoadState( ChannelMinFreeSpace = config.GetChannelMinFreeSpace() / 100.; ChannelFreeSpaceThreshold = config.GetChannelFreeSpaceThreshold() / 100.; + LargeDeletionMarkersEnabled = config.GetLargeDeletionMarkersEnabled(); + LargeDeletionMarkerBlocks = config.GetLargeDeletionMarkerBlocks(); + LargeDeletionMarkersThreshold = config.GetLargeDeletionMarkersThreshold(); + FileSystem.CopyFrom(fileSystem); FileSystemStats.CopyFrom(fileSystemStats); TabletStorageInfo.CopyFrom(tabletStorageInfo); diff --git a/cloud/filestore/libs/storage/tablet/tablet_state.h b/cloud/filestore/libs/storage/tablet/tablet_state.h index 7345abcbb79..90362218c26 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_state.h +++ b/cloud/filestore/libs/storage/tablet/tablet_state.h @@ -145,6 +145,9 @@ class TIndexTabletState /*const*/ ui32 SessionHistoryEntryCount = 0; /*const*/ double ChannelMinFreeSpace = 0; /*const*/ double ChannelFreeSpaceThreshold = 1; + /*const*/ bool LargeDeletionMarkersEnabled = false; + /*const*/ ui64 LargeDeletionMarkerBlocks = 0; + /*const*/ ui64 LargeDeletionMarkersThreshold = 0; bool StateLoaded = false; diff --git a/cloud/filestore/libs/storage/tablet/tablet_state_data.cpp b/cloud/filestore/libs/storage/tablet/tablet_state_data.cpp index 40bd5e0336c..37f2743398a 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_state_data.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_state_data.cpp @@ -177,18 +177,39 @@ void TIndexTabletState::DeleteRange( range.FirstAlignedBlock(), deletedBlockCount); - SplitRange( - range.FirstAlignedBlock(), - deletedBlockCount, - BlockGroupSize, - [&] (ui32 blockOffset, ui32 blocksCount) { - MarkMixedBlocksDeleted( - db, - nodeId, - commitId, - range.FirstAlignedBlock() + blockOffset, - blocksCount); - }); + const bool useLargeDeletionMarkers = LargeDeletionMarkersEnabled + && deletedBlockCount >= LargeDeletionMarkersThreshold; + if (useLargeDeletionMarkers) { + SplitRange( + range.FirstAlignedBlock(), + deletedBlockCount, + LargeDeletionMarkerBlocks, + [&] (ui32 blockOffset, ui32 blocksCount) { + Impl->LargeBlocks.AddDeletionMarker({ + nodeId, + commitId, + blockOffset, + blocksCount}); + db.WriteLargeDeletionMarkers( + nodeId, + commitId, + blockOffset, + blocksCount); + }); + } else { + SplitRange( + range.FirstAlignedBlock(), + deletedBlockCount, + BlockGroupSize, + [&] (ui32 blockOffset, ui32 blocksCount) { + MarkMixedBlocksDeleted( + db, + nodeId, + commitId, + range.FirstAlignedBlock() + blockOffset, + blocksCount); + }); + } } WriteFreshBytesDeletionMarker(