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] issue-2467: use file handle to restore invalidated node cache entries in local filestore #2938

Merged
merged 6 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cloud/filestore/config/server.proto
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,17 @@ message TLocalServiceConfig
// Enable Writeback cache on guest (fuse client)
optional bool GuestWritebackCacheEnabled = 11;

// Async processing of destroy handle requests.
// Async processing of destroy handle requests
optional bool AsyncDestroyHandleEnabled = 12;

// Period of processing create/destroy handle requests.
// Period of processing create/destroy handle requests
optional uint32 AsyncHandleOperationPeriod = 13;

// Use open_by_handle_at to lookup nodes
budevg marked this conversation as resolved.
Show resolved Hide resolved
optional bool OpenNodeByHandleEnabled = 14;

// Number of nodes to clean in each iteration
optional uint32 NodeCleanupBatchSize = 15;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions cloud/filestore/libs/service_local/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ constexpr TDuration AsyncHandleOpsPeriod = TDuration::MilliSeconds(50);
xxx(GuestWritebackCacheEnabled, bool, false )\
xxx(AsyncDestroyHandleEnabled, bool, false )\
xxx(AsyncHandleOperationPeriod, TDuration, AsyncHandleOpsPeriod )\
xxx(OpenNodeByHandleEnabled, bool, false )\
xxx(NodeCleanupBatchSize, ui32, 1000 )\
// FILESTORE_SERVICE_CONFIG

#define FILESTORE_SERVICE_DECLARE_CONFIG(name, type, value) \
Expand Down
3 changes: 3 additions & 0 deletions cloud/filestore/libs/service_local/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ class TLocalFileStoreConfig
bool GetDirectIoEnabled() const;
ui32 GetDirectIoAlign() const;
bool GetGuestWritebackCacheEnabled() const;
ui32 GetNodeCleanupBatchSize() const;

void Dump(IOutputStream& out) const;
void DumpHtml(IOutputStream& out) const;

bool GetAsyncDestroyHandleEnabled() const;
TDuration GetAsyncHandleOperationPeriod() const;

bool GetOpenNodeByHandleEnabled() const;
};

} // namespace NCloud::NFileStore
2 changes: 2 additions & 0 deletions cloud/filestore/libs/service_local/fs_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ NProto::TCreateSessionResponse TLocalFileSystem::CreateSession(
clientId,
Config->GetMaxNodeCount(),
Config->GetMaxHandlePerSessionCount(),
Config->GetOpenNodeByHandleEnabled(),
Config->GetNodeCleanupBatchSize(),
Logging);

session->Init(request.GetRestoreClientSession());
Expand Down
43 changes: 42 additions & 1 deletion cloud/filestore/libs/service_local/index.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "index.h"

#include "lowlevel.h"
#include <util/string/builder.h>

namespace NCloud::NFileStore {

Expand Down Expand Up @@ -160,4 +160,45 @@ void TIndexNode::RemoveXAttr(const TString& name)
return NLowLevel::RemoveXAttr(NodeFd, name);
}

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

TNodeLoader::TNodeLoader(const TIndexNodePtr& rootNode)
: RootHandle(rootNode->OpenHandle(O_RDONLY))
, RootFileId(RootHandle)
{
switch (NLowLevel::TFileId::EFileIdType(RootFileId.FileHandle.handle_type)) {
case NLowLevel::TFileId::EFileIdType::Lustre:
case NLowLevel::TFileId::EFileIdType::Weka:
break;
default:
ythrow TServiceError(E_FS_NOTSUPP)
<< "Not supported hande type, RootFileId=" << RootFileId.ToString();
}
}

TIndexNodePtr TNodeLoader::LoadNode(ui64 nodeId) const
{
NLowLevel::TFileId fileId(RootFileId);

switch (NLowLevel::TFileId::EFileIdType(fileId.FileHandle.handle_type)) {
case NLowLevel::TFileId::EFileIdType::Lustre:
fileId.LustreFid.Oid = nodeId & 0xffffff;
fileId.LustreFid.Seq = (nodeId >> 24) & 0xffffffffff;
break;
case NLowLevel::TFileId::EFileIdType::Weka:
fileId.WekaInodeId.Id = nodeId;
break;
default:
ythrow TServiceError(E_FS_NOTSUPP);
}

auto handle = fileId.Open(RootHandle, O_PATH);
return std::make_shared<TIndexNode>(nodeId, std::move(handle));
}

TString TNodeLoader::ToString() const
{
return TStringBuilder() << "NodeLoader(" << RootFileId.ToString() << ")";
}

} // namespace NCloud::NFileStore
Loading
Loading