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

[Filestore, merge to stable] add force operation to delete all zero compaction stat ranges; add action to write specified data to compaction map table, nfs-client.txt, support aliases for filestore names #1817

Merged
merged 9 commits into from
Aug 19, 2024
5 changes: 2 additions & 3 deletions cloud/blockstore/apps/client/lib/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ TCommand::TCommand(IBlockStorePtr client)
<< "config file name. Default is "
<< DefaultConfigFile)
.RequiredArgument("STR")
.DefaultValue(DefaultConfigFile)
.StoreResult(&ConfigFile);

Opts.AddLongOption("iam-config")
Expand Down Expand Up @@ -610,10 +611,8 @@ TString TCommand::GetIamTokenFromClient()
void TCommand::InitClientConfig()
{
NProto::TClientAppConfig appConfig;
if (ConfigFile) {
if (NFs::Exists(ConfigFile)) {
ParseFromTextFormat(ConfigFile, appConfig);
} else if (NFs::Exists(DefaultConfigFile)) {
ParseFromTextFormat(DefaultConfigFile, appConfig);
}

auto& clientConfig = *appConfig.MutableClientConfig();
Expand Down
14 changes: 14 additions & 0 deletions cloud/filestore/apps/client/lib/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cloud/storage/core/libs/common/timer.h>

#include <library/cpp/lwtrace/mon/mon_lwtrace.h>
#include <library/cpp/protobuf/util/pb_io.h>

#include <util/datetime/base.h>
#include <util/folder/dirut.h>
Expand All @@ -32,6 +33,7 @@ namespace {

constexpr TDuration WaitTimeout = TDuration::Seconds(1);

const TString DefaultConfigFile = "/Berkanavt/nfs-server/cfg/nfs-client.txt";
const TString DefaultIamTokenFile = "~/.nfs-client/iam-token";

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -103,6 +105,14 @@ TCommand::TCommand()
.RequiredArgument("STR")
.StoreResult(&IamTokenFile);

Opts.AddLongOption("config")
.Help(TStringBuilder()
<< "config file name. Default is "
<< DefaultConfigFile)
.RequiredArgument("STR")
.DefaultValue(DefaultConfigFile)
.StoreResult(&ConfigFile);

Opts.AddLongOption("json")
.StoreTrue(&JsonOutput);
}
Expand Down Expand Up @@ -174,6 +184,10 @@ void TCommand::Init()
Scheduler = CreateScheduler();

NProto::TClientConfig config;
if (NFs::Exists(ConfigFile)) {
ParseFromTextFormat(ConfigFile, config);
}

if (ServerAddress) {
config.SetHost(ServerAddress);
}
Expand Down
1 change: 1 addition & 0 deletions cloud/filestore/apps/client/lib/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class TCommand
ui32 SecurePort = 0;
bool SkipCertVerification = false;
TString IamTokenFile;
TString ConfigFile;

TClientConfigPtr ClientConfig;

Expand Down
15 changes: 15 additions & 0 deletions cloud/filestore/config/storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,19 @@ message TStorageConfig

// Enables ThreeStageWrite for unaligned requests.
optional bool UnalignedThreeStageWriteEnabled = 366;

// Number of ranges with zero compaction stats to delete per tx.
optional uint32 MaxZeroCompactionRangesToDeletePerTx = 367;

// Mapping allowing for multiple fs ids to point to the same fs
message TFilestoreAliasEntry
{
optional string Alias = 1;
optional string FsId = 2;
}
message TFilestoreAliases
{
repeated TFilestoreAliasEntry Entries = 1;
}
optional TFilestoreAliases FilestoreAliases = 368;
}
4 changes: 4 additions & 0 deletions cloud/filestore/libs/storage/api/tablet.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace NCloud::NFileStore::NStorage {
xxx(ConfigureAsFollower, __VA_ARGS__) \
xxx(GetStorageConfig, __VA_ARGS__) \
xxx(GetNodeAttrBatch, __VA_ARGS__) \
xxx(WriteCompactionMap, __VA_ARGS__) \
// FILESTORE_TABLET_REQUESTS

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -93,6 +94,9 @@ struct TEvIndexTablet
EvGetNodeAttrBatchRequest = EvBegin + 31,
EvGetNodeAttrBatchResponse,

EvWriteCompactionMapRequest = EvBegin + 33,
EvWriteCompactionMapResponse,

EvEnd
};

Expand Down
51 changes: 51 additions & 0 deletions cloud/filestore/libs/storage/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <library/cpp/monlib/service/pages/templates.h>

#include <util/generic/hash.h>
#include <util/generic/size_literals.h>

#include <google/protobuf/text_format.h>
Expand All @@ -12,6 +13,8 @@ namespace {

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

using TAliases = NProto::TStorageConfig::TFilestoreAliases;

#define FILESTORE_STORAGE_CONFIG(xxx) \
xxx(SchemeShardDir, TString, "/Root" )\
\
Expand Down Expand Up @@ -168,8 +171,14 @@ namespace {
xxx(AllowFileStoreForceDestroy, bool, false )\
xxx(BlobCompressionRate, ui32, 0 )\
xxx(BlobCompressionCodec, TString, "lz4" )\
\
xxx(MaxZeroCompactionRangesToDeletePerTx, ui32, 10000 )\
// FILESTORE_STORAGE_CONFIG

#define FILESTORE_STORAGE_CONFIG_REF(xxx) \
xxx(FilestoreAliases, TAliases, {} )\
// FILESTORE_STORAGE_CONFIG_REF

#define FILESTORE_DECLARE_CONFIG(name, type, value) \
Y_DECLARE_UNUSED static const type Default##name = value; \
// FILESTORE_DECLARE_CONFIG
Expand All @@ -186,6 +195,12 @@ bool IsEmpty(const T& t)
return !t;
}

template <>
bool IsEmpty(const TAliases& value)
{
return value.GetEntries().empty();
}

template <typename TTarget, typename TSource>
TTarget ConvertValue(const TSource& value)
{
Expand Down Expand Up @@ -218,6 +233,16 @@ void DumpImpl(const T& t, IOutputStream& os)
os << t;
}

template <>
void DumpImpl(const TAliases& value, IOutputStream& os)
{
os << "{ ";
for (const auto& x: value.GetEntries()) {
os << x.GetAlias() << ": " << x.GetFsId() << ", ";
}
os << " }";
}

} // namespace

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -234,6 +259,17 @@ FILESTORE_STORAGE_CONFIG(FILESTORE_CONFIG_GETTER)

#undef FILESTORE_CONFIG_GETTER

#define FILESTORE_CONFIG_GETTER_REF(name, type, ...) \
const type& TStorageConfig::Get##name() const \
{ \
return ProtoConfig.Get##name(); \
} \
// FILESTORE_CONFIG_GETTER_REF

FILESTORE_STORAGE_CONFIG_REF(FILESTORE_CONFIG_GETTER_REF)

#undef FILESTORE_CONFIG_GETTER_REF

void TStorageConfig::Dump(IOutputStream& out) const
{
#define FILESTORE_DUMP_CONFIG(name, ...) \
Expand All @@ -243,6 +279,7 @@ void TStorageConfig::Dump(IOutputStream& out) const
// FILESTORE_DUMP_CONFIG

FILESTORE_STORAGE_CONFIG(FILESTORE_DUMP_CONFIG);
FILESTORE_STORAGE_CONFIG_REF(FILESTORE_DUMP_CONFIG);

#undef FILESTORE_DUMP_CONFIG
}
Expand All @@ -260,6 +297,7 @@ void TStorageConfig::DumpHtml(IOutputStream& out) const
TABLE_CLASS("table table-condensed") {
TABLEBODY() {
FILESTORE_STORAGE_CONFIG(FILESTORE_DUMP_CONFIG);
FILESTORE_STORAGE_CONFIG_REF(FILESTORE_DUMP_CONFIG);
}
}
}
Expand All @@ -284,6 +322,7 @@ void TStorageConfig::DumpOverridesHtml(IOutputStream& out) const
TABLE_CLASS("table table-condensed") {
TABLEBODY() {
FILESTORE_STORAGE_CONFIG(FILESTORE_DUMP_CONFIG);
FILESTORE_STORAGE_CONFIG_REF(FILESTORE_DUMP_CONFIG);
}
}
}
Expand Down Expand Up @@ -329,4 +368,16 @@ const NProto::TStorageConfig& TStorageConfig::GetStorageConfigProto() const
return ProtoConfig;
}

const TString* TStorageConfig::FindFileSystemIdByAlias(
const TString& alias) const
{
const auto& entries = GetFilestoreAliases().GetEntries();
for (const auto& entry: entries) {
if (entry.GetAlias() == alias) {
return &entry.GetFsId();
}
}
return nullptr;
}

} // namespace NCloud::NFileStore::NStorage
5 changes: 5 additions & 0 deletions cloud/filestore/libs/storage/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ class TStorageConfig

bool GetAllowFileStoreForceDestroy() const;

ui32 GetMaxZeroCompactionRangesToDeletePerTx() const;

void Dump(IOutputStream& out) const;
void DumpHtml(IOutputStream& out) const;
void DumpOverridesHtml(IOutputStream& out) const;
Expand All @@ -222,6 +224,9 @@ class TStorageConfig
TString GetBlobCompressionCodec() const;

const NProto::TStorageConfig& GetStorageConfigProto() const;

const NProto::TStorageConfig::TFilestoreAliases& GetFilestoreAliases() const;
const TString* FindFileSystemIdByAlias(const TString& alias) const;
};

} // namespace NCloud::NFileStore::NStorage
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ target_sources(filestore-libs-storage-service PRIVATE
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config_fields.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_reassign_tablet.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_write_compaction_map.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_alterfs.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_complete.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ target_sources(filestore-libs-storage-service PRIVATE
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config_fields.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_reassign_tablet.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_write_compaction_map.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_alterfs.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_complete.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ target_sources(filestore-libs-storage-service PRIVATE
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config_fields.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_reassign_tablet.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_write_compaction_map.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_alterfs.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_complete.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ target_sources(filestore-libs-storage-service PRIVATE
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_get_storage_config_fields.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_reassign_tablet.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions_write_compaction_map.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_actions.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_alterfs.cpp
${CMAKE_SOURCE_DIR}/cloud/filestore/libs/storage/service/service_actor_complete.cpp
Expand Down
4 changes: 4 additions & 0 deletions cloud/filestore/libs/storage/service/service_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ class TStorageServiceActor final
TRequestInfoPtr requestInfo,
TString input);

NActors::IActorPtr CreateWriteCompactionMapActionActor(
TRequestInfoPtr requestInfo,
TString input);

private:
void RenderSessions(IOutputStream& out);
void RenderLocalFileStores(IOutputStream& out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ void TStorageServiceActor::HandleExecuteAction(
"getstorageconfig",
&TStorageServiceActor::CreateGetStorageConfigActionActor
},
{
"writecompactionmap",
&TStorageServiceActor::CreateWriteCompactionMapActionActor
},
};

auto it = actions.find(action);
Expand Down
Loading
Loading