Skip to content

Commit

Permalink
[Filestore] issue-2467: use file handle to restore invalidated node c…
Browse files Browse the repository at this point in the history
…ache entries in local filestore (#2938)
  • Loading branch information
budevg authored Feb 11, 2025
1 parent 0f388a9 commit a2c69e5
Show file tree
Hide file tree
Showing 10 changed files with 524 additions and 52 deletions.
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
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

0 comments on commit a2c69e5

Please sign in to comment.