New upstream version 8.1.0
This commit is contained in:
199
client_module/source/Makefile
Normal file
199
client_module/source/Makefile
Normal file
@@ -0,0 +1,199 @@
|
||||
# NOTE(jstimpfle, 2022-04): I changed the interface of the feature-detect.sh
|
||||
# script to take some arguments explicitly from the command-line, as opposed to
|
||||
# implicitly from the environment.
|
||||
#
|
||||
# The reason is that we hit a case where there was a string literal in
|
||||
# KBUILD_CFLAGS (generated in Linux kernel Makefiles), and since this variable
|
||||
# is normally used as part of shell commands contained in Makefiles this
|
||||
# string literal is wrapped in a pair of single quotes,
|
||||
# like this '"string literal"'.
|
||||
|
||||
BEEGFS_FEATURE_DETECTION := $(shell $(dir $(lastword $(MAKEFILE_LIST)))/../build/feature-detect.sh $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS))
|
||||
|
||||
ifneq ($(lastword $(BEEGFS_FEATURE_DETECTION)),--~~success~~--)
|
||||
$(error feature detection reported an error)
|
||||
else
|
||||
BEEGFS_FEATURE_DETECTION := $(filter-out --~~success~~--,$(BEEGFS_FEATURE_DETECTION))
|
||||
$(info feature detection gives: $(BEEGFS_FEATURE_DETECTION))
|
||||
endif
|
||||
|
||||
# ccflags-y was introduced in 2.6.24, earlier kernels use EXTRA_CFLAGS for the same purpose
|
||||
ifeq ($(origin ccflags-y),file)
|
||||
ccflags-y += $(BEEGFS_FEATURE_DETECTION)
|
||||
else
|
||||
# the client makefile sets this already
|
||||
override EXTRA_CFLAGS += $(BEEGFS_FEATURE_DETECTION)
|
||||
endif
|
||||
|
||||
kernel-version = $(shell printf "%02d%02d" $(VERSION) $(PATCHLEVEL))
|
||||
kernel-if-version-or-later = $(shell [ $(kernel-version) -ge $(1) ] && echo $(2))
|
||||
|
||||
obj-m += ${TARGET}.o
|
||||
|
||||
SOURCES := \
|
||||
fault-inject/fault-inject.c \
|
||||
os/iov_iter.c \
|
||||
os/atomic64.c \
|
||||
os/OsCompat.c \
|
||||
os/OsDeps.c \
|
||||
net/message/NetMessageFactory.c \
|
||||
net/filesystem/FhgfsOpsCommKit.c \
|
||||
net/filesystem/FhgfsOpsRemoting.c \
|
||||
net/filesystem/FhgfsOpsCommKitVec.c \
|
||||
common/system/System.c \
|
||||
common/net/sock/Socket.c \
|
||||
common/net/sock/NicAddress.c \
|
||||
common/net/sock/NetworkInterfaceCard.c \
|
||||
common/net/sock/NicAddressList.c \
|
||||
common/net/sock/RDMASocket.c \
|
||||
common/net/sock/ibv/IBVSocket.c \
|
||||
common/net/sock/ibv/IBVBuffer.c \
|
||||
common/net/sock/ibv/No_IBVSocket.c \
|
||||
common/net/sock/StandardSocket.c \
|
||||
common/net/message/control/PeerInfoMsg.c \
|
||||
common/net/message/SimpleIntMsg.c \
|
||||
common/net/message/NetMessage.c \
|
||||
common/net/message/session/locking/FLockEntryMsg.c \
|
||||
common/net/message/session/locking/FLockAppendMsg.c \
|
||||
common/net/message/session/locking/LockGrantedMsgEx.c \
|
||||
common/net/message/session/locking/FLockRangeMsg.c \
|
||||
common/net/message/session/GetFileVersionRespMsg.c \
|
||||
common/net/message/session/rw/ReadLocalFileV2Msg.c \
|
||||
common/net/message/session/rw/ReadLocalFileRDMAMsg.c \
|
||||
common/net/message/session/rw/WriteLocalFileMsg.c \
|
||||
common/net/message/session/rw/WriteLocalFileRDMAMsg.c \
|
||||
common/net/message/session/FSyncLocalFileMsg.c \
|
||||
common/net/message/session/GetFileVersionMsg.c \
|
||||
common/net/message/session/opening/OpenFileMsg.c \
|
||||
common/net/message/session/opening/OpenFileRespMsg.c \
|
||||
common/net/message/session/opening/CloseFileMsg.c \
|
||||
common/net/message/session/BumpFileVersion.c \
|
||||
common/net/message/SimpleInt64Msg.c \
|
||||
common/net/message/SimpleUInt16Msg.c \
|
||||
common/net/message/SimpleStringMsg.c \
|
||||
common/net/message/SimpleIntStringMsg.c \
|
||||
common/net/message/nodes/RegisterNodeMsg.c \
|
||||
common/net/message/nodes/RegisterNodeRespMsg.c \
|
||||
common/net/message/nodes/HeartbeatRequestMsgEx.c \
|
||||
common/net/message/nodes/MapTargetsMsgEx.c \
|
||||
common/net/message/nodes/GetTargetMappingsRespMsg.c \
|
||||
common/net/message/nodes/HeartbeatMsgEx.c \
|
||||
common/net/message/nodes/RemoveNodeMsgEx.c \
|
||||
common/net/message/nodes/GetStatesAndBuddyGroupsMsg.c \
|
||||
common/net/message/nodes/GetStatesAndBuddyGroupsRespMsg.c \
|
||||
common/net/message/nodes/RefreshTargetStatesMsgEx.c \
|
||||
common/net/message/nodes/GetNodesRespMsg.c \
|
||||
common/net/message/nodes/SetMirrorBuddyGroupMsgEx.c \
|
||||
common/net/message/SimpleMsg.c \
|
||||
common/net/message/storage/moving/RenameMsg.c \
|
||||
common/net/message/storage/StatStoragePathRespMsg.c \
|
||||
common/net/message/storage/creating/HardlinkMsg.c \
|
||||
common/net/message/storage/creating/MkFileMsg.c \
|
||||
common/net/message/storage/creating/MkDirMsg.c \
|
||||
common/net/message/storage/creating/UnlinkFileMsg.c \
|
||||
common/net/message/storage/creating/MkDirRespMsg.c \
|
||||
common/net/message/storage/creating/RmDirMsg.c \
|
||||
common/net/message/storage/creating/MkFileRespMsg.c \
|
||||
common/net/message/storage/attribs/StatRespMsg.c \
|
||||
common/net/message/storage/attribs/ListXAttrRespMsg.c \
|
||||
common/net/message/storage/attribs/SetAttrMsg.c \
|
||||
common/net/message/storage/attribs/ListXAttrMsg.c \
|
||||
common/net/message/storage/attribs/RefreshEntryInfoMsg.c \
|
||||
common/net/message/storage/attribs/StatMsg.c \
|
||||
common/net/message/storage/attribs/GetXAttrRespMsg.c \
|
||||
common/net/message/storage/attribs/GetXAttrMsg.c \
|
||||
common/net/message/storage/attribs/RemoveXAttrMsg.c \
|
||||
common/net/message/storage/attribs/SetXAttrMsg.c \
|
||||
common/net/message/storage/lookup/LookupIntentRespMsg.c \
|
||||
common/net/message/storage/lookup/LookupIntentMsg.c \
|
||||
common/net/message/storage/TruncFileMsg.c \
|
||||
common/net/message/storage/listing/ListDirFromOffsetRespMsg.c \
|
||||
common/net/message/storage/listing/ListDirFromOffsetMsg.c \
|
||||
common/threading/Thread.c \
|
||||
common/toolkit/Serialization.c \
|
||||
common/toolkit/MessagingTk.c \
|
||||
common/toolkit/HashTk.c \
|
||||
common/toolkit/ackstore/WaitAckMap.c \
|
||||
common/toolkit/ackstore/AcknowledgmentStore.c \
|
||||
common/toolkit/ackstore/AckStoreMap.c \
|
||||
common/toolkit/Random.c \
|
||||
common/toolkit/tree/IntMap.c \
|
||||
common/toolkit/tree/StrCpyMap.c \
|
||||
common/toolkit/tree/PointerRBTree.c \
|
||||
common/toolkit/NodesTk.c \
|
||||
common/toolkit/SocketTk.c \
|
||||
common/toolkit/MetadataTk.c \
|
||||
common/toolkit/StringTk.c \
|
||||
common/toolkit/ListTk.c \
|
||||
common/Types.c \
|
||||
common/nodes/Node.c \
|
||||
common/nodes/TargetMapper.c \
|
||||
common/nodes/MirrorBuddyGroup.c \
|
||||
common/nodes/NumNodeID.c \
|
||||
common/nodes/TargetStateStore.c \
|
||||
common/nodes/NodeTree.c \
|
||||
common/nodes/MirrorBuddyGroupMapper.c \
|
||||
common/nodes/NodeConnPool.c \
|
||||
common/storage/StorageErrors.c \
|
||||
common/storage/StatData.c \
|
||||
common/storage/striping/BuddyMirrorPattern.c \
|
||||
common/storage/striping/SimplePattern.c \
|
||||
common/storage/striping/StripePattern.c \
|
||||
common/storage/striping/Raid10Pattern.c \
|
||||
common/storage/striping/Raid0Pattern.c \
|
||||
common/storage/PathInfo.c \
|
||||
common/storage/RdmaInfo.c \
|
||||
common/storage/Nvfs.c \
|
||||
common/storage/EntryInfo.c \
|
||||
common/storage/StoragePoolId.c \
|
||||
common/storage/FileEvent.c \
|
||||
program/Main.c \
|
||||
toolkit/FhgfsChunkPageVec.c \
|
||||
toolkit/StatFsCache.c \
|
||||
toolkit/NoAllocBufferStore.c \
|
||||
toolkit/InodeRefStore.c \
|
||||
toolkit/BitStore.c \
|
||||
components/DatagramListener.c \
|
||||
components/InternodeSyncer.c \
|
||||
components/Flusher.c \
|
||||
components/worker/RWPagesWork.c \
|
||||
components/AckManager.c \
|
||||
nodes/NodeStoreEx.c \
|
||||
filesystem/ProcFs.c \
|
||||
filesystem/FhgfsOpsPages.c \
|
||||
filesystem/FhgfsOpsFile.c \
|
||||
filesystem/FhgfsOpsInode.c \
|
||||
filesystem/FhgfsOpsFileNative.c \
|
||||
filesystem/FhgfsInode.c \
|
||||
filesystem/helper/IoctlHelper.c \
|
||||
filesystem/FsFileInfo.c \
|
||||
filesystem/ProcFsHelper.c \
|
||||
filesystem/FhgfsOpsSuper.c \
|
||||
filesystem/FhgfsOps_versions.c \
|
||||
filesystem/FhgfsXAttrHandlers.c \
|
||||
filesystem/FhgfsOpsDir.c \
|
||||
filesystem/FhgfsOpsIoctl.c \
|
||||
filesystem/FhgfsOpsExport.c \
|
||||
filesystem/FhgfsOpsHelper.c \
|
||||
app/App.c \
|
||||
app/log/Logger.c \
|
||||
app/config/MountConfig.c \
|
||||
app/config/Config.c
|
||||
|
||||
${TARGET}-y := $(patsubst %.c,%.o,$(SOURCES))
|
||||
|
||||
ifdef BEEGFS_NO_RDMA
|
||||
ccflags-y += -DBEEGFS_NO_RDMA
|
||||
endif
|
||||
|
||||
ifneq ($(OFED_INCLUDE_PATH),)
|
||||
|
||||
# RHEL/CentOS 8 + MLNX 4.7 requires extra flags (bug?)
|
||||
ccflags-y += $(call kernel-if-version-or-later, 0418, -DHAVE_BITS_H)
|
||||
|
||||
NOSTDINC_FLAGS+=-I$(OFED_INCLUDE_PATH) -I$(OFED_INCLUDE_PATH)/uapi
|
||||
ifeq ($(shell [ -f $(OFED_INCLUDE_PATH)/linux/compat-2.6.h ] && echo 1),1)
|
||||
ccflags-y += -include $(OFED_INCLUDE_PATH)/linux/compat-2.6.h
|
||||
endif
|
||||
|
||||
endif
|
||||
1010
client_module/source/app/App.c
Normal file
1010
client_module/source/app/App.c
Normal file
File diff suppressed because it is too large
Load Diff
436
client_module/source/app/App.h
Normal file
436
client_module/source/app/App.h
Normal file
@@ -0,0 +1,436 @@
|
||||
#ifndef APP_H_
|
||||
#define APP_H_
|
||||
|
||||
#include <app/config/MountConfig.h>
|
||||
#include <common/toolkit/list/PointerListIter.h>
|
||||
#include <common/toolkit/list/StrCpyListIter.h>
|
||||
#include <common/toolkit/list/UInt16ListIter.h>
|
||||
#include <common/net/sock/NicAddressList.h>
|
||||
#include <common/threading/AtomicInt.h>
|
||||
#include <common/threading/Mutex.h>
|
||||
#include <common/threading/Thread.h>
|
||||
#include <common/Common.h>
|
||||
#include <toolkit/BitStore.h>
|
||||
|
||||
|
||||
// program return codes
|
||||
#define APPCODE_NO_ERROR 0
|
||||
#define APPCODE_PROGRAM_ERROR 1
|
||||
#define APPCODE_INVALID_CONFIG 2
|
||||
#define APPCODE_INITIALIZATION_ERROR 3
|
||||
#define APPCODE_RUNTIME_ERROR 4
|
||||
|
||||
// forward declarations
|
||||
struct Config;
|
||||
struct Logger;
|
||||
struct DatagramListener;
|
||||
struct InternodeSyncer;
|
||||
struct AckManager;
|
||||
struct Flusher;
|
||||
struct Node;
|
||||
struct NodeStoreEx;
|
||||
struct TargetMapper;
|
||||
struct MirrorBuddyGroupMapper;
|
||||
struct TargetStateStore;
|
||||
struct NoAllocBufferStore;
|
||||
struct AcknowledgmentStore;
|
||||
struct NetFilter;
|
||||
struct InodeRefStore;
|
||||
struct StatFsCache;
|
||||
|
||||
|
||||
|
||||
struct App;
|
||||
typedef struct App App;
|
||||
|
||||
|
||||
extern void App_init(App* this, MountConfig* mountConfig);
|
||||
extern void App_uninit(App* this);
|
||||
|
||||
extern int App_run(App* this);
|
||||
extern void App_stop(App* this);
|
||||
|
||||
extern bool __App_initDataObjects(App* this, MountConfig* mountConfig);
|
||||
extern bool __App_initInodeOperations(App* this);
|
||||
extern bool __App_initLocalNodeInfo(App* this);
|
||||
extern bool __App_initComponents(App* this);
|
||||
extern void __App_startComponents(App* this);
|
||||
extern void __App_stopComponents(App* this);
|
||||
extern void __App_joinComponents(App* this);
|
||||
extern void __App_waitForComponentTermination(App* this, Thread* component);
|
||||
|
||||
extern void __App_logInfos(App* this);
|
||||
|
||||
extern bool __App_mountServerCheck(App* this);
|
||||
|
||||
extern bool App_findAllowedInterfaces(App* this, NicAddressList* nicList);
|
||||
extern void App_findAllowedRDMAInterfaces(App* this, NicAddressList* nicList, NicAddressList* rdmaNicList);
|
||||
|
||||
// external getters & setters
|
||||
extern const char* App_getVersionStr(void);
|
||||
extern void App_updateLocalInterfaces(App* app, NicAddressList* nicList);
|
||||
extern char* App_cloneFsUUID(App* this);
|
||||
extern void App_updateFsUUID(App* this, const char* fsUUID);
|
||||
extern void App_cloneLocalNicList(App* this, NicAddressList* nicList);
|
||||
extern void App_cloneLocalRDMANicList(App* this, NicAddressList* rdmaNicList);
|
||||
|
||||
// inliners
|
||||
static inline struct Logger* App_getLogger(App* this);
|
||||
static inline struct Config* App_getConfig(App* this);
|
||||
static inline struct MountConfig* App_getMountConfig(App* this);
|
||||
static inline struct NetFilter* App_getNetFilter(App* this);
|
||||
static inline struct NetFilter* App_getTcpOnlyFilter(App* this);
|
||||
static inline NicAddressList* App_getLocalRDMANicListLocked(App* this);
|
||||
/**
|
||||
* Called when access to the nicList is required but doesn't
|
||||
* want the overhead of a clone operation. This locks the internel nicListMutex.
|
||||
* App_unlockNicList must later be invoked.
|
||||
*/
|
||||
static inline void App_lockNicList(App* this);
|
||||
/**
|
||||
* Release the lock on nicListMutex acquired by App_lockNicList.
|
||||
*/
|
||||
static inline void App_unlockNicList(App* this);
|
||||
static inline UInt16List* App_getPreferredStorageTargets(App* this);
|
||||
static inline UInt16List* App_getPreferredMetaNodes(App* this);
|
||||
static inline struct Node* App_getLocalNode(App* this);
|
||||
static inline struct NodeStoreEx* App_getMgmtNodes(App* this);
|
||||
static inline struct NodeStoreEx* App_getMetaNodes(App* this);
|
||||
static inline struct NodeStoreEx* App_getStorageNodes(App* this);
|
||||
static inline struct TargetMapper* App_getTargetMapper(App* this);
|
||||
static inline struct MirrorBuddyGroupMapper* App_getStorageBuddyGroupMapper(App* this);
|
||||
static inline struct MirrorBuddyGroupMapper* App_getMetaBuddyGroupMapper(App* this);
|
||||
static inline struct TargetStateStore* App_getTargetStateStore(App* this);
|
||||
static inline struct TargetStateStore* App_getMetaStateStore(App* this);
|
||||
static inline struct NoAllocBufferStore* App_getCacheBufStore(App* this);
|
||||
static inline struct NoAllocBufferStore* App_getPathBufStore(App* this);
|
||||
static inline struct NoAllocBufferStore* App_getMsgBufStore(App* this);
|
||||
static inline struct AcknowledgmentStore* App_getAckStore(App* this);
|
||||
static inline struct InodeRefStore* App_getInodeRefStore(App* this);
|
||||
static inline struct StatFsCache* App_getStatFsCache(App* this);
|
||||
static inline struct DatagramListener* App_getDatagramListener(App* this);
|
||||
static inline struct InternodeSyncer* App_getInternodeSyncer(App* this);
|
||||
static inline struct AckManager* App_getAckManager(App* this);
|
||||
static inline AtomicInt* App_getLockAckAtomicCounter(App* this);
|
||||
static inline bool App_getConnRetriesEnabled(App* this);
|
||||
static inline void App_setConnRetriesEnabled(App* this, bool connRetriesEnabled);
|
||||
static inline bool App_getNetBenchModeEnabled(App* this);
|
||||
static inline void App_setNetBenchModeEnabled(App* this, bool netBenchModeEnabled);
|
||||
|
||||
static inline struct inode_operations* App_getFileInodeOps(App* this);
|
||||
static inline struct inode_operations* App_getSymlinkInodeOps(App* this);
|
||||
static inline struct inode_operations* App_getDirInodeOps(App* this);
|
||||
static inline struct inode_operations* App_getSpecialInodeOps(App* this);
|
||||
|
||||
#ifdef BEEGFS_DEBUG
|
||||
static inline size_t App_getNumRPCs(App* this);
|
||||
static inline void App_incNumRPCs(App* this);
|
||||
static inline size_t App_getNumRemoteReads(App* this);
|
||||
static inline void App_incNumRemoteReads(App* this);
|
||||
static inline size_t App_getNumRemoteWrites(App* this);
|
||||
static inline void App_incNumRemoteWrites(App* this);
|
||||
#endif // BEEGFS_DEBUG
|
||||
|
||||
|
||||
struct App
|
||||
{
|
||||
int appResult;
|
||||
MountConfig* mountConfig;
|
||||
|
||||
struct Config* cfg;
|
||||
struct Logger* logger;
|
||||
const char* fsUUID;
|
||||
Mutex fsUUIDMutex;
|
||||
|
||||
struct NetFilter* netFilter; // empty filter means "all nets allowed"
|
||||
struct NetFilter* tcpOnlyFilter; // for IPs which allow only plain TCP (no RDMA etc)
|
||||
StrCpyList allowedInterfaces; // empty list means "all interfaces accepted"
|
||||
StrCpyList allowedRDMAInterfaces; // empty list means "all interfaces eligible"
|
||||
UInt16List preferredMetaNodes; // empty list means "no preferred nodes => use any"
|
||||
UInt16List preferredStorageTargets; // empty list means "no preferred nodes => use any"
|
||||
// rdmaNicList contains the addresses of specific RDMA NICs to use for outbound RDMA.
|
||||
// This is only populated when the configuration specifies a list of interfaces. If this
|
||||
// list is empty, any RDMA NIC on the client may be used for outbound RDMA.
|
||||
// allowedRDMAInterfaces contains the interface names used to populate this list.
|
||||
NicAddressList rdmaNicList;
|
||||
Mutex nicListMutex;
|
||||
|
||||
struct Node* localNode;
|
||||
struct NodeStoreEx* mgmtNodes;
|
||||
struct NodeStoreEx* metaNodes;
|
||||
struct NodeStoreEx* storageNodes;
|
||||
|
||||
struct TargetMapper* targetMapper;
|
||||
struct MirrorBuddyGroupMapper* storageBuddyGroupMapper;
|
||||
struct MirrorBuddyGroupMapper* metaBuddyGroupMapper;
|
||||
struct TargetStateStore* targetStateStore; // map storage targets IDs to a state
|
||||
struct TargetStateStore* metaStateStore; // map mds targets (i.e. nodeIDs) to a state
|
||||
|
||||
struct NoAllocBufferStore* cacheBufStore; // for buffered cache mode
|
||||
struct NoAllocBufferStore* pathBufStore; // for dentry path lookups
|
||||
struct NoAllocBufferStore* msgBufStore; // for MessagingTk request/response
|
||||
struct AcknowledgmentStore* ackStore;
|
||||
struct InodeRefStore* inodeRefStore;
|
||||
struct StatFsCache* statfsCache;
|
||||
|
||||
struct DatagramListener* dgramListener;
|
||||
struct InternodeSyncer* internodeSyncer;
|
||||
struct AckManager* ackManager;
|
||||
struct Flusher* flusher;
|
||||
|
||||
AtomicInt lockAckAtomicCounter; // used by remoting to generate unique lockAckIDs
|
||||
volatile bool connRetriesEnabled; // changed at umount and via procfs
|
||||
bool netBenchModeEnabled; // changed via procfs to disable server-side disk read/write
|
||||
|
||||
// Inode operations. Since the members of the structs depend on runtime config opts, we need
|
||||
// one copy of each struct per App object.
|
||||
struct inode_operations* fileInodeOps;
|
||||
struct inode_operations* symlinkInodeOps;
|
||||
struct inode_operations* dirInodeOps;
|
||||
struct inode_operations* specialInodeOps;
|
||||
|
||||
#ifdef BEEGFS_DEBUG
|
||||
Mutex debugCounterMutex; // this is the closed tree, so we don't have atomics here (but doesn't
|
||||
// matter since this is debug info and not performance critical)
|
||||
|
||||
size_t numRPCs;
|
||||
size_t numRemoteReads;
|
||||
size_t numRemoteWrites;
|
||||
#endif // BEEGFS_DEBUG
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct Logger* App_getLogger(App* this)
|
||||
{
|
||||
return this->logger;
|
||||
}
|
||||
|
||||
struct Config* App_getConfig(App* this)
|
||||
{
|
||||
return this->cfg;
|
||||
}
|
||||
|
||||
struct MountConfig* App_getMountConfig(App* this)
|
||||
{
|
||||
return this->mountConfig;
|
||||
}
|
||||
|
||||
struct NetFilter* App_getNetFilter(App* this)
|
||||
{
|
||||
return this->netFilter;
|
||||
}
|
||||
|
||||
struct NetFilter* App_getTcpOnlyFilter(App* this)
|
||||
{
|
||||
return this->tcpOnlyFilter;
|
||||
}
|
||||
|
||||
UInt16List* App_getPreferredMetaNodes(App* this)
|
||||
{
|
||||
return &this->preferredMetaNodes;
|
||||
}
|
||||
|
||||
UInt16List* App_getPreferredStorageTargets(App* this)
|
||||
{
|
||||
return &this->preferredStorageTargets;
|
||||
}
|
||||
|
||||
void App_lockNicList(App* this)
|
||||
{
|
||||
Mutex_lock(&this->nicListMutex); // L O C K
|
||||
}
|
||||
|
||||
void App_unlockNicList(App* this)
|
||||
{
|
||||
Mutex_unlock(&this->nicListMutex); // U N L O C K
|
||||
}
|
||||
|
||||
NicAddressList* App_getLocalRDMANicListLocked(App* this)
|
||||
{
|
||||
return &this->rdmaNicList;
|
||||
}
|
||||
|
||||
struct Node* App_getLocalNode(App* this)
|
||||
{
|
||||
return this->localNode;
|
||||
}
|
||||
|
||||
struct NodeStoreEx* App_getMgmtNodes(App* this)
|
||||
{
|
||||
return this->mgmtNodes;
|
||||
}
|
||||
|
||||
struct NodeStoreEx* App_getMetaNodes(App* this)
|
||||
{
|
||||
return this->metaNodes;
|
||||
}
|
||||
|
||||
struct NodeStoreEx* App_getStorageNodes(App* this)
|
||||
{
|
||||
return this->storageNodes;
|
||||
}
|
||||
|
||||
struct TargetMapper* App_getTargetMapper(App* this)
|
||||
{
|
||||
return this->targetMapper;
|
||||
}
|
||||
|
||||
struct MirrorBuddyGroupMapper* App_getStorageBuddyGroupMapper(App* this)
|
||||
{
|
||||
return this->storageBuddyGroupMapper;
|
||||
}
|
||||
|
||||
struct MirrorBuddyGroupMapper* App_getMetaBuddyGroupMapper(App* this)
|
||||
{
|
||||
return this->metaBuddyGroupMapper;
|
||||
}
|
||||
|
||||
struct TargetStateStore* App_getTargetStateStore(App* this)
|
||||
{
|
||||
return this->targetStateStore;
|
||||
}
|
||||
|
||||
struct TargetStateStore* App_getMetaStateStore(App* this)
|
||||
{
|
||||
return this->metaStateStore;
|
||||
}
|
||||
|
||||
struct NoAllocBufferStore* App_getCacheBufStore(App* this)
|
||||
{
|
||||
return this->cacheBufStore;
|
||||
}
|
||||
|
||||
struct NoAllocBufferStore* App_getPathBufStore(App* this)
|
||||
{
|
||||
return this->pathBufStore;
|
||||
}
|
||||
|
||||
struct NoAllocBufferStore* App_getMsgBufStore(App* this)
|
||||
{
|
||||
return this->msgBufStore;
|
||||
}
|
||||
|
||||
struct AcknowledgmentStore* App_getAckStore(App* this)
|
||||
{
|
||||
return this->ackStore;
|
||||
}
|
||||
|
||||
struct InodeRefStore* App_getInodeRefStore(App* this)
|
||||
{
|
||||
return this->inodeRefStore;
|
||||
}
|
||||
|
||||
struct StatFsCache* App_getStatFsCache(App* this)
|
||||
{
|
||||
return this->statfsCache;
|
||||
}
|
||||
|
||||
struct DatagramListener* App_getDatagramListener(App* this)
|
||||
{
|
||||
return this->dgramListener;
|
||||
}
|
||||
|
||||
struct InternodeSyncer* App_getInternodeSyncer(App* this)
|
||||
{
|
||||
return this->internodeSyncer;
|
||||
}
|
||||
|
||||
struct AckManager* App_getAckManager(App* this)
|
||||
{
|
||||
return this->ackManager;
|
||||
}
|
||||
|
||||
AtomicInt* App_getLockAckAtomicCounter(App* this)
|
||||
{
|
||||
return &this->lockAckAtomicCounter;
|
||||
}
|
||||
|
||||
bool App_getConnRetriesEnabled(App* this)
|
||||
{
|
||||
return this->connRetriesEnabled;
|
||||
}
|
||||
|
||||
void App_setConnRetriesEnabled(App* this, bool connRetriesEnabled)
|
||||
{
|
||||
this->connRetriesEnabled = connRetriesEnabled;
|
||||
}
|
||||
|
||||
bool App_getNetBenchModeEnabled(App* this)
|
||||
{
|
||||
return this->netBenchModeEnabled;
|
||||
}
|
||||
|
||||
void App_setNetBenchModeEnabled(App* this, bool netBenchModeEnabled)
|
||||
{
|
||||
this->netBenchModeEnabled = netBenchModeEnabled;
|
||||
}
|
||||
|
||||
struct inode_operations* App_getFileInodeOps(App* this)
|
||||
{
|
||||
return this->fileInodeOps;
|
||||
}
|
||||
|
||||
struct inode_operations* App_getSymlinkInodeOps(App* this)
|
||||
{
|
||||
return this->symlinkInodeOps;
|
||||
}
|
||||
|
||||
struct inode_operations* App_getDirInodeOps(App* this)
|
||||
{
|
||||
return this->dirInodeOps;
|
||||
}
|
||||
|
||||
struct inode_operations* App_getSpecialInodeOps(App* this)
|
||||
{
|
||||
return this->specialInodeOps;
|
||||
}
|
||||
|
||||
#ifdef BEEGFS_DEBUG
|
||||
|
||||
size_t App_getNumRPCs(App* this)
|
||||
{
|
||||
return this->numRPCs;
|
||||
}
|
||||
|
||||
void App_incNumRPCs(App* this)
|
||||
{
|
||||
Mutex_lock(&this->debugCounterMutex);
|
||||
this->numRPCs++;
|
||||
Mutex_unlock(&this->debugCounterMutex);
|
||||
}
|
||||
|
||||
size_t App_getNumRemoteReads(App* this)
|
||||
{
|
||||
return this->numRemoteReads;
|
||||
}
|
||||
|
||||
void App_incNumRemoteReads(App* this)
|
||||
{
|
||||
Mutex_lock(&this->debugCounterMutex);
|
||||
this->numRemoteReads++;
|
||||
Mutex_unlock(&this->debugCounterMutex);
|
||||
}
|
||||
|
||||
size_t App_getNumRemoteWrites(App* this)
|
||||
{
|
||||
return this->numRemoteWrites;
|
||||
}
|
||||
|
||||
void App_incNumRemoteWrites(App* this)
|
||||
{
|
||||
Mutex_lock(&this->debugCounterMutex);
|
||||
this->numRemoteWrites++;
|
||||
Mutex_unlock(&this->debugCounterMutex);
|
||||
}
|
||||
|
||||
#else // BEEGFS_DEBUG
|
||||
|
||||
#define App_incNumRPCs(this)
|
||||
#define App_incNumRemoteReads(this)
|
||||
#define App_incNumRemoteWrites(this)
|
||||
|
||||
#endif // BEEGFS_DEBUG
|
||||
|
||||
|
||||
#endif /*APP_H_*/
|
||||
1557
client_module/source/app/config/Config.c
Normal file
1557
client_module/source/app/config/Config.c
Normal file
File diff suppressed because it is too large
Load Diff
758
client_module/source/app/config/Config.h
Normal file
758
client_module/source/app/config/Config.h
Normal file
@@ -0,0 +1,758 @@
|
||||
#ifndef CONFIG_H_
|
||||
#define CONFIG_H_
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/toolkit/list/StrCpyListIter.h>
|
||||
#include <common/toolkit/list/UInt16ListIter.h>
|
||||
#include <common/toolkit/tree/StrCpyMap.h>
|
||||
#include <common/toolkit/tree/StrCpyMapIter.h>
|
||||
#include <common/toolkit/StringTk.h>
|
||||
#include <app/config/MountConfig.h>
|
||||
|
||||
|
||||
struct Config;
|
||||
typedef struct Config Config;
|
||||
|
||||
enum FileCacheType;
|
||||
typedef enum FileCacheType FileCacheType;
|
||||
|
||||
enum InodeIDStyle;
|
||||
typedef enum InodeIDStyle InodeIDStyle;
|
||||
|
||||
enum RDMAKeyType;
|
||||
typedef enum RDMAKeyType RDMAKeyType;
|
||||
|
||||
enum CheckCapabilities;
|
||||
typedef enum CheckCapabilities CheckCapabilities;
|
||||
|
||||
enum EventLogMask
|
||||
{
|
||||
EventLogMask_NONE = 0,
|
||||
EventLogMask_FLUSH = 1,
|
||||
EventLogMask_TRUNC = 2,
|
||||
EventLogMask_SETATTR = 4,
|
||||
EventLogMask_CLOSE = 8,
|
||||
EventLogMask_LINK_OP = 16,
|
||||
EventLogMask_OPEN_READ = 32,
|
||||
EventLogMask_OPEN_WRITE = 64,
|
||||
EventLogMask_OPEN_READ_WRITE = 128
|
||||
};
|
||||
|
||||
|
||||
extern __must_check bool Config_init(Config* this, MountConfig* mountConfig);
|
||||
extern Config* Config_construct(MountConfig* mountConfig);
|
||||
extern void Config_uninit(Config* this);
|
||||
extern void Config_destruct(Config* this);
|
||||
|
||||
extern bool _Config_initConfig(Config* this, MountConfig* mountConfig);
|
||||
extern StrCpyMapIter _Config_eraseFromConfigMap(Config* this, StrCpyMapIter* iter);
|
||||
extern void _Config_loadDefaults(Config* this);
|
||||
extern bool _Config_applyConfigMap(Config* this);
|
||||
extern void _Config_configMapRedefine(Config* this, char* keyStr, const char* valueStr);
|
||||
extern void __Config_addLineToConfigMap(Config* this, char* line);
|
||||
|
||||
extern void __Config_loadFromMountConfig(Config* this, MountConfig* mountConfig);
|
||||
extern bool __Config_loadFromFile(struct Config* this, const char* filename);
|
||||
extern bool Config_loadStringListFile(const char* filename,
|
||||
StrCpyList* outList);
|
||||
extern bool Config_loadUInt16ListFile(struct Config* this, const char* filename,
|
||||
UInt16List* outList);
|
||||
|
||||
extern bool __Config_initImplicitVals(Config* this);
|
||||
extern void __Config_initConnNumCommRetries(Config* this);
|
||||
extern void __Config_initTuneFileCacheTypeNum(Config* this);
|
||||
void __Config_initSysInodeIDStyleNum(Config* this);
|
||||
bool __Config_initConnAuthHash(Config* this, char* connAuthFile, uint64_t* outConnAuthHash);
|
||||
void __Config_initConnRDMAKeyTypeNum(Config* this);
|
||||
|
||||
// conversion
|
||||
const char* Config_fileCacheTypeNumToStr(FileCacheType cacheType);
|
||||
const char* Config_inodeIDStyleNumToStr(InodeIDStyle inodeIDStyle);
|
||||
const char* Config_eventLogMaskToStr(enum EventLogMask mask);
|
||||
const char* Config_rdmaKeyTypeNumToStr(RDMAKeyType keyType);
|
||||
const char* Config_checkCapabilitiesTypeToStr(CheckCapabilities checkCapabilities);
|
||||
|
||||
// getters & setters
|
||||
static inline char* Config_getCfgFile(Config* this);
|
||||
static inline int Config_getLogLevel(Config* this);
|
||||
static inline bool Config_getLogClientID(Config* this);
|
||||
static inline bool Config_getConnUseRDMA(Config* this);
|
||||
static inline bool Config_getConnTCPFallbackEnabled(Config* this);
|
||||
static inline int Config_getConnClientPort(Config* this);
|
||||
static inline int Config_getConnMgmtdPort(Config* this);
|
||||
static inline int Config_getConnMgmtdGrpcPort(Config* this);
|
||||
static inline void Config_setConnMgmtdGrpcPort(Config* this, int port);
|
||||
static inline unsigned Config_getConnMaxInternodeNum(Config* this);
|
||||
static inline char* Config_getConnInterfacesFile(Config* this);
|
||||
static inline char* Config_getConnInterfacesList(Config* this);
|
||||
static inline char* Config_getConnRDMAInterfacesFile(Config* this);
|
||||
static inline unsigned Config_getConnFallbackExpirationSecs(Config* this);
|
||||
static inline unsigned Config_getConnNumCommRetries(Config* this);
|
||||
static inline unsigned Config_getConnCommRetrySecs(Config* this);
|
||||
static inline bool Config_getConnUnmountRetries(Config* this);
|
||||
static inline int Config_getConnTCPRcvBufSize(Config* this);
|
||||
static inline int Config_getConnUDPRcvBufSize(Config* this);
|
||||
static inline unsigned Config_getConnRDMABufSize(Config* this);
|
||||
static inline unsigned Config_getConnRDMAFragmentSize(Config* this);
|
||||
static inline unsigned Config_getConnRDMABufNum(Config* this);
|
||||
static inline unsigned Config_getConnRDMAMetaBufSize(Config* this);
|
||||
static inline unsigned Config_getConnRDMAMetaBufNum(Config* this);
|
||||
static inline unsigned Config_getConnRDMAMetaFragmentSize(Config* this);
|
||||
static inline char* Config_getConnRDMAKeyType(Config* this);
|
||||
static inline RDMAKeyType Config_getConnRDMAKeyTypeNum(Config* this);
|
||||
static inline int Config_getConnRDMATypeOfService(Config* this);
|
||||
static inline unsigned Config_getRemapConnectionFailureStatus(Config* this);
|
||||
static inline void Config_setRemapConnectionFailureStatus(Config* this, unsigned status);
|
||||
static inline char* Config_getConnNetFilterFile(Config* this);
|
||||
static inline unsigned Config_getConnMaxConcurrentAttempts(Config* this);
|
||||
static inline char* Config_getConnAuthFile(Config* this);
|
||||
static inline bool Config_getConnDisableAuthentication(Config* this);
|
||||
static inline uint64_t Config_getConnAuthHash(Config* this);
|
||||
static inline char* Config_getConnTcpOnlyFilterFile(Config* this);
|
||||
static inline char* Config_getTunePreferredMetaFile(Config* this);
|
||||
static inline char* Config_getTunePreferredStorageFile(Config* this);
|
||||
static inline char* Config_getTuneFileCacheType(Config* this);
|
||||
static inline FileCacheType Config_getTuneFileCacheTypeNum(Config* this);
|
||||
static inline int Config_getTuneFileCacheBufSize(Config* this);
|
||||
static inline int Config_getTuneFileCacheBufNum(Config* this);
|
||||
static inline int Config_getTunePathBufSize(Config* this);
|
||||
static inline int Config_getTunePathBufNum(Config* this);
|
||||
static inline int Config_getTuneMsgBufSize(Config* this);
|
||||
static inline int Config_getTuneMsgBufNum(Config* this);
|
||||
static inline unsigned Config_getTunePageCacheValidityMS(Config* this);
|
||||
static inline unsigned Config_getTuneDirSubentryCacheValidityMS(Config* this);
|
||||
static inline unsigned Config_getTuneFileSubentryCacheValidityMS(Config* this);
|
||||
static inline unsigned Config_getTuneENOENTCacheValidityMS(Config* this);
|
||||
static inline bool Config_getTuneRemoteFSync(Config* this);
|
||||
static inline bool Config_getTuneUseGlobalFileLocks(Config* this);
|
||||
static inline bool Config_getTuneRefreshOnGetAttr(Config* this);
|
||||
static inline void Config_setTuneRefreshOnGetAttr(Config* this);
|
||||
static inline unsigned Config_getTuneInodeBlockBits(Config* this);
|
||||
static inline unsigned Config_getTuneInodeBlockSize(Config* this);
|
||||
static inline bool Config_getTuneEarlyCloseResponse(Config* this);
|
||||
static inline bool Config_getTuneUseGlobalAppendLocks(Config* this);
|
||||
static inline bool Config_getTuneUseBufferedAppend(Config* this);
|
||||
static inline unsigned Config_getTuneStatFsCacheSecs(Config* this);
|
||||
static inline bool Config_getTuneCoherentBuffers(Config* this);
|
||||
|
||||
static inline char* Config_getSysMgmtdHost(Config* this);
|
||||
static inline char* Config_getSysInodeIDStyle(Config* this);
|
||||
static inline InodeIDStyle Config_getSysInodeIDStyleNum(Config* this);
|
||||
static inline bool Config_getSysCacheInvalidationVersion(Config* this);
|
||||
static inline bool Config_getSysCreateHardlinksAsSymlinks(Config* this);
|
||||
static inline unsigned Config_getSysMountSanityCheckMS(Config* this);
|
||||
static inline bool Config_getSysSyncOnClose(Config* this);
|
||||
static inline bool Config_getSysSessionCheckOnClose(Config* this);
|
||||
static inline bool Config_getSysSessionChecksEnabled(Config* this);
|
||||
static inline unsigned Config_getSysUpdateTargetStatesSecs(Config* this);
|
||||
static inline unsigned Config_getSysTargetOfflineTimeoutSecs(Config* this);
|
||||
static inline bool Config_getSysXAttrsEnabled(Config* this);
|
||||
static inline CheckCapabilities Config_getSysXAttrsCheckCapabilities (Config* this);
|
||||
static inline bool Config_getSysACLsEnabled(Config* this);
|
||||
static inline bool Config_getSysXAttrsImplicitlyEnabled(Config* this);
|
||||
static inline bool Config_getSysBypassFileAccessCheckOnMeta(Config* this);
|
||||
|
||||
static inline bool Config_getQuotaEnabled(Config* this);
|
||||
static inline char* Config_getConnMessagingTimeouts(Config* this);
|
||||
static inline char* Config_getConnRDMATimeouts(Config* this);
|
||||
static inline int Config_getConnRDMATimeoutConnect(Config* this);
|
||||
static inline int Config_getConnRDMATimeoutCompletion(Config* this);
|
||||
static inline int Config_getConnRDMATimeoutFlowSend(Config* this);
|
||||
static inline int Config_getConnRDMATimeoutFlowRecv(Config* this);
|
||||
static inline int Config_getConnRDMATimeoutPoll(Config* this);
|
||||
|
||||
|
||||
enum FileCacheType
|
||||
{ FILECACHETYPE_None = 0, FILECACHETYPE_Buffered = 1, FILECACHETYPE_Paged = 2,
|
||||
FILECACHETYPE_Native = 3};
|
||||
|
||||
|
||||
#define INODEIDSTYLE_HASH32HSIEH_STR "hash32"
|
||||
#define INODEIDSTYLE_HASH64HSIEH_STR "hash64"
|
||||
#define INODEIDSTYLE_HASH32MD4_STR "md4hash32"
|
||||
#define INODEIDSTYLE_HASH64MD4_STR "md4hash64"
|
||||
#define INODEIDSTYLE_DEFAULT INODEIDSTYLE_HASH64MD4_STR
|
||||
|
||||
enum InodeIDStyle
|
||||
{
|
||||
INODEIDSTYLE_Hash32Hsieh = 0, // hsieh32
|
||||
INODEIDSTYLE_Hash32MD4, // half-md4
|
||||
INODEIDSTYLE_Hash64HSieh, // hsieh32
|
||||
INODEIDSTYLE_Hash64MD4 // half-md4
|
||||
};
|
||||
#define INODEIDSTYLE_Default INODEIDSTYLE_Hash64MD4
|
||||
|
||||
#define RDMAKEYTYPE_UNSAFE_GLOBAL_STR "global"
|
||||
#define RDMAKEYTYPE_UNSAFE_DMA_STR "dma"
|
||||
#define RDMAKEYTYPE_REGISTER_STR "register"
|
||||
|
||||
enum RDMAKeyType
|
||||
{
|
||||
RDMAKEYTYPE_UnsafeGlobal = 0,
|
||||
RDMAKEYTYPE_UnsafeDMA,
|
||||
RDMAKEYTYPE_Register
|
||||
};
|
||||
|
||||
#define CHECKCAPABILITIES_ALWAYS_STR "always"
|
||||
#define CHECKCAPABILITIES_CACHE_STR "cache"
|
||||
#define CHECKCAPABILITIES_NEVER_STR "never"
|
||||
|
||||
enum CheckCapabilities
|
||||
{
|
||||
CHECKCAPABILITIES_Always = 0,
|
||||
CHECKCAPABILITIES_Cache,
|
||||
CHECKCAPABILITIES_Never
|
||||
};
|
||||
|
||||
struct Config
|
||||
{
|
||||
// configurables
|
||||
char* cfgFile;
|
||||
|
||||
int logLevel;
|
||||
bool logClientID;
|
||||
|
||||
int connPortShift; // shifts all UDP and TCP ports
|
||||
int connClientPort;
|
||||
int connMgmtdPort;
|
||||
int connMgmtdGrpcPort; // pulled from mgmtd and not meant to be configured by the user
|
||||
bool connUseRDMA;
|
||||
bool connTCPFallbackEnabled;
|
||||
unsigned connMaxInternodeNum;
|
||||
char* connInterfacesFile;
|
||||
char* connInterfacesList;
|
||||
char* connRDMAInterfacesFile;
|
||||
unsigned connFallbackExpirationSecs;
|
||||
unsigned connNumCommRetries; // auto-computed from connCommRetrySecs
|
||||
unsigned connCommRetrySecs;
|
||||
bool connUnmountRetries;
|
||||
int connTCPRcvBufSize;
|
||||
int connUDPRcvBufSize;
|
||||
int connRDMABufSize;
|
||||
int connRDMAFragmentSize;
|
||||
int connRDMABufNum;
|
||||
int connRDMAMetaBufSize;
|
||||
int connRDMAMetaFragmentSize;
|
||||
int connRDMAMetaBufNum;
|
||||
int connRDMATypeOfService;
|
||||
char* connRDMAKeyType;
|
||||
RDMAKeyType connRDMAKeyTypeNum;
|
||||
char* connNetFilterFile; // allowed IP addresses (all IPs allowed, if empty)
|
||||
unsigned connMaxConcurrentAttempts;
|
||||
char* connAuthFile;
|
||||
bool connDisableAuthentication;
|
||||
uint64_t connAuthHash; // implicitly set based on hash of connAuthFile contents
|
||||
char* connTcpOnlyFilterFile; // allow only plain TCP (no RDMA etc) to these IPs
|
||||
|
||||
char* connMessagingTimeouts;
|
||||
int connMsgLongTimeout;
|
||||
int connMsgMediumTimeout;
|
||||
int connMsgShortTimeout; // connection (response) timeouts in ms
|
||||
// note: be careful here, because servers not
|
||||
// responding for >30secs under high load is nothing
|
||||
// unusual, so never use connMsgShortTimeout for
|
||||
// IO-related operations.
|
||||
char* connRDMATimeouts;
|
||||
int connRDMATimeoutConnect;
|
||||
int connRDMATimeoutCompletion;
|
||||
int connRDMATimeoutFlowSend;
|
||||
int connRDMATimeoutFlowRecv;
|
||||
int connRDMATimeoutPoll;
|
||||
|
||||
char* tunePreferredMetaFile;
|
||||
char* tunePreferredStorageFile;
|
||||
char* tuneFileCacheType;
|
||||
FileCacheType tuneFileCacheTypeNum; // auto-generated based on tuneFileCacheType
|
||||
int tuneFileCacheBufSize;
|
||||
int tuneFileCacheBufNum; // 0 means automatic setting
|
||||
unsigned tunePageCacheValidityMS;
|
||||
unsigned tuneDirSubentryCacheValidityMS;
|
||||
unsigned tuneFileSubentryCacheValidityMS;
|
||||
unsigned tuneENOENTCacheValidityMS;
|
||||
int tunePathBufSize;
|
||||
int tunePathBufNum;
|
||||
int tuneMsgBufSize;
|
||||
int tuneMsgBufNum; // 0 means automatic setting
|
||||
bool tuneRemoteFSync;
|
||||
bool tuneUseGlobalFileLocks; // false means local flock/fcntl locks
|
||||
bool tuneRefreshOnGetAttr; // false means don't refresh on getattr
|
||||
unsigned tuneInodeBlockBits; // bitshift for optimal io size seen by stat() (2^n)
|
||||
unsigned tuneInodeBlockSize; // auto-generated based on tuneInodeBlockBits
|
||||
bool tuneEarlyCloseResponse; // don't wait for chunk files close result
|
||||
bool tuneUseGlobalAppendLocks; // false means local append locks
|
||||
bool tuneUseBufferedAppend; // false disables buffering of append writes
|
||||
unsigned tuneStatFsCacheSecs; // 0 disables caching of free space info from servers
|
||||
bool tuneCoherentBuffers; // try to keep buffer cache and page cache coherent
|
||||
|
||||
char* sysMgmtdHost;
|
||||
char* sysInodeIDStyle;
|
||||
InodeIDStyle sysInodeIDStyleNum; // auto-generated based on sysInodeIDStyle
|
||||
bool sysCacheInvalidationVersion;
|
||||
bool sysCreateHardlinksAsSymlinks;
|
||||
unsigned sysMountSanityCheckMS;
|
||||
bool sysSyncOnClose;
|
||||
bool sysSessionCheckOnClose;
|
||||
bool sysSessionChecksEnabled;
|
||||
unsigned sysUpdateTargetStatesSecs;
|
||||
unsigned sysTargetOfflineTimeoutSecs;
|
||||
|
||||
bool sysXAttrsEnabled;
|
||||
CheckCapabilities sysXAttrsCheckCapabilities;
|
||||
bool sysACLsEnabled;
|
||||
bool sysXAttrsImplicitlyEnabled; // True when XAttrs have not been enabled in the config file
|
||||
// but have been enabled by __Config_initImplicitVals
|
||||
// because ACLs are enabled in the config and XAs are needed
|
||||
// to store the ACLs.
|
||||
bool sysBypassFileAccessCheckOnMeta; // bypass file access check on meta server
|
||||
|
||||
bool quotaEnabled;
|
||||
enum EventLogMask eventLogMask;
|
||||
|
||||
/* workaround for rename of closed files on nfs */
|
||||
bool sysRenameEbusyAsXdev;
|
||||
|
||||
|
||||
// internals
|
||||
StrCpyMap configMap;
|
||||
|
||||
// testing
|
||||
unsigned remapConnectionFailureStatus;
|
||||
};
|
||||
|
||||
char* Config_getCfgFile(Config* this)
|
||||
{
|
||||
return this->cfgFile;
|
||||
}
|
||||
|
||||
int Config_getLogLevel(Config* this)
|
||||
{
|
||||
return this->logLevel;
|
||||
}
|
||||
|
||||
bool Config_getLogClientID(Config* this)
|
||||
{
|
||||
return this->logClientID;
|
||||
}
|
||||
|
||||
int Config_getConnClientPort(Config* this)
|
||||
{
|
||||
return this->connClientPort ? (this->connClientPort + this->connPortShift) : 0;
|
||||
}
|
||||
|
||||
int Config_getConnMgmtdPort(Config* this)
|
||||
{
|
||||
return this->connMgmtdPort ? (this->connMgmtdPort + this->connPortShift) : 0;
|
||||
}
|
||||
|
||||
int Config_getConnMgmtdGrpcPort(Config* this)
|
||||
{
|
||||
// not adding port shift here because connMgmtdGrpcPort is pulled from mgmtd and already shifted
|
||||
return this->connMgmtdGrpcPort ? this->connMgmtdGrpcPort : 0;
|
||||
}
|
||||
|
||||
void Config_setConnMgmtdGrpcPort(Config* this, int port)
|
||||
{
|
||||
this->connMgmtdGrpcPort = port;
|
||||
}
|
||||
|
||||
bool Config_getConnUseRDMA(Config* this)
|
||||
{
|
||||
return this->connUseRDMA;
|
||||
}
|
||||
|
||||
bool Config_getConnTCPFallbackEnabled(Config* this)
|
||||
{
|
||||
return this->connTCPFallbackEnabled;
|
||||
}
|
||||
|
||||
unsigned Config_getConnMaxInternodeNum(Config* this)
|
||||
{
|
||||
return this->connMaxInternodeNum;
|
||||
}
|
||||
|
||||
char* Config_getConnInterfacesFile(Config* this)
|
||||
{
|
||||
return this->connInterfacesFile;
|
||||
}
|
||||
|
||||
char* Config_getConnInterfacesList(Config* this)
|
||||
{
|
||||
return this->connInterfacesList;
|
||||
}
|
||||
|
||||
char* Config_getConnRDMAInterfacesFile(Config* this)
|
||||
{
|
||||
return this->connRDMAInterfacesFile;
|
||||
}
|
||||
|
||||
unsigned Config_getConnFallbackExpirationSecs(Config* this)
|
||||
{
|
||||
return this->connFallbackExpirationSecs;
|
||||
}
|
||||
|
||||
unsigned Config_getConnNumCommRetries(Config* this)
|
||||
{
|
||||
return this->connNumCommRetries;
|
||||
}
|
||||
|
||||
unsigned Config_getConnCommRetrySecs(Config* this)
|
||||
{
|
||||
return this->connCommRetrySecs;
|
||||
}
|
||||
|
||||
bool Config_getConnUnmountRetries(Config* this)
|
||||
{
|
||||
return this->connUnmountRetries;
|
||||
}
|
||||
|
||||
int Config_getConnTCPRcvBufSize(Config* this)
|
||||
{
|
||||
return this->connTCPRcvBufSize;
|
||||
}
|
||||
|
||||
int Config_getConnUDPRcvBufSize(Config* this)
|
||||
{
|
||||
return this->connUDPRcvBufSize;
|
||||
}
|
||||
|
||||
unsigned Config_getConnRDMABufSize(Config* this)
|
||||
{
|
||||
return (unsigned) this->connRDMABufSize;
|
||||
}
|
||||
|
||||
unsigned Config_getConnRDMAFragmentSize(Config* this)
|
||||
{
|
||||
return (unsigned) this->connRDMAFragmentSize;
|
||||
}
|
||||
|
||||
unsigned Config_getConnRDMABufNum(Config* this)
|
||||
{
|
||||
return (unsigned) this->connRDMABufNum;
|
||||
}
|
||||
|
||||
unsigned Config_getConnRDMAMetaBufSize(Config* this)
|
||||
{
|
||||
return (unsigned) this->connRDMAMetaBufSize;
|
||||
}
|
||||
|
||||
unsigned Config_getConnRDMAMetaFragmentSize(Config* this)
|
||||
{
|
||||
return (unsigned) this->connRDMAMetaFragmentSize;
|
||||
}
|
||||
|
||||
unsigned Config_getConnRDMAMetaBufNum(Config* this)
|
||||
{
|
||||
return (unsigned) this->connRDMAMetaBufNum;
|
||||
}
|
||||
|
||||
int Config_getConnRDMATypeOfService(Config* this)
|
||||
{
|
||||
return this->connRDMATypeOfService;
|
||||
}
|
||||
|
||||
char* Config_getConnRDMAKeyType(Config* this)
|
||||
{
|
||||
return this->connRDMAKeyType;
|
||||
}
|
||||
|
||||
RDMAKeyType Config_getConnRDMAKeyTypeNum(Config* this)
|
||||
{
|
||||
return this->connRDMAKeyTypeNum;
|
||||
}
|
||||
|
||||
unsigned Config_getRemapConnectionFailureStatus(Config* this)
|
||||
{
|
||||
return this->remapConnectionFailureStatus;
|
||||
}
|
||||
|
||||
void Config_setRemapConnectionFailureStatus(Config* this, unsigned status)
|
||||
{
|
||||
this->remapConnectionFailureStatus = status;
|
||||
}
|
||||
|
||||
char* Config_getConnNetFilterFile(Config* this)
|
||||
{
|
||||
return this->connNetFilterFile;
|
||||
}
|
||||
|
||||
unsigned Config_getConnMaxConcurrentAttempts(Config* this)
|
||||
{
|
||||
return this->connMaxConcurrentAttempts;
|
||||
}
|
||||
|
||||
char* Config_getConnAuthFile(Config* this)
|
||||
{
|
||||
return this->connAuthFile;
|
||||
}
|
||||
|
||||
bool Config_getConnDisableAuthentication(Config* this)
|
||||
{
|
||||
return this->connDisableAuthentication;
|
||||
}
|
||||
|
||||
uint64_t Config_getConnAuthHash(Config* this)
|
||||
{
|
||||
return this->connAuthHash;
|
||||
}
|
||||
|
||||
char* Config_getConnTcpOnlyFilterFile(Config* this)
|
||||
{
|
||||
return this->connTcpOnlyFilterFile;
|
||||
}
|
||||
|
||||
char* Config_getTunePreferredMetaFile(Config* this)
|
||||
{
|
||||
return this->tunePreferredMetaFile;
|
||||
}
|
||||
|
||||
char* Config_getTunePreferredStorageFile(Config* this)
|
||||
{
|
||||
return this->tunePreferredStorageFile;
|
||||
}
|
||||
|
||||
char* Config_getTuneFileCacheType(Config* this)
|
||||
{
|
||||
return this->tuneFileCacheType;
|
||||
}
|
||||
|
||||
FileCacheType Config_getTuneFileCacheTypeNum(Config* this)
|
||||
{
|
||||
return this->tuneFileCacheTypeNum;
|
||||
}
|
||||
|
||||
int Config_getTuneFileCacheBufSize(Config* this)
|
||||
{
|
||||
return this->tuneFileCacheBufSize;
|
||||
}
|
||||
|
||||
int Config_getTuneFileCacheBufNum(Config* this)
|
||||
{
|
||||
return this->tuneFileCacheBufNum;
|
||||
}
|
||||
|
||||
int Config_getTunePathBufSize(Config* this)
|
||||
{
|
||||
return this->tunePathBufSize;
|
||||
}
|
||||
|
||||
int Config_getTunePathBufNum(Config* this)
|
||||
{
|
||||
return this->tunePathBufNum;
|
||||
}
|
||||
|
||||
int Config_getTuneMsgBufSize(Config* this)
|
||||
{
|
||||
return this->tuneMsgBufSize;
|
||||
}
|
||||
|
||||
int Config_getTuneMsgBufNum(Config* this)
|
||||
{
|
||||
return this->tuneMsgBufNum;
|
||||
}
|
||||
|
||||
unsigned Config_getTunePageCacheValidityMS(Config* this)
|
||||
{
|
||||
return this->tunePageCacheValidityMS;
|
||||
}
|
||||
|
||||
unsigned Config_getTuneDirSubentryCacheValidityMS(Config* this)
|
||||
{
|
||||
return this->tuneDirSubentryCacheValidityMS;
|
||||
}
|
||||
|
||||
unsigned Config_getTuneFileSubentryCacheValidityMS(Config* this)
|
||||
{
|
||||
return this->tuneFileSubentryCacheValidityMS;
|
||||
}
|
||||
|
||||
unsigned Config_getTuneENOENTCacheValidityMS(Config* this)
|
||||
{
|
||||
return this->tuneENOENTCacheValidityMS;
|
||||
}
|
||||
|
||||
bool Config_getTuneRemoteFSync(Config* this)
|
||||
{
|
||||
return this->tuneRemoteFSync;
|
||||
}
|
||||
|
||||
bool Config_getTuneUseGlobalFileLocks(Config* this)
|
||||
{
|
||||
return this->tuneUseGlobalFileLocks;
|
||||
}
|
||||
|
||||
bool Config_getTuneRefreshOnGetAttr(Config* this)
|
||||
{
|
||||
return this->tuneRefreshOnGetAttr;
|
||||
}
|
||||
|
||||
bool Config_getTuneCoherentBuffers(Config* this)
|
||||
{
|
||||
return this->tuneCoherentBuffers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Special function to automatically enable TuneRefreshOnGetAttr, e.g. for NFS exports.
|
||||
*
|
||||
* Note: We do not use any locks here assuming the right value will propate to all cores rather
|
||||
* soon.
|
||||
*/
|
||||
void Config_setTuneRefreshOnGetAttr(Config* this)
|
||||
{
|
||||
this->tuneRefreshOnGetAttr = true;
|
||||
|
||||
// do a memory barrier, so that other CPUs get the new value as soon as possible
|
||||
smp_wmb();
|
||||
}
|
||||
|
||||
|
||||
unsigned Config_getTuneInodeBlockBits(Config* this)
|
||||
{
|
||||
return this->tuneInodeBlockBits;
|
||||
}
|
||||
|
||||
unsigned Config_getTuneInodeBlockSize(Config* this)
|
||||
{
|
||||
return this->tuneInodeBlockSize;
|
||||
}
|
||||
|
||||
bool Config_getTuneEarlyCloseResponse(Config* this)
|
||||
{
|
||||
return this->tuneEarlyCloseResponse;
|
||||
}
|
||||
|
||||
bool Config_getTuneUseGlobalAppendLocks(Config* this)
|
||||
{
|
||||
return this->tuneUseGlobalAppendLocks;
|
||||
}
|
||||
|
||||
bool Config_getTuneUseBufferedAppend(Config* this)
|
||||
{
|
||||
return this->tuneUseBufferedAppend;
|
||||
}
|
||||
|
||||
unsigned Config_getTuneStatFsCacheSecs(Config* this)
|
||||
{
|
||||
return this->tuneStatFsCacheSecs;
|
||||
}
|
||||
|
||||
char* Config_getSysMgmtdHost(Config* this)
|
||||
{
|
||||
return this->sysMgmtdHost;
|
||||
}
|
||||
|
||||
char* Config_getSysInodeIDStyle(Config* this)
|
||||
{
|
||||
return this->sysInodeIDStyle;
|
||||
}
|
||||
|
||||
InodeIDStyle Config_getSysInodeIDStyleNum(Config* this)
|
||||
{
|
||||
return this->sysInodeIDStyleNum;
|
||||
}
|
||||
|
||||
bool Config_getSysCacheInvalidationVersion(Config* this)
|
||||
{
|
||||
return this->sysCacheInvalidationVersion;
|
||||
}
|
||||
|
||||
bool Config_getSysCreateHardlinksAsSymlinks(Config* this)
|
||||
{
|
||||
return this->sysCreateHardlinksAsSymlinks;
|
||||
}
|
||||
|
||||
unsigned Config_getSysMountSanityCheckMS(Config* this)
|
||||
{
|
||||
return this->sysMountSanityCheckMS;
|
||||
}
|
||||
|
||||
bool Config_getSysSyncOnClose(Config* this)
|
||||
{
|
||||
return this->sysSyncOnClose;
|
||||
}
|
||||
|
||||
bool Config_getSysSessionCheckOnClose(Config* this)
|
||||
{
|
||||
return this->sysSessionCheckOnClose;
|
||||
}
|
||||
|
||||
bool Config_getSysSessionChecksEnabled(Config* this)
|
||||
{
|
||||
return this->sysSessionChecksEnabled;
|
||||
}
|
||||
|
||||
unsigned Config_getSysUpdateTargetStatesSecs(Config* this)
|
||||
{
|
||||
return this->sysUpdateTargetStatesSecs;
|
||||
}
|
||||
|
||||
unsigned Config_getSysTargetOfflineTimeoutSecs(Config* this)
|
||||
{
|
||||
return this->sysTargetOfflineTimeoutSecs;
|
||||
}
|
||||
|
||||
bool Config_getSysXAttrsEnabled(Config* this)
|
||||
{
|
||||
return this->sysXAttrsEnabled;
|
||||
}
|
||||
|
||||
CheckCapabilities Config_getSysXAttrsCheckCapabilities(Config* this)
|
||||
{
|
||||
return this->sysXAttrsCheckCapabilities;
|
||||
}
|
||||
|
||||
bool Config_getSysACLsEnabled(Config* this)
|
||||
{
|
||||
return this->sysACLsEnabled;
|
||||
}
|
||||
|
||||
bool Config_getSysXAttrsImplicitlyEnabled(Config* this)
|
||||
{
|
||||
return this->sysXAttrsImplicitlyEnabled;
|
||||
}
|
||||
|
||||
bool Config_getSysBypassFileAccessCheckOnMeta(Config* this)
|
||||
{
|
||||
return this->sysBypassFileAccessCheckOnMeta;
|
||||
}
|
||||
|
||||
bool Config_getQuotaEnabled(Config* this)
|
||||
{
|
||||
return this->quotaEnabled;
|
||||
}
|
||||
|
||||
char* Config_getConnMessagingTimeouts(Config* this)
|
||||
{
|
||||
return this->connMessagingTimeouts;
|
||||
}
|
||||
|
||||
char* Config_getConnRDMATimeouts(Config* this)
|
||||
{
|
||||
return this->connRDMATimeouts;
|
||||
}
|
||||
|
||||
int Config_getConnRDMATimeoutConnect(Config* this)
|
||||
{
|
||||
return this->connRDMATimeoutConnect;
|
||||
}
|
||||
|
||||
int Config_getConnRDMATimeoutCompletion(Config* this)
|
||||
{
|
||||
return this->connRDMATimeoutCompletion;
|
||||
}
|
||||
|
||||
int Config_getConnRDMATimeoutFlowSend(Config* this)
|
||||
{
|
||||
return this->connRDMATimeoutFlowSend;
|
||||
}
|
||||
|
||||
int Config_getConnRDMATimeoutFlowRecv(Config* this)
|
||||
{
|
||||
return this->connRDMATimeoutFlowRecv;
|
||||
}
|
||||
|
||||
int Config_getConnRDMATimeoutPoll(Config* this)
|
||||
{
|
||||
return this->connRDMATimeoutPoll;
|
||||
}
|
||||
|
||||
#endif /*CONFIG_H_*/
|
||||
238
client_module/source/app/config/MountConfig.c
Normal file
238
client_module/source/app/config/MountConfig.c
Normal file
@@ -0,0 +1,238 @@
|
||||
#include <app/config/MountConfig.h>
|
||||
#include <common/toolkit/list/StrCpyList.h>
|
||||
#include <common/toolkit/list/StrCpyListIter.h>
|
||||
#include <common/Common.h>
|
||||
|
||||
#include <linux/parser.h>
|
||||
|
||||
|
||||
enum {
|
||||
/* Mount options that take string arguments */
|
||||
Opt_cfgFile,
|
||||
Opt_logStdFile,
|
||||
Opt_sysMgmtdHost,
|
||||
Opt_tunePreferredMetaFile,
|
||||
Opt_tunePreferredStorageFile,
|
||||
|
||||
Opt_connInterfacesList,
|
||||
Opt_connAuthFile,
|
||||
Opt_connDisableAuthentication,
|
||||
|
||||
/* Mount options that take integer arguments */
|
||||
Opt_logLevel,
|
||||
Opt_connPortShift,
|
||||
Opt_connMgmtdPort,
|
||||
Opt_sysMountSanityCheckMS,
|
||||
|
||||
/* Mount options that take no arguments */
|
||||
Opt_grpid,
|
||||
|
||||
Opt_err
|
||||
};
|
||||
|
||||
|
||||
static match_table_t fhgfs_mount_option_tokens =
|
||||
{
|
||||
/* Mount options that take string arguments */
|
||||
{ Opt_cfgFile, "cfgFile=%s" },
|
||||
{ Opt_logStdFile, "logStdFile=%s" },
|
||||
{ Opt_sysMgmtdHost, "sysMgmtdHost=%s" },
|
||||
{ Opt_tunePreferredMetaFile, "tunePreferredMetaFile=%s" },
|
||||
{ Opt_tunePreferredStorageFile, "tunePreferredStorageFile=%s" },
|
||||
|
||||
{ Opt_connInterfacesList, "connInterfacesList=%s" },
|
||||
{ Opt_connAuthFile, "connAuthFile=%s" },
|
||||
{ Opt_connDisableAuthentication, "connDisableAuthentication=%s" },
|
||||
|
||||
/* Mount options that take integer arguments */
|
||||
{ Opt_logLevel, "logLevel=%d" },
|
||||
{ Opt_connPortShift, "connPortShift=%d" },
|
||||
{ Opt_connMgmtdPort, "connMgmtdPort=%u" },
|
||||
{ Opt_sysMountSanityCheckMS, "sysMountSanityCheckMS=%u" },
|
||||
|
||||
{ Opt_grpid, "grpid" },
|
||||
|
||||
{ Opt_err, NULL }
|
||||
};
|
||||
|
||||
|
||||
|
||||
bool MountConfig_parseFromRawOptions(MountConfig* this, char* mountOptions)
|
||||
{
|
||||
char* currentOption;
|
||||
|
||||
if(!mountOptions)
|
||||
{
|
||||
printk_fhgfs_debug(KERN_INFO, "Mount options = <none>\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
printk_fhgfs_debug(KERN_INFO, "Mount options = '%s'\n", mountOptions);
|
||||
|
||||
while( (currentOption = strsep(&mountOptions, ",") ) != NULL)
|
||||
{
|
||||
substring_t args[MAX_OPT_ARGS];
|
||||
int tokenID;
|
||||
|
||||
if(!*currentOption)
|
||||
continue; // skip empty string
|
||||
|
||||
tokenID = match_token(currentOption, fhgfs_mount_option_tokens, args);
|
||||
|
||||
switch(tokenID)
|
||||
{
|
||||
/* Mount options that take STRING arguments */
|
||||
|
||||
case Opt_cfgFile:
|
||||
{
|
||||
SAFE_KFREE(this->cfgFile);
|
||||
|
||||
this->cfgFile = match_strdup(args);// (string kalloc'ed => needs kfree later)
|
||||
} break;
|
||||
|
||||
case Opt_logStdFile:
|
||||
{
|
||||
SAFE_KFREE(this->logStdFile);
|
||||
|
||||
this->logStdFile = match_strdup(args); // (string kalloc'ed => needs kfree later)
|
||||
} break;
|
||||
|
||||
case Opt_sysMgmtdHost:
|
||||
{
|
||||
SAFE_KFREE(this->sysMgmtdHost);
|
||||
|
||||
this->sysMgmtdHost = match_strdup(args); // (string kalloc'ed => needs kfree later)
|
||||
} break;
|
||||
|
||||
case Opt_tunePreferredMetaFile:
|
||||
{
|
||||
SAFE_KFREE(this->tunePreferredMetaFile);
|
||||
|
||||
this->tunePreferredMetaFile = match_strdup(args); // (string kalloc'ed => needs kfree later)
|
||||
} break;
|
||||
|
||||
case Opt_tunePreferredStorageFile:
|
||||
{
|
||||
SAFE_KFREE(this->tunePreferredStorageFile);
|
||||
|
||||
this->tunePreferredStorageFile = match_strdup(args); // (string kalloc'ed => needs kfree later)
|
||||
} break;
|
||||
|
||||
case Opt_connInterfacesList:
|
||||
{
|
||||
SAFE_KFREE(this->connInterfacesList);
|
||||
|
||||
this->connInterfacesList = match_strdup(args);
|
||||
} break;
|
||||
|
||||
case Opt_connAuthFile:
|
||||
{
|
||||
SAFE_KFREE(this->connAuthFile);
|
||||
|
||||
this->connAuthFile = match_strdup(args);
|
||||
} break;
|
||||
|
||||
case Opt_connDisableAuthentication:
|
||||
{
|
||||
SAFE_KFREE(this->connDisableAuthentication);
|
||||
|
||||
this->connDisableAuthentication = match_strdup(args);
|
||||
} break;
|
||||
|
||||
/* Mount options that take INTEGER arguments */
|
||||
|
||||
case Opt_logLevel:
|
||||
{
|
||||
if(match_int(args, &this->logLevel) )
|
||||
goto err_exit_invalid_option;
|
||||
|
||||
this->logLevelDefined = true;
|
||||
} break;
|
||||
|
||||
case Opt_connPortShift:
|
||||
{
|
||||
if(match_int(args, &this->connPortShift) )
|
||||
goto err_exit_invalid_option;
|
||||
|
||||
this->connPortShiftDefined = true;
|
||||
} break;
|
||||
|
||||
case Opt_connMgmtdPort:
|
||||
{
|
||||
if(match_int(args, &this->connMgmtdPort) )
|
||||
goto err_exit_invalid_option;
|
||||
|
||||
this->connMgmtdPortDefined = true;
|
||||
} break;
|
||||
|
||||
case Opt_sysMountSanityCheckMS:
|
||||
{
|
||||
if(match_int(args, &this->sysMountSanityCheckMS) )
|
||||
goto err_exit_invalid_option;
|
||||
|
||||
this->sysMountSanityCheckMSDefined = true;
|
||||
} break;
|
||||
|
||||
case Opt_grpid:
|
||||
this->grpid = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
goto err_exit_unknown_option;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
err_exit_unknown_option:
|
||||
printk_fhgfs(KERN_WARNING, "Unknown mount option: '%s'\n", currentOption);
|
||||
return false;
|
||||
|
||||
err_exit_invalid_option:
|
||||
printk_fhgfs(KERN_WARNING, "Invalid mount option: '%s'\n", currentOption);
|
||||
return false;
|
||||
}
|
||||
|
||||
void MountConfig_showOptions(MountConfig* this, struct seq_file* sf)
|
||||
{
|
||||
if (this->cfgFile)
|
||||
seq_printf(sf, ",cfgFile=%s", this->cfgFile);
|
||||
|
||||
if (this->logStdFile)
|
||||
seq_printf(sf, ",logStdFile=%s", this->logStdFile);
|
||||
|
||||
if (this->sysMgmtdHost)
|
||||
seq_printf(sf, ",sysMgmtdHost=%s", this->sysMgmtdHost);
|
||||
|
||||
if (this->tunePreferredMetaFile)
|
||||
seq_printf(sf, ",tunePreferredMetaFile=%s", this->tunePreferredMetaFile);
|
||||
|
||||
if (this->tunePreferredStorageFile)
|
||||
seq_printf(sf, ",tunePreferredStorageFile=%s", this->tunePreferredStorageFile);
|
||||
|
||||
if (this->connInterfacesList)
|
||||
seq_printf(sf, ",connInterfacesList=%s", this->connInterfacesList);
|
||||
|
||||
if (this->connAuthFile)
|
||||
seq_printf(sf, ",connAuthFile=%s", this->connInterfacesList);
|
||||
|
||||
if (this->connDisableAuthentication)
|
||||
seq_printf(sf, ",connDisableAuthentication=%s", this->connInterfacesList);
|
||||
|
||||
if (this->logLevelDefined)
|
||||
seq_printf(sf, ",logLevel=%d", this->logLevel);
|
||||
|
||||
if (this->connPortShiftDefined)
|
||||
seq_printf(sf, ",connPortShift=%d", this->connPortShift);
|
||||
|
||||
if (this->connMgmtdPortDefined)
|
||||
seq_printf(sf, ",connMgmtdPort=%u", this->connMgmtdPort);
|
||||
|
||||
if (this->sysMountSanityCheckMSDefined)
|
||||
seq_printf(sf, ",sysMountSanityCheckMS=%u", this->sysMountSanityCheckMS);
|
||||
|
||||
if (this->grpid)
|
||||
seq_printf(sf, ",grpid");
|
||||
}
|
||||
80
client_module/source/app/config/MountConfig.h
Normal file
80
client_module/source/app/config/MountConfig.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef OPEN_MOUNTCONFIG_H_
|
||||
#define OPEN_MOUNTCONFIG_H_
|
||||
|
||||
#include <common/Common.h>
|
||||
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
struct MountConfig;
|
||||
typedef struct MountConfig MountConfig;
|
||||
|
||||
|
||||
static inline void MountConfig_init(MountConfig* this);
|
||||
static inline MountConfig* MountConfig_construct(void);
|
||||
static inline void MountConfig_uninit(MountConfig* this);
|
||||
static inline void MountConfig_destruct(MountConfig* this);
|
||||
|
||||
extern bool MountConfig_parseFromRawOptions(MountConfig* this, char* mountOptions);
|
||||
extern void MountConfig_showOptions(MountConfig* this, struct seq_file* sf);
|
||||
|
||||
|
||||
struct MountConfig
|
||||
{
|
||||
char* cfgFile;
|
||||
char* logStdFile;
|
||||
char* sysMgmtdHost;
|
||||
char* tunePreferredMetaFile;
|
||||
char* tunePreferredStorageFile;
|
||||
|
||||
bool logLevelDefined; // true if the value has been specified
|
||||
bool connPortShiftDefined; // true if the value has been specified
|
||||
bool connMgmtdPortDefined; // true if the value has been specified
|
||||
bool sysMountSanityCheckMSDefined; // true if the value has been specified
|
||||
|
||||
int logLevel;
|
||||
unsigned connPortShift;
|
||||
unsigned connMgmtdPort;
|
||||
unsigned sysMountSanityCheckMS;
|
||||
char* connInterfacesList;
|
||||
char* connAuthFile;
|
||||
char* connDisableAuthentication;
|
||||
|
||||
bool grpid;
|
||||
};
|
||||
|
||||
|
||||
void MountConfig_init(MountConfig* this)
|
||||
{
|
||||
memset(this, 0, sizeof(*this) );
|
||||
}
|
||||
|
||||
struct MountConfig* MountConfig_construct(void)
|
||||
{
|
||||
struct MountConfig* this = (MountConfig*)os_kmalloc(sizeof(*this) );
|
||||
|
||||
MountConfig_init(this);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
void MountConfig_uninit(MountConfig* this)
|
||||
{
|
||||
SAFE_KFREE(this->cfgFile);
|
||||
SAFE_KFREE(this->logStdFile);
|
||||
SAFE_KFREE(this->sysMgmtdHost);
|
||||
SAFE_KFREE(this->tunePreferredMetaFile);
|
||||
SAFE_KFREE(this->tunePreferredStorageFile);
|
||||
SAFE_KFREE(this->connInterfacesList);
|
||||
SAFE_KFREE(this->connAuthFile);
|
||||
SAFE_KFREE(this->connDisableAuthentication);
|
||||
}
|
||||
|
||||
void MountConfig_destruct(MountConfig* this)
|
||||
{
|
||||
MountConfig_uninit(this);
|
||||
|
||||
kfree(this);
|
||||
}
|
||||
|
||||
|
||||
#endif /*OPEN_MOUNTCONFIG_H_*/
|
||||
331
client_module/source/app/log/Logger.c
Normal file
331
client_module/source/app/log/Logger.c
Normal file
@@ -0,0 +1,331 @@
|
||||
#include <common/threading/Thread.h>
|
||||
#include <common/toolkit/MessagingTk.h>
|
||||
#include <common/nodes/Node.h>
|
||||
#include <filesystem/FhgfsOpsSuper.h>
|
||||
#include <filesystem/FhgfsInode.h>
|
||||
#include <toolkit/NoAllocBufferStore.h>
|
||||
#include "Logger.h"
|
||||
|
||||
|
||||
#define LOG_TOPIC_GENERAL_STR "general"
|
||||
#define LOG_TOPIC_CONN_STR "conn"
|
||||
#define LOG_TOPIC_COMMKIT_STR "commkit"
|
||||
#define LOG_TOPIC_UNKNOWN_STR "<unknown>" /* for unknown/invalid log topics */
|
||||
|
||||
|
||||
|
||||
void Logger_init(Logger* this, App* app, Config* cfg)
|
||||
{
|
||||
int i;
|
||||
|
||||
this->app = app;
|
||||
|
||||
for(i=0; i < LogTopic_LAST; i++)
|
||||
this->logLevels[i] = Config_getLogLevel(cfg);
|
||||
|
||||
this->logFormattedBuf = (char*)os_kmalloc(LOGGER_LOGBUF_SIZE);
|
||||
this->logContextBuf = (char*)os_kmalloc(LOGGER_LOGBUF_SIZE);
|
||||
|
||||
this->clientID = NULL;
|
||||
|
||||
Mutex_init(&this->outputMutex);
|
||||
|
||||
|
||||
// Note: The follwing guys exist to avoid deadlocks that would occur when log messages are
|
||||
// created (by the same thread) while we're already trying to send a log message to the
|
||||
// helper daemon (e.g. the messages of the NodeConnPool). Such messages will be discarded.
|
||||
this->currentOutputPID = LOGGER_PID_NOCURRENTOUTPUT;
|
||||
Mutex_init(&this->multiLockMutex);
|
||||
}
|
||||
|
||||
Logger* Logger_construct(App* app, Config* cfg)
|
||||
{
|
||||
Logger* this = (Logger*)os_kmalloc(sizeof(Logger) );
|
||||
|
||||
Logger_init(this, app, cfg);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
void Logger_uninit(Logger* this)
|
||||
{
|
||||
SAFE_KFREE(this->clientID);
|
||||
|
||||
SAFE_KFREE(this->logContextBuf);
|
||||
SAFE_KFREE(this->logFormattedBuf);
|
||||
|
||||
Mutex_uninit(&this->multiLockMutex);
|
||||
Mutex_uninit(&this->outputMutex);
|
||||
}
|
||||
|
||||
void Logger_destruct(Logger* this)
|
||||
{
|
||||
Logger_uninit(this);
|
||||
|
||||
kfree(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Just print a log message with formatting similar to printk().
|
||||
*
|
||||
* @param level LogLevel_... value
|
||||
* @param context the context from which this msg was printed (e.g. the calling function).
|
||||
* @param msg the log message with formatting, e.g. "%s".
|
||||
*/
|
||||
void Logger_logFormatted(Logger* this, LogLevel level, const char* context, const char* msgFormat,
|
||||
...)
|
||||
{
|
||||
// note: cannot be inlined because of variable arg list
|
||||
|
||||
va_list ap;
|
||||
|
||||
if(level > this->logLevels[LogTopic_GENERAL])
|
||||
return;
|
||||
|
||||
va_start(ap, msgFormat);
|
||||
|
||||
__Logger_logTopFormattedGranted(this, LogTopic_GENERAL, level, context, msgFormat, ap);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void Logger_logTopFormatted(Logger* this, LogTopic logTopic, LogLevel level, const char* context,
|
||||
const char* msgFormat, ...)
|
||||
{
|
||||
// note: cannot be inlined because of variable arg list
|
||||
|
||||
va_list ap;
|
||||
|
||||
if(level > this->logLevels[logTopic])
|
||||
return;
|
||||
|
||||
va_start(ap, msgFormat);
|
||||
|
||||
__Logger_logTopFormattedGranted(this, logTopic, level, context, msgFormat, ap);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log with EntryID
|
||||
*
|
||||
* Note: This takes an EntryInfo read-lock. Must be used only if there is no risk of deadlock.
|
||||
*/
|
||||
void Logger_logTopFormattedWithEntryID(struct inode* inode, LogTopic logTopic, LogLevel level,
|
||||
const char* logContext, const char* msgFormat, ...)
|
||||
{
|
||||
char* newMsg;
|
||||
App* app = FhgfsOps_getApp(inode->i_sb);
|
||||
Logger* log = App_getLogger(app);
|
||||
FhgfsInode* fhgfsInode = BEEGFS_INODE(inode);
|
||||
const EntryInfo* entryInfo = FhgfsInode_getEntryInfo(fhgfsInode);
|
||||
va_list ap;
|
||||
|
||||
FhgfsInode_entryInfoReadLock(fhgfsInode); // L O C K entryInfo
|
||||
|
||||
va_start(ap, msgFormat);
|
||||
|
||||
newMsg = os_kmalloc(LOGGER_LOGBUF_SIZE);
|
||||
if (newMsg)
|
||||
snprintf(newMsg, LOGGER_LOGBUF_SIZE, "entryID: %s %s ", EntryInfo_getEntryID(entryInfo),
|
||||
msgFormat);
|
||||
else // malloc failed. Likely an out memory situation, we still try to print msgFormat
|
||||
newMsg = (char*)msgFormat;
|
||||
|
||||
Logger_logTopFormattedVA(log, logTopic, level, logContext, newMsg, ap);
|
||||
va_end(ap);
|
||||
|
||||
FhgfsInode_entryInfoReadUnlock(fhgfsInode); // U N L O C K entryInfo
|
||||
|
||||
if(newMsg != msgFormat)
|
||||
kfree(newMsg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Just print a log message. Similar to Logger_logFormatted(), but take a va_list already
|
||||
*/
|
||||
void Logger_logFormattedVA(Logger* this, LogLevel level, const char* context, const char* msgFormat,
|
||||
va_list ap)
|
||||
{
|
||||
if(level > this->logLevels[LogTopic_GENERAL])
|
||||
return;
|
||||
|
||||
__Logger_logTopFormattedGranted(this, LogTopic_GENERAL, level, context, msgFormat, ap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Just print a log message. Similar to Logger_logTopFormatted(), but take a va_list already
|
||||
*/
|
||||
void Logger_logTopFormattedVA(Logger* this, LogTopic logTopic, LogLevel level, const char* context,
|
||||
const char* msgFormat, va_list ap)
|
||||
{
|
||||
if(level > this->logLevels[logTopic])
|
||||
return;
|
||||
|
||||
__Logger_logTopFormattedGranted(this, logTopic, level, context, msgFormat, ap);
|
||||
}
|
||||
|
||||
void Logger_logErrFormatted(Logger* this, const char* context, const char* msgFormat, ...)
|
||||
{
|
||||
// note: cannot be inlined because of variable arg list
|
||||
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, msgFormat);
|
||||
|
||||
__Logger_logTopFormattedGranted(this, LogTopic_GENERAL, Log_ERR, context, msgFormat, ap);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void Logger_logTopErrFormatted(Logger* this, LogTopic logTopic, const char* context,
|
||||
const char* msgFormat, ...)
|
||||
{
|
||||
// note: cannot be inlined because of variable arg list
|
||||
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, msgFormat);
|
||||
|
||||
__Logger_logTopFormattedGranted(this, logTopic, Log_ERR, context, msgFormat, ap);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a message to the standard log.
|
||||
*
|
||||
* @param level log level (Log_... value)
|
||||
* @param msg the message
|
||||
*/
|
||||
void __Logger_logTopFormattedGranted(Logger* this, LogTopic logTopic, LogLevel level,
|
||||
const char* context, const char* msgFormat, va_list args)
|
||||
{
|
||||
if(__Logger_checkThreadMultiLock(this) )
|
||||
{
|
||||
// this thread is already trying to log a message. trying to lock outputMutex would deadlock.
|
||||
// => discard this message
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Mutex_lock(&this->outputMutex);
|
||||
|
||||
__Logger_setCurrentOutputPID(this, current->pid); // grab currentOutputPID
|
||||
|
||||
|
||||
// evaluate msgFormat
|
||||
vsnprintf(this->logFormattedBuf, LOGGER_LOGBUF_SIZE, msgFormat, args);
|
||||
|
||||
// extend context
|
||||
if(this->clientID)
|
||||
snprintf(this->logContextBuf, LOGGER_LOGBUF_SIZE, "%s: %s", this->clientID, context);
|
||||
else
|
||||
snprintf(this->logContextBuf, LOGGER_LOGBUF_SIZE, "%s", context);
|
||||
|
||||
printk_fhgfs(KERN_INFO, "%s: %s\n", this->logContextBuf, this->logFormattedBuf);
|
||||
|
||||
__Logger_setCurrentOutputPID(this, LOGGER_PID_NOCURRENTOUTPUT); // release currentOutputPID
|
||||
|
||||
Mutex_unlock(&this->outputMutex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Note: Call this before locking the outputMutex (because it exists to avoid dead-locking).
|
||||
*
|
||||
* @return true if the currentOutputPID is set to the current thread and logging cannot continue;
|
||||
*/
|
||||
bool __Logger_checkThreadMultiLock(Logger* this)
|
||||
{
|
||||
bool retVal = false;
|
||||
|
||||
Mutex_lock(&this->multiLockMutex);
|
||||
|
||||
if(this->currentOutputPID == current->pid)
|
||||
{ // we alread own the outputPID (=> we already own the outputMutex)
|
||||
retVal = true;
|
||||
}
|
||||
|
||||
Mutex_unlock(&this->multiLockMutex);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: Call this only after the thread owns the outputMutex to avoid "stealing".
|
||||
*/
|
||||
void __Logger_setCurrentOutputPID(Logger* this, pid_t pid)
|
||||
{
|
||||
Mutex_lock(&this->multiLockMutex);
|
||||
|
||||
this->currentOutputPID = pid;
|
||||
|
||||
Mutex_unlock(&this->multiLockMutex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a pointer to the static string representation of a log topic (or "<unknown>" for unknown/
|
||||
* invalid log topic numbers.
|
||||
*/
|
||||
const char* Logger_getLogTopicStr(LogTopic logTopic)
|
||||
{
|
||||
switch(logTopic)
|
||||
{
|
||||
case LogTopic_GENERAL:
|
||||
return LOG_TOPIC_GENERAL_STR;
|
||||
|
||||
case LogTopic_CONN:
|
||||
return LOG_TOPIC_CONN_STR;
|
||||
|
||||
case LogTopic_COMMKIT:
|
||||
return LOG_TOPIC_COMMKIT_STR;
|
||||
|
||||
default:
|
||||
return LOG_TOPIC_UNKNOWN_STR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the log topic number from a string (not case-sensitive).
|
||||
*
|
||||
* @return false if string didn't match any known log topic.
|
||||
*/
|
||||
bool Logger_getLogTopicFromStr(const char* logTopicStr, LogTopic* outLogTopic)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i < LogTopic_LAST; i++)
|
||||
{
|
||||
const char* currentLogTopicStr = Logger_getLogTopicStr( (LogTopic)i);
|
||||
|
||||
if(!strcasecmp(logTopicStr, currentLogTopicStr))
|
||||
{
|
||||
*outLogTopic = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// (note: we carefully set outLogTopic to "general" to not risk leaving it undefined)
|
||||
*outLogTopic = LogTopic_GENERAL;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to retrieve the level of LogTopic_GENERAL in old code.
|
||||
* New code should use _getLogTopicLevel() instead.
|
||||
*/
|
||||
LogLevel Logger_getLogLevel(Logger* this)
|
||||
{
|
||||
return this->logLevels[LogTopic_GENERAL];
|
||||
}
|
||||
|
||||
LogLevel Logger_getLogTopicLevel(Logger* this, LogTopic logTopic)
|
||||
{
|
||||
return this->logLevels[logTopic];
|
||||
}
|
||||
|
||||
244
client_module/source/app/log/Logger.h
Normal file
244
client_module/source/app/log/Logger.h
Normal file
@@ -0,0 +1,244 @@
|
||||
#ifndef LOGGER_H_
|
||||
#define LOGGER_H_
|
||||
|
||||
#include <app/config/Config.h>
|
||||
#include <app/App.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/toolkit/StringTk.h>
|
||||
#include <common/toolkit/Time.h>
|
||||
#include <common/threading/Mutex.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/Common.h>
|
||||
|
||||
|
||||
#define LOGGER_LOGBUF_SIZE 1000 /* max log message length */
|
||||
#define LOGGER_PID_NOCURRENTOUTPUT 0 /* pid value if outputMutex not locked */
|
||||
|
||||
|
||||
#ifdef LOG_DEBUG_MESSAGES
|
||||
|
||||
#define LOG_DEBUG(logger, level, contextStr, msgStr) \
|
||||
do { Logger_log(logger, level, contextStr, msgStr); } while(0)
|
||||
|
||||
#define LOG_DEBUG_TOP(logger, logTopic, level, contextStr, msgStr) \
|
||||
do { Logger_logTop(logger, logTopic, level, contextStr, msgStr); } while(0)
|
||||
|
||||
#define LOG_DEBUG_FORMATTED(logger, level, contextStr, msgStr, ...) \
|
||||
do { Logger_logFormatted(logger, level, contextStr, msgStr, ## __VA_ARGS__); } while(0)
|
||||
|
||||
#define LOG_DEBUG_TOP_FORMATTED(logger, logTopic, level, contextStr, msgStr, ...) \
|
||||
do { Logger_logTopFormatted(logger, logTopic, level, contextStr, msgStr, ## __VA_ARGS__); } \
|
||||
while(0)
|
||||
|
||||
#else
|
||||
|
||||
#define LOG_DEBUG(logger, level, contextStr, msgStr)
|
||||
#define LOG_DEBUG_TOP(logger, logTopic, level, contextStr, msgStr)
|
||||
#define LOG_DEBUG_FORMATTED(logger, level, contextStr, msgStr, ...)
|
||||
#define LOG_DEBUG_TOP_FORMATTED(logger, logTopic, level, contextStr, msgStr, ...)
|
||||
|
||||
#endif // LOG_DEBUG_MESSAGES
|
||||
|
||||
#define Logger_logFormattedWithEntryID(inode, level, logContext, msgFormat, ...) \
|
||||
Logger_logTopFormattedWithEntryID(inode, LogTopic_GENERAL, level, logContext, msgFormat, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
// forward declarations...
|
||||
|
||||
struct Logger;
|
||||
typedef struct Logger Logger;
|
||||
|
||||
struct Node;
|
||||
|
||||
enum LogLevel;
|
||||
typedef enum LogLevel LogLevel;
|
||||
enum LogTopic;
|
||||
typedef enum LogTopic LogTopic;
|
||||
|
||||
|
||||
|
||||
extern void Logger_init(Logger* this, App* app, Config* cfg);
|
||||
extern Logger* Logger_construct(App* app, Config* cfg);
|
||||
extern void Logger_uninit(Logger* this);
|
||||
extern void Logger_destruct(Logger* this);
|
||||
|
||||
__attribute__((format(printf, 4, 5)))
|
||||
extern void Logger_logFormatted(Logger* this, LogLevel level, const char* context,
|
||||
const char* msgFormat, ...);
|
||||
__attribute__((format(printf, 5, 6)))
|
||||
extern void Logger_logTopFormattedWithEntryID(struct inode* inode, LogTopic logTopic,
|
||||
LogLevel level, const char* logContext, const char* msgFormat, ...);
|
||||
__attribute__((format(printf, 5, 6)))
|
||||
extern void Logger_logTopFormatted(Logger* this, LogTopic logTopic, LogLevel level,
|
||||
const char* context, const char* msgFormat, ...);
|
||||
extern void Logger_logFormattedVA(Logger* this, LogLevel level, const char* context,
|
||||
const char* msgFormat, va_list ap);
|
||||
extern void Logger_logTopFormattedVA(Logger* this, LogTopic logTopic, LogLevel level,
|
||||
const char* context, const char* msgFormat, va_list ap);
|
||||
__attribute__((format(printf, 3, 4)))
|
||||
extern void Logger_logErrFormatted(Logger* this, const char* context, const char* msgFormat, ...);
|
||||
__attribute__((format(printf, 4, 5)))
|
||||
extern void Logger_logTopErrFormatted(Logger* this, LogTopic logTopic, const char* context,
|
||||
const char* msgFormat, ...);
|
||||
|
||||
extern LogLevel Logger_getLogLevel(Logger* this);
|
||||
extern LogLevel Logger_getLogTopicLevel(Logger* this, LogTopic logTopic);
|
||||
|
||||
extern void __Logger_logTopFormattedGranted(Logger* this, LogTopic logTopic, LogLevel level,
|
||||
const char* context, const char* msgFormat, va_list args);
|
||||
|
||||
extern bool __Logger_checkThreadMultiLock(Logger* this);
|
||||
extern void __Logger_setCurrentOutputPID(Logger* this, pid_t pid);
|
||||
|
||||
|
||||
// static
|
||||
extern const char* Logger_getLogTopicStr(LogTopic logTopic);
|
||||
extern bool Logger_getLogTopicFromStr(const char* logTopicStr, LogTopic* logTopic);
|
||||
|
||||
// getters & setters
|
||||
static inline void Logger_setClientID(Logger* this, const char* clientID);
|
||||
static inline void Logger_setAllLogLevels(Logger* this, LogLevel logLevel);
|
||||
static inline void Logger_setLogTopicLevel(Logger* this, LogTopic logTopic, LogLevel logLevel);
|
||||
|
||||
// inliners
|
||||
static inline void Logger_log(Logger* this, LogLevel level, const char* context, const char* msg);
|
||||
static inline void Logger_logTop(Logger* this, LogTopic logTopic, LogLevel level,
|
||||
const char* context, const char* msg);
|
||||
static inline void Logger_logErr(Logger* this, const char* context, const char* msg);
|
||||
static inline void Logger_logTopErr(Logger* this, LogTopic logTopic, const char* context,
|
||||
const char* msg);
|
||||
|
||||
|
||||
enum LogLevel
|
||||
{
|
||||
LOG_NOTHING=-1,
|
||||
Log_ERR=0, /* system error */
|
||||
Log_CRITICAL=1, /* something the users should definitely know about */
|
||||
Log_WARNING=2, /* things that indicate or are related to a problem */
|
||||
Log_NOTICE=3, /* things that could help finding problems */
|
||||
Log_DEBUG=4, /* things that are only useful during debugging, often logged with LOG_DEBUG() */
|
||||
Log_SPAM=5 /* things that are typically too detailed even during normal debugging,
|
||||
very often with LOG_DEBUG() */
|
||||
};
|
||||
|
||||
/**
|
||||
* Note: When you add a new log topic, you must also update these places:
|
||||
* 1) Logger_getLogTopicStr()
|
||||
* 2) ProcFsHelper_{read/write}_logLevels()
|
||||
*/
|
||||
enum LogTopic
|
||||
{
|
||||
LogTopic_GENERAL=0, /* everything that is not assigned to a more specific log topic */
|
||||
LogTopic_CONN, /* connects and disconnects */
|
||||
LogTopic_COMMKIT, /* CommKitVec */
|
||||
|
||||
LogTopic_LAST /* not valid, just exists to define the LogLevelsArray size */
|
||||
};
|
||||
|
||||
typedef signed char LogTopicLevels[LogTopic_LAST]; /* array for per-topic log levels, see LogTopic/
|
||||
LogLevel. Note: Type is actually type LogLevel, but we use char here because we also allow
|
||||
"-1" to disable a level. */
|
||||
|
||||
|
||||
/**
|
||||
* This is the general logger class.
|
||||
*/
|
||||
struct Logger
|
||||
{
|
||||
// configurables
|
||||
LogTopicLevels logLevels; // per-topic log levels
|
||||
|
||||
// internals
|
||||
App* app;
|
||||
|
||||
Mutex outputMutex;
|
||||
|
||||
Mutex multiLockMutex; // to avoid multiple locking of the outputMutex by the same thread
|
||||
pid_t currentOutputPID; // pid of outputMutex holder (see LOGGER_PID_NOCURRENTOUTPUT)
|
||||
|
||||
char* logFormattedBuf; // for logging functions with variable argument list
|
||||
char* logContextBuf; // for extended context logging
|
||||
|
||||
char* clientID; // only set if clientID logging is enabled
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Note: Copies the clientID.
|
||||
*/
|
||||
void Logger_setClientID(Logger* this, const char* clientID)
|
||||
{
|
||||
SAFE_KFREE(this->clientID); // free old clientID
|
||||
|
||||
this->clientID = StringTk_strDup(clientID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: This is intended to be used during app destruction to disable logging by setting the levels
|
||||
* to "-1".
|
||||
*
|
||||
* @param logLevel LogLevel_... or "-1" to disable.
|
||||
*/
|
||||
void Logger_setAllLogLevels(Logger* this, LogLevel logLevel)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i < LogTopic_LAST; i++)
|
||||
this->logLevels[i] = logLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param logLevel LogLevel_... or "-1" to disable.
|
||||
*/
|
||||
void Logger_setLogTopicLevel(Logger* this, LogTopic logTopic, LogLevel logLevel)
|
||||
{
|
||||
this->logLevels[logTopic] = logLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log msg for LogTopic_GENERAL.
|
||||
*
|
||||
* @param level LogLevel_... value
|
||||
* @param context the context from which this msg was printed (e.g. the calling function).
|
||||
* @param msg the log message
|
||||
*/
|
||||
void Logger_log(Logger* this, LogLevel level, const char* context, const char* msg)
|
||||
{
|
||||
Logger_logFormatted(this, level, context, "%s", msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log msg for a certain log topic.
|
||||
*
|
||||
* @param level LogLevel_... value
|
||||
* @param context the context from which this msg was printed (e.g. the calling function).
|
||||
* @param msg the log message
|
||||
*/
|
||||
void Logger_logTop(Logger* this, LogTopic logTopic, LogLevel level, const char* context,
|
||||
const char* msg)
|
||||
{
|
||||
Logger_logTopFormatted(this, logTopic, level, context, "%s", msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log error msg for LogTopic_GENERAL.
|
||||
*/
|
||||
void Logger_logErr(Logger* this, const char* context, const char* msg)
|
||||
{
|
||||
Logger_logErrFormatted(this, context, "%s", msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log error msg for a certain log topic.
|
||||
*/
|
||||
void Logger_logTopErr(Logger* this, LogTopic logTopic, const char* context, const char* msg)
|
||||
{
|
||||
Logger_logTopErrFormatted(this, logTopic, context, "%s", msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /*LOGGER_H_*/
|
||||
490
client_module/source/common/Common.h
Normal file
490
client_module/source/common/Common.h
Normal file
@@ -0,0 +1,490 @@
|
||||
#ifndef COMMON_H_
|
||||
#define COMMON_H_
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/sched.h> /* for TASK_COMM_LEN */
|
||||
#include <linux/string.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
#ifdef KERNEL_HAS_LINUX_FILELOCK_H
|
||||
#include <linux/filelock.h>
|
||||
#endif
|
||||
|
||||
#ifdef KERNEL_HAS_LINUX_STDARG_H
|
||||
#include <linux/stdarg.h>
|
||||
#else
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/stddef.h>
|
||||
#include <linux/cred.h>
|
||||
#include <asm/div64.h>
|
||||
|
||||
#ifdef KERNEL_HAS_SCHED_SIG_H
|
||||
#include <linux/sched/signal.h>
|
||||
#endif
|
||||
|
||||
#include <common/FhgfsTypes.h>
|
||||
#include <os/OsDeps.h>
|
||||
|
||||
/**
|
||||
* NOTE: These timeouts can now be overridden by the connMessagingTimeouts
|
||||
* option in the configuration file. If that option is unset or set to <=0, we
|
||||
* still default to these constants.
|
||||
*/
|
||||
#define CONN_LONG_TIMEOUT 600000
|
||||
#define CONN_MEDIUM_TIMEOUT 90000
|
||||
#define CONN_SHORT_TIMEOUT 30000
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) \
|
||||
( ( (a) < (b) ) ? (a) : (b) )
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) \
|
||||
( ( (a) < (b) ) ? (b) : (a) )
|
||||
#endif
|
||||
|
||||
#define SAFE_VFREE(p) \
|
||||
do{ if(p) {vfree(p); (p)=NULL;} } while(0)
|
||||
|
||||
#define SAFE_VFREE_NOSET(p) \
|
||||
do{ if(p) vfree(p); } while(0)
|
||||
|
||||
#define SAFE_KFREE(p) \
|
||||
do{ if(p) {kfree(p); (p)=NULL;} } while(0)
|
||||
|
||||
#define SAFE_KFREE_NOSET(p) \
|
||||
do{ if(p) kfree(p); } while(0)
|
||||
|
||||
#define SAFE_DESTRUCT(p, destructor) \
|
||||
do{if(p) {destructor(p); (p)=NULL;} } while(0)
|
||||
|
||||
#define SAFE_DESTRUCT_NOSET(p, destructor) \
|
||||
do{if(p) destructor(p); } while(0)
|
||||
|
||||
|
||||
// typically used for optional out-args
|
||||
#define SAFE_ASSIGN(destPointer, sourceValue) \
|
||||
do{ if(destPointer) {*(destPointer) = (sourceValue);} } while(0)
|
||||
|
||||
|
||||
// module name
|
||||
|
||||
#ifndef BEEGFS_MODULE_NAME_STR
|
||||
#define BEEGFS_MODULE_NAME_STR "beegfs"
|
||||
#endif
|
||||
|
||||
#define BEEGFS_THREAD_NAME_PREFIX_STR BEEGFS_MODULE_NAME_STR "_"
|
||||
|
||||
// a printk-version that adds the module name and comm name
|
||||
#define printk_fhgfs(levelStr, fmtStr, ...) \
|
||||
printk(levelStr BEEGFS_MODULE_NAME_STR ": " "%s(%u): " fmtStr, current->comm, \
|
||||
(unsigned)current->pid, ## __VA_ARGS__)
|
||||
|
||||
// for interrupt handling routines (does not print "current")
|
||||
#define printk_fhgfs_ir(levelStr, fmtStr, ...) \
|
||||
printk(levelStr BEEGFS_MODULE_NAME_STR ": " fmtStr, ## __VA_ARGS__)
|
||||
|
||||
|
||||
// dumps stack in case of a buggy condition
|
||||
#define BEEGFS_BUG_ON(condition, msgStr) \
|
||||
do { \
|
||||
if(unlikely(condition) ) { \
|
||||
printk_fhgfs(KERN_ERR, "%s:%d: BUG: %s (dumping stack...)\n", \
|
||||
__func__, __LINE__, msgStr); \
|
||||
dump_stack(); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
|
||||
#ifdef LOG_DEBUG_MESSAGES
|
||||
|
||||
#define printk_fhgfs_debug(levelStr, fmtStr, ...) \
|
||||
printk(levelStr BEEGFS_MODULE_NAME_STR ": " "%s(%u): " fmtStr, current->comm, \
|
||||
(unsigned)current->pid, ## __VA_ARGS__)
|
||||
|
||||
|
||||
#define printk_fhgfs_ir_debug(levelStr, fmtStr, ...) \
|
||||
printk_fhgfs_ir(levelStr, fmtStr, ## __VA_ARGS__)
|
||||
|
||||
#define BEEGFS_BUG_ON_DEBUG(condition, msgStr) BEEGFS_BUG_ON(condition, msgStr)
|
||||
|
||||
#else // !LOG_DEBUG_MESSAGES
|
||||
|
||||
#define printk_fhgfs_debug(levelStr, fmtStr, ...) \
|
||||
do { /* nothing */ } while(0)
|
||||
|
||||
#define printk_fhgfs_ir_debug(levelStr, fmtStr, ...) \
|
||||
do { /* nothing */ } while(0)
|
||||
|
||||
#define BEEGFS_BUG_ON_DEBUG(condition, msgStr) \
|
||||
do { /* nothing */ } while(0)
|
||||
|
||||
#endif // LOG_DEBUG_MESSAGES
|
||||
|
||||
#ifdef BEEGFS_OPENTK_LOG_CONN_ERRORS
|
||||
#define printk_fhgfs_connerr(levelStr, fmtStr, ...) \
|
||||
printk_fhgfs(levelStr, fmtStr, ## __VA_ARGS__)
|
||||
#else
|
||||
#define printk_fhgfs_connerr(levelStr, fmtStr, ...) /* logging of conn errors disabled */
|
||||
#endif // BEEGFS_OPENTK_LOG_CONN_ERRORS
|
||||
|
||||
|
||||
// this macro mutes warnings about unused variables
|
||||
#define IGNORE_UNUSED_VARIABLE(a) do{ if( ((long)a)==1) {} } while(0)
|
||||
|
||||
// this macro mutes warnings about unsused variables that are only used in debug build
|
||||
#ifdef BEEGFS_DEBUG
|
||||
#define IGNORE_UNUSED_DEBUG_VARIABLE(a) do{ /* do nothing */ } while(0)
|
||||
#else
|
||||
#define IGNORE_UNUSED_DEBUG_VARIABLE(a) do{ if( ((long)a)==1) {} } while(0)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
/* set_fs() / get_fs() macro hackery.
|
||||
*
|
||||
* set_fs() and get_fs() have disappeared with Linux kernel 5.10.
|
||||
* For older kernels, we employ some macros to make their use less of a hassle.
|
||||
*/
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
#define BEEGFS_CONCAT_(x, y) x ## y
|
||||
#define BEEGFS_CONCAT(x, y) BEEGFS_CONCAT_(x, y)
|
||||
#define BEEGFS_UNIQUE_NAME(prefix) BEEGFS_CONCAT(prefix, __LINE__)
|
||||
|
||||
|
||||
// Lifted from Linux 5.10
|
||||
#if __has_attribute(__fallthrough__)
|
||||
#define BEEGFS_FALLTHROUGH __attribute__((__fallthrough__))
|
||||
#else
|
||||
#define BEEGFS_FALLTHROUGH do {} while (0) /* FALLTHROUGH */
|
||||
#endif
|
||||
|
||||
|
||||
/* Preprocessor hack to add statements that are executed on scope cleanup.
|
||||
* A for-loop that runs exactly 1 time is misused to execute the cleanup
|
||||
* statement. An assertion ensures that we didn't break from the inner loop,
|
||||
* to ensure the cleanup statement is executed. */
|
||||
|
||||
#define BEEGFS_FOR_SCOPE_(begin_stmt, end_stmt, name) \
|
||||
for (int name = 0; !name; ({BUG_ON(!name);})) \
|
||||
for (begin_stmt; !name++; end_stmt)
|
||||
|
||||
#define BEEGFS_FOR_SCOPE(begin_stmt, end_stmt) \
|
||||
BEEGFS_FOR_SCOPE_(begin_stmt, end_stmt, BEEGFS_UNIQUE_NAME(scope))
|
||||
|
||||
#ifdef KERNEL_HAS_GET_FS
|
||||
|
||||
static inline mm_segment_t BEEGFS_BEGIN_PROCESS_CONTEXT(void)
|
||||
{
|
||||
mm_segment_t out = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline void BEEGFS_END_PROCESS_CONTEXT(mm_segment_t *backup)
|
||||
{
|
||||
set_fs(*backup);
|
||||
}
|
||||
|
||||
#define WITH_PROCESS_CONTEXT \
|
||||
BEEGFS_FOR_SCOPE( \
|
||||
mm_segment_t segment = BEEGFS_BEGIN_PROCESS_CONTEXT(), \
|
||||
BEEGFS_END_PROCESS_CONTEXT(&segment))
|
||||
|
||||
#else
|
||||
|
||||
#define WITH_PROCESS_CONTEXT
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// in 4.13 wait_queue_t got renamed to wait_queue_entry_t
|
||||
#if defined(KERNEL_HAS_WAIT_QUEUE_ENTRY_T)
|
||||
typedef wait_queue_entry_t wait_queue_t;
|
||||
#endif
|
||||
|
||||
#if defined(KERNEL_HAS_64BIT_TIMESTAMPS)
|
||||
static inline struct timespec64 current_fs_time(struct super_block *sb)
|
||||
{
|
||||
struct timespec64 now;
|
||||
#if defined(KERNEL_HAS_KTIME_GET_COARSE_REAL_TS64)
|
||||
ktime_get_coarse_real_ts64(&now);
|
||||
return now;
|
||||
#elif defined(KERNEL_HAS_KTIME_GET_REAL_TS64)
|
||||
ktime_get_real_ts64(&now);
|
||||
return timespec64_trunc(now, sb->s_time_gran);
|
||||
#else
|
||||
now = current_kernel_time64();
|
||||
return timespec64_trunc(now, sb->s_time_gran);
|
||||
#endif
|
||||
}
|
||||
#elif !defined(KERNEL_HAS_CURRENT_FS_TIME)
|
||||
static inline struct timespec current_fs_time(struct super_block *sb)
|
||||
{
|
||||
struct timespec now = current_kernel_time();
|
||||
return timespec_trunc(now, sb->s_time_gran);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Defined by <linux/include/linux/uidgid.h> and already included by one of the headers, so
|
||||
* no KernelFeatureDetection.mk detection required.
|
||||
* Note: Not in OsCompat.h, as OsCompat depends on Common.h. */
|
||||
#ifndef _LINUX_UIDGID_H
|
||||
typedef unsigned kuid_t;
|
||||
typedef unsigned kgid_t;
|
||||
|
||||
#define from_kuid(a, b) (b)
|
||||
#define from_kgid(a, b) (b)
|
||||
#define make_kuid(a, b) (b)
|
||||
#define make_kgid(a, b) (b)
|
||||
#endif
|
||||
|
||||
#ifndef swap
|
||||
#define swap(a, b) do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
|
||||
#endif
|
||||
|
||||
#undef BEEGFS_RDMA
|
||||
#ifndef BEEGFS_NO_RDMA
|
||||
#if defined(CONFIG_INFINIBAND) || defined(CONFIG_INFINIBAND_MODULE)
|
||||
#define BEEGFS_RDMA 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static inline unsigned FhgfsCommon_getCurrentUserID(void);
|
||||
static inline unsigned FhgfsCommon_getCurrentGroupID(void);
|
||||
|
||||
|
||||
unsigned FhgfsCommon_getCurrentUserID(void)
|
||||
{
|
||||
return from_kuid(&init_user_ns, current_fsuid());
|
||||
}
|
||||
|
||||
unsigned FhgfsCommon_getCurrentGroupID(void)
|
||||
{
|
||||
return from_kgid(&init_user_ns, current_fsgid());
|
||||
}
|
||||
|
||||
// Helper function for getting file pointer
|
||||
static inline struct file * FhgfsCommon_getFileLock(struct file_lock *fileLock)
|
||||
{
|
||||
#if defined(KERNEL_HAS_FILE_LOCK_CORE)
|
||||
return fileLock->c.flc_file;
|
||||
#else
|
||||
return fileLock->fl_file;
|
||||
#endif
|
||||
}
|
||||
// Helper function to get PID from file lock
|
||||
static inline pid_t FhgfsCommon_getFileLockPID(struct file_lock *fileLock)
|
||||
{
|
||||
#if defined(KERNEL_HAS_FILE_LOCK_CORE)
|
||||
return fileLock->c.flc_pid;
|
||||
#else
|
||||
return fileLock->fl_pid;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Helper function to get lock type
|
||||
static inline unsigned char FhgfsCommon_getFileLockType(struct file_lock *flock)
|
||||
{
|
||||
#if defined(KERNEL_HAS_FILE_LOCK_CORE)
|
||||
return flock->c.flc_type;
|
||||
#else
|
||||
return flock->fl_type;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Helper function to get lock flags
|
||||
static inline unsigned int FhgfsCommon_getFileLockFlags(struct file_lock *fileLock)
|
||||
{
|
||||
#if defined(KERNEL_HAS_FILE_LOCK_CORE)
|
||||
return fileLock->c.flc_flags;
|
||||
#else
|
||||
return fileLock->fl_flags;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Debug definitions:
|
||||
* - LOG_DEBUG_MESSAGES: Enables logging of some extra debug messages that will not be
|
||||
* available otherwise.
|
||||
* - DEBUG_REFCOUNT: Enables debugging of ObjectReferencer::refCount. Error messages will
|
||||
* be logged if refCount is less than zero.
|
||||
*/
|
||||
|
||||
/**
|
||||
* BEEGFS_KFREE_LIST() - destroys and kfree()s all element of a list, leaving an empty list
|
||||
*
|
||||
* expands to ``BEEGFS_KFREE_LIST_DTOR(List, ElemType, Member, (void))``, ie no destructor is
|
||||
* called.
|
||||
*/
|
||||
#define BEEGFS_KFREE_LIST(List, ElemType, Member) \
|
||||
BEEGFS_KFREE_LIST_DTOR(List, ElemType, Member, (void))
|
||||
/**
|
||||
* BEEGFS_KFREE_LIST_DTOR() - destroys and kfree()s all element of a list, leaving an empty list
|
||||
* @List the &struct list_head to free
|
||||
* @ElemType type of elements contained in the list
|
||||
* @Member name of the &struct list_head in @ElemType that links to the next element of the list
|
||||
* @Dtor for each element of the list, ``Dtor(entry)`` is evaluated before the entry is freed
|
||||
*/
|
||||
#define BEEGFS_KFREE_LIST_DTOR(List, ElemType, Member, Dtor) \
|
||||
do { \
|
||||
ElemType* entry; \
|
||||
ElemType* n; \
|
||||
list_for_each_entry_safe(entry, n, List, Member) \
|
||||
{ \
|
||||
Dtor(entry); \
|
||||
kfree(entry); \
|
||||
} \
|
||||
INIT_LIST_HEAD(List); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Generic key comparison function for integer types and pointers, to be used by the
|
||||
* RBTREE_FUNCTIONS as KeyCmp.
|
||||
*/
|
||||
#define BEEGFS_RB_KEYCMP_LT_INTEGRAL(lhs, rhs) \
|
||||
( lhs < rhs ? -1 : (lhs == rhs ? 0 : 1) )
|
||||
|
||||
/**
|
||||
* BEEGFS_KFREE_RBTREE() - destroys and kfree()s all elements an rbtree
|
||||
*
|
||||
* expands to ``BEEGFS_KFREE_RBTREE_DTOR(TreeRoot, ElemType, Member, (void))``, ie no destructor is
|
||||
* called.
|
||||
*/
|
||||
#define BEEGFS_KFREE_RBTREE(TreeRoot, ElemType, Member) \
|
||||
BEEGFS_KFREE_RBTREE_DTOR(TreeRoot, ElemType, Member, (void))
|
||||
/**
|
||||
* BEEGFS_KFREE_RBTREE_DTOR() - destroys and kfree()s all elements an rbtree, leaving an empty tree
|
||||
* @TreeRoot &struct rb_root to free
|
||||
* @ElemType type of elements contained in the tree
|
||||
* @Member name of the &struct rb_node in @ElemType that links to further entries in the tree
|
||||
* @Dtor for each element of the tree, ``Dtor(elem)`` is evaluated before the entry is freed
|
||||
*/
|
||||
#define BEEGFS_KFREE_RBTREE_DTOR(TreeRoot, ElemType, Member, Dtor) \
|
||||
do { \
|
||||
ElemType* pos; \
|
||||
ElemType* n; \
|
||||
rbtree_postorder_for_each_entry_safe(pos, n, TreeRoot, Member) \
|
||||
{ \
|
||||
Dtor(pos); \
|
||||
kfree(pos); \
|
||||
} \
|
||||
*(TreeRoot) = RB_ROOT; \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* BEEGFS_RBTREE_FUNCTIONS() - defines a default set of rbtree functions
|
||||
* @Access access modifier of generated functions
|
||||
* @NS namespace prefix for all defined functions
|
||||
* @RootTy type of the struct that contains the tree we are building functions for
|
||||
* @RootNode name of the &struct rb_root of our tree in @RootTy
|
||||
* @KeyTy type of the trees sort key
|
||||
* @ElemTy type of the tree element. must contain a field of type @KeyTy
|
||||
* @ElemKey name of the key member in @ElemTy (must be of type @KeyTy)
|
||||
* @ElemNode node of the &struct rb_node of our tree in @ElemTy
|
||||
* @KeyCmp function or macro used to compare to @KeyTy values for tree ordering
|
||||
*
|
||||
* This macro declares a number of functions with names prefixed by @NS:
|
||||
*
|
||||
* * ``Access ElemTy* NS##_find(const RootTy*, KeyTy key)`` finds the @ElemTy with key ``key`` and
|
||||
* returns it. If none exists, %NULL is returned.
|
||||
* * ``Access bool NS##_insert(RootTy*, ElemTy* data)`` inserts the element ``data`` into the tree
|
||||
* if no element with the same key exists and return %true. If an element with the same key does
|
||||
* exist, returns %false.
|
||||
* * ``Access ElemTy* NS##_insertOrReplace(RootTy*, ElemTy* data)`` inserts ``data`` into the tree
|
||||
* if no element with the same key exists or replaced the existing item with the same key. If no
|
||||
* item existed %NULL is returned, otherwise the pointer to the previous element is returned.
|
||||
* This is analogous to how std::map::operator[] works in C++.
|
||||
* * ``access void NS##_erase(RootTy*, ElemTy* data)`` removes ``data`` from the tree. ``data`` is
|
||||
* not freed or otherwise processed, this function only removes the item and rebalances the tree
|
||||
* if necessary.
|
||||
*/
|
||||
#define BEEGFS_RBTREE_FUNCTIONS(Access, NS, RootTy, RootNode, KeyTy, ElemTy, ElemKey, ElemNode, \
|
||||
KeyCmp) \
|
||||
__attribute__((unused)) \
|
||||
Access ElemTy* NS##_find(const RootTy* root, KeyTy key) \
|
||||
{ \
|
||||
struct rb_node* node = root->RootNode.rb_node; \
|
||||
while (node) \
|
||||
{ \
|
||||
ElemTy* data = rb_entry(node, ElemTy, ElemNode); \
|
||||
int cmp = KeyCmp(key, data->ElemKey); \
|
||||
\
|
||||
if (cmp < 0) \
|
||||
node = node->rb_left; \
|
||||
else if (cmp > 0) \
|
||||
node = node->rb_right; \
|
||||
else \
|
||||
return data; \
|
||||
} \
|
||||
return NULL; \
|
||||
} \
|
||||
__attribute__((unused)) \
|
||||
Access bool NS##_insert(RootTy* root, ElemTy* data) \
|
||||
{ \
|
||||
struct rb_node** new = &root->RootNode.rb_node; \
|
||||
struct rb_node* parent = NULL; \
|
||||
while (*new) \
|
||||
{ \
|
||||
ElemTy* cur = container_of(*new, ElemTy, ElemNode); \
|
||||
int cmp = KeyCmp(data->ElemKey, cur->ElemKey); \
|
||||
\
|
||||
parent = *new; \
|
||||
if (cmp < 0) \
|
||||
new = &(*new)->rb_left; \
|
||||
else if (cmp > 0) \
|
||||
new = &(*new)->rb_right; \
|
||||
else \
|
||||
return false; \
|
||||
} \
|
||||
rb_link_node(&data->ElemNode, parent, new); \
|
||||
rb_insert_color(&data->ElemNode, &root->RootNode); \
|
||||
return true; \
|
||||
} \
|
||||
__attribute__((unused)) \
|
||||
Access ElemTy* NS##_insertOrReplace(RootTy* root, ElemTy* data) \
|
||||
{ \
|
||||
ElemTy* existing; \
|
||||
if (NS##_insert(root, data)) \
|
||||
return NULL; \
|
||||
\
|
||||
existing = NS##_find(root, data->ElemKey); \
|
||||
rb_replace_node(&existing->ElemNode, &data->ElemNode, &root->RootNode); \
|
||||
return existing; \
|
||||
} \
|
||||
__attribute__((unused)) \
|
||||
Access void NS##_erase(RootTy* root, ElemTy* data) \
|
||||
{ \
|
||||
rb_erase(&data->ElemNode, &root->RootNode); \
|
||||
}
|
||||
|
||||
#define BEEGFS_RBTREE_FOR_EACH_ENTRY(Pos, Root, Node) \
|
||||
for (Pos = rb_entry_safe(rb_first(Root), typeof(*Pos), Node); \
|
||||
Pos; \
|
||||
Pos = rb_entry_safe(rb_next(&Pos->Node), typeof(*Pos), Node))
|
||||
|
||||
/* version number of both the network protocol and the on-disk data structures that are versioned.
|
||||
* must be kept in sync with userspace. */
|
||||
#define BEEGFS_DATA_VERSION ((uint32_t)0)
|
||||
|
||||
#endif /*COMMON_H_*/
|
||||
35
client_module/source/common/FhgfsTypes.h
Normal file
35
client_module/source/common/FhgfsTypes.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef OPEN_FHGFSTYPES_H_
|
||||
#define OPEN_FHGFSTYPES_H_
|
||||
|
||||
#include <linux/in.h>
|
||||
#include <linux/time.h>
|
||||
|
||||
#include <common/toolkit/Time.h>
|
||||
|
||||
struct fhgfs_sockaddr_in
|
||||
{
|
||||
struct in_addr addr;
|
||||
__be16 port;
|
||||
};
|
||||
typedef struct fhgfs_sockaddr_in fhgfs_sockaddr_in;
|
||||
|
||||
|
||||
|
||||
struct fhgfs_stat
|
||||
{
|
||||
umode_t mode;
|
||||
unsigned int nlink;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
loff_t size;
|
||||
uint64_t blocks;
|
||||
Time atime;
|
||||
Time mtime;
|
||||
Time ctime; // attrib change time (not creation time)
|
||||
unsigned int metaVersion;
|
||||
};
|
||||
typedef struct fhgfs_stat fhgfs_stat;
|
||||
|
||||
|
||||
|
||||
#endif /* OPEN_FHGFSTYPES_H_ */
|
||||
30
client_module/source/common/Types.c
Normal file
30
client_module/source/common/Types.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "Types.h"
|
||||
|
||||
SERDES_DEFINE_SERIALIZERS_SIMPLE(, TargetMapping, struct TargetMapping,
|
||||
(targetID, , Serialization, UShort),
|
||||
(nodeID, &, NumNodeID, ))
|
||||
SERDES_DEFINE_LIST_SERIALIZERS(, TargetMappingList, struct TargetMapping,
|
||||
TargetMapping, (void), _list, false)
|
||||
|
||||
|
||||
SERDES_DEFINE_SERIALIZERS_SIMPLE(, TargetPoolMapping, struct TargetPoolMapping,
|
||||
(targetID, , Serialization, UShort),
|
||||
(poolID, &, StoragePoolId, ))
|
||||
SERDES_DEFINE_LIST_SERIALIZERS(, TargetPoolMappingList, struct TargetPoolMapping,
|
||||
TargetPoolMapping, (void), _list, false)
|
||||
|
||||
|
||||
SERDES_DEFINE_SERIALIZERS_SIMPLE(, BuddyGroupMapping, struct BuddyGroupMapping,
|
||||
(groupID, , Serialization, UShort),
|
||||
(primaryTargetID, , Serialization, UShort),
|
||||
(secondaryTargetID, , Serialization, UShort))
|
||||
SERDES_DEFINE_LIST_SERIALIZERS(, BuddyGroupMappingList, struct BuddyGroupMapping,
|
||||
BuddyGroupMapping, (void), _list, false)
|
||||
|
||||
|
||||
SERDES_DEFINE_SERIALIZERS_SIMPLE(, TargetStateMapping, struct TargetStateMapping,
|
||||
(targetID, , Serialization, UShort),
|
||||
(reachabilityState, , TargetReachabilityState, ),
|
||||
(consistencyState, , TargetConsistencyState, ))
|
||||
SERDES_DEFINE_LIST_SERIALIZERS(, TargetStateMappingList, struct TargetStateMapping,
|
||||
TargetStateMapping, (void), _list, false)
|
||||
105
client_module/source/common/Types.h
Normal file
105
client_module/source/common/Types.h
Normal file
@@ -0,0 +1,105 @@
|
||||
#ifndef BEEGFS_TYPES_H_
|
||||
#define BEEGFS_TYPES_H_
|
||||
|
||||
#include <common/storage/StoragePoolId.h>
|
||||
#include <common/toolkit/Serialization.h>
|
||||
|
||||
struct TargetMapping
|
||||
{
|
||||
uint16_t targetID;
|
||||
NumNodeID nodeID;
|
||||
|
||||
/* private: */
|
||||
union {
|
||||
struct rb_node _node; /* for use by TargetMapper */
|
||||
struct list_head _list; /* for use by de/serialized lists */
|
||||
};
|
||||
};
|
||||
|
||||
SERDES_DECLARE_SERIALIZERS(TargetMapping, struct TargetMapping)
|
||||
SERDES_DECLARE_LIST_SERIALIZERS(TargetMappingList, struct TargetMapping)
|
||||
|
||||
/* make sure to keep this in sync with TargetState in common lib */
|
||||
enum TargetReachabilityState
|
||||
{
|
||||
TargetReachabilityState_ONLINE,
|
||||
TargetReachabilityState_POFFLINE, // probably offline
|
||||
TargetReachabilityState_OFFLINE
|
||||
};
|
||||
|
||||
typedef enum TargetReachabilityState TargetReachabilityState;
|
||||
|
||||
SERDES_DEFINE_ENUM_SERIALIZERS(TargetReachabilityState, enum TargetReachabilityState,
|
||||
uint8_t, UInt8)
|
||||
|
||||
enum TargetConsistencyState
|
||||
{
|
||||
TargetConsistencyState_GOOD,
|
||||
TargetConsistencyState_NEEDS_RESYNC,
|
||||
TargetConsistencyState_BAD
|
||||
};
|
||||
|
||||
typedef enum TargetConsistencyState TargetConsistencyState;
|
||||
|
||||
SERDES_DEFINE_ENUM_SERIALIZERS(TargetConsistencyState, enum TargetConsistencyState, uint8_t, UInt8)
|
||||
|
||||
struct CombinedTargetState
|
||||
{
|
||||
TargetReachabilityState reachabilityState;
|
||||
TargetConsistencyState consistencyState;
|
||||
};
|
||||
|
||||
typedef struct CombinedTargetState CombinedTargetState;
|
||||
|
||||
struct TargetStateInfo
|
||||
{
|
||||
uint16_t targetID;
|
||||
struct CombinedTargetState state;
|
||||
|
||||
/* private */
|
||||
struct rb_node _node;
|
||||
};
|
||||
|
||||
typedef struct TargetStateInfo TargetStateInfo;
|
||||
|
||||
struct TargetPoolMapping
|
||||
{
|
||||
uint16_t targetID;
|
||||
StoragePoolId poolID;
|
||||
|
||||
/* private: */
|
||||
struct list_head _list; /* for de/serialized lists */
|
||||
};
|
||||
|
||||
SERDES_DECLARE_SERIALIZERS(TargetPoolMapping, struct TargetPoolMapping)
|
||||
SERDES_DECLARE_LIST_SERIALIZERS(TargetPoolMappingList, struct TargetPoolMapping)
|
||||
|
||||
|
||||
struct BuddyGroupMapping
|
||||
{
|
||||
uint16_t groupID;
|
||||
uint16_t primaryTargetID;
|
||||
uint16_t secondaryTargetID;
|
||||
|
||||
/* private: */
|
||||
struct list_head _list; /* for de/serialized lists */
|
||||
};
|
||||
|
||||
SERDES_DECLARE_SERIALIZERS(BuddyGroupMapping, struct BuddyGroupMapping)
|
||||
SERDES_DECLARE_LIST_SERIALIZERS(BuddyGroupMappingList, struct BuddyGroupMapping)
|
||||
|
||||
|
||||
struct TargetStateMapping
|
||||
{
|
||||
uint16_t targetID;
|
||||
TargetReachabilityState reachabilityState;
|
||||
TargetConsistencyState consistencyState;
|
||||
|
||||
/* private: */
|
||||
struct list_head _list; /* for de/serialized lists */
|
||||
};
|
||||
|
||||
SERDES_DECLARE_SERIALIZERS(TargetStateMapping, struct TargetStateMapping)
|
||||
SERDES_DECLARE_LIST_SERIALIZERS(TargetStateMappingList, struct TargetStateMapping)
|
||||
|
||||
#endif
|
||||
149
client_module/source/common/net/message/NetMessage.c
Normal file
149
client_module/source/common/net/message/NetMessage.c
Normal file
@@ -0,0 +1,149 @@
|
||||
#include "NetMessage.h"
|
||||
|
||||
/**
|
||||
* Processes this message.
|
||||
*
|
||||
* Note: Some messages might be received over a datagram socket, so the response
|
||||
* must be atomic (=> only a single sendto()-call)
|
||||
*
|
||||
* @param fromAddr must be NULL for stream sockets
|
||||
* @return false on error
|
||||
*/
|
||||
bool NetMessage_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen)
|
||||
{
|
||||
// Note: Has to be implemented appropriately by derived classes.
|
||||
// Empty implementation provided here for invalid messages and other messages
|
||||
// that don't require this way of processing (e.g. some response messages).
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all feature flags that are supported by this message. Defaults to "none", so this
|
||||
* method needs to be overridden by derived messages that actually support header feature
|
||||
* flags.
|
||||
*
|
||||
* @return combination of all supported feature flags
|
||||
*/
|
||||
unsigned NetMessage_getSupportedHeaderFeatureFlagsMask(NetMessage* this)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the (common) header part of a message from a buffer.
|
||||
*
|
||||
* Note: Message type will be set to NETMSGTYPE_Invalid if deserialization fails.
|
||||
*/
|
||||
void __NetMessage_deserializeHeader(DeserializeCtx* ctx, NetMessageHeader* outHeader)
|
||||
{
|
||||
size_t totalLength = ctx->length;
|
||||
uint64_t prefix = 0;
|
||||
// check min buffer length
|
||||
|
||||
if(unlikely(ctx->length < NETMSG_HEADER_LENGTH) )
|
||||
{
|
||||
outHeader->msgType = NETMSGTYPE_Invalid;
|
||||
return;
|
||||
}
|
||||
|
||||
// message length
|
||||
Serialization_deserializeUInt(ctx, &outHeader->msgLength);
|
||||
|
||||
// verify contained msg length
|
||||
if(unlikely(outHeader->msgLength != totalLength) )
|
||||
{
|
||||
outHeader->msgType = NETMSGTYPE_Invalid;
|
||||
return;
|
||||
}
|
||||
|
||||
// feature flags
|
||||
Serialization_deserializeUShort(ctx, &outHeader->msgFeatureFlags);
|
||||
Serialization_deserializeUInt8(ctx, &outHeader->msgCompatFeatureFlags);
|
||||
Serialization_deserializeUInt8(ctx, &outHeader->msgFlags);
|
||||
|
||||
// check message prefix
|
||||
Serialization_deserializeUInt64(ctx, &prefix);
|
||||
if (prefix != NETMSG_PREFIX)
|
||||
{
|
||||
outHeader->msgType = NETMSGTYPE_Invalid;
|
||||
return;
|
||||
}
|
||||
|
||||
if (outHeader->msgFlags & ~(MSGHDRFLAG_BUDDYMIRROR_SECOND | MSGHDRFLAG_IS_SELECTIVE_ACK |
|
||||
MSGHDRFLAG_HAS_SEQUENCE_NO))
|
||||
{
|
||||
outHeader->msgType = NETMSGTYPE_Invalid;
|
||||
return;
|
||||
}
|
||||
|
||||
// message type
|
||||
Serialization_deserializeUShort(ctx, &outHeader->msgType);
|
||||
|
||||
// targetID
|
||||
Serialization_deserializeUShort(ctx, &outHeader->msgTargetID);
|
||||
|
||||
// userID
|
||||
Serialization_deserializeUInt(ctx, &outHeader->msgUserID);
|
||||
|
||||
Serialization_deserializeUInt64(ctx, &outHeader->msgSequence);
|
||||
Serialization_deserializeUInt64(ctx, &outHeader->msgSequenceDone);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes the (common) header part of a message to a buffer.
|
||||
*
|
||||
* Note the min required size for the buf parameter! Message-specific data can be stored
|
||||
* from &buf[NETMSG_HEADER_LENGTH] on.
|
||||
* The msg->msgPrefix field is ignored and will always be stored correctly in the buffer.
|
||||
*
|
||||
* @param buf min size is NETMSG_HEADER_LENGTH
|
||||
* @return false on error (e.g. bufLen too small), true otherwise
|
||||
*/
|
||||
void __NetMessage_serializeHeader(NetMessage* this, SerializeCtx* ctx, bool zeroLengthField)
|
||||
{
|
||||
// message length
|
||||
Serialization_serializeUInt(ctx, zeroLengthField ? 0 : NetMessage_getMsgLength(this) );
|
||||
|
||||
// feature flags
|
||||
Serialization_serializeUShort(ctx, this->msgHeader.msgFeatureFlags);
|
||||
Serialization_serializeChar(ctx, this->msgHeader.msgCompatFeatureFlags);
|
||||
Serialization_serializeChar(ctx, this->msgHeader.msgFlags);
|
||||
|
||||
// message prefix
|
||||
Serialization_serializeUInt64(ctx, NETMSG_PREFIX);
|
||||
|
||||
// message type
|
||||
Serialization_serializeUShort(ctx, this->msgHeader.msgType);
|
||||
|
||||
// targetID
|
||||
Serialization_serializeUShort(ctx, this->msgHeader.msgTargetID);
|
||||
|
||||
// userID
|
||||
Serialization_serializeUInt(ctx, this->msgHeader.msgUserID);
|
||||
|
||||
Serialization_serializeUInt64(ctx, this->msgHeader.msgSequence);
|
||||
Serialization_serializeUInt64(ctx, this->msgHeader.msgSequenceDone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy function for deserialize pointers
|
||||
*/
|
||||
bool _NetMessage_deserializeDummy(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
printk_fhgfs(KERN_INFO, "Bug: Deserialize function called, although it should not\n");
|
||||
dump_stack();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy function for serialize pointers
|
||||
*/
|
||||
void _NetMessage_serializeDummy(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
printk_fhgfs(KERN_INFO, "Bug: Serialize function called, although it should not\n");
|
||||
dump_stack();
|
||||
}
|
||||
259
client_module/source/common/net/message/NetMessage.h
Normal file
259
client_module/source/common/net/message/NetMessage.h
Normal file
@@ -0,0 +1,259 @@
|
||||
#ifndef NETMESSAGE_H_
|
||||
#define NETMESSAGE_H_
|
||||
|
||||
#include <common/net/sock/NetworkInterfaceCard.h>
|
||||
#include <common/net/sock/Socket.h>
|
||||
#include <common/toolkit/Serialization.h>
|
||||
#include <common/Common.h>
|
||||
#include "NetMessageTypes.h"
|
||||
|
||||
/**
|
||||
* Note: This "class" is not meant to be instantiated directly (consider it to be abstract).
|
||||
* It contains some "virtual" methods, as you can see in the struct NetMessage. Only the virtual
|
||||
* Method processIncoming(..) has a default implementation.
|
||||
* Derived classes have a destructor with a NetMessage-Pointer (instead of the real type)
|
||||
* because of the generic virtual destructor signature.
|
||||
* Derived classes normally have two constructors: One has no arguments and is used for
|
||||
* deserialization. The other one is the standard constructor.
|
||||
*/
|
||||
|
||||
// common message constants
|
||||
// ========================
|
||||
#define NETMSG_PREFIX ((0x42474653ULL << 32) + BEEGFS_DATA_VERSION)
|
||||
#define NETMSG_MIN_LENGTH NETMSG_HEADER_LENGTH
|
||||
#define NETMSG_HEADER_LENGTH 40 /* length of the header (see struct NetMessageHeader) */
|
||||
#define NETMSG_MAX_MSG_SIZE 65536 // 64kB
|
||||
#define NETMSG_MAX_PAYLOAD_SIZE ((unsigned)(NETMSG_MAX_MSG_SIZE - NETMSG_HEADER_LENGTH))
|
||||
|
||||
#define NETMSG_DEFAULT_USERID (~0) // non-zero to avoid mixing up with root userID
|
||||
|
||||
|
||||
// forward declaration
|
||||
struct App;
|
||||
|
||||
|
||||
struct NetMessageHeader;
|
||||
typedef struct NetMessageHeader NetMessageHeader;
|
||||
struct NetMessage;
|
||||
typedef struct NetMessage NetMessage;
|
||||
|
||||
struct NetMessageOps;
|
||||
|
||||
static inline void NETMESSAGE_FREE(NetMessage* this);
|
||||
|
||||
static inline void NetMessage_init(NetMessage* this, unsigned short msgType,
|
||||
const struct NetMessageOps* ops);
|
||||
|
||||
extern void __NetMessage_deserializeHeader(DeserializeCtx* ctx, struct NetMessageHeader* outHeader);
|
||||
extern void __NetMessage_serializeHeader(NetMessage* this, SerializeCtx* ctx, bool zeroLengthField);
|
||||
|
||||
extern void _NetMessage_serializeDummy(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool _NetMessage_deserializeDummy(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
|
||||
static inline unsigned NetMessage_extractMsgLengthFromBuf(const char* recvBuf);
|
||||
static inline bool NetMessage_serialize(NetMessage* this, char* buf, size_t bufLen);
|
||||
static inline bool NetMessage_checkHeaderFeatureFlagsCompat(NetMessage* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool NetMessage_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen);
|
||||
extern unsigned NetMessage_getSupportedHeaderFeatureFlagsMask(NetMessage* this);
|
||||
|
||||
// getters & setters
|
||||
static inline unsigned short NetMessage_getMsgType(NetMessage* this);
|
||||
static inline unsigned NetMessage_getMsgHeaderFeatureFlags(NetMessage* this);
|
||||
static inline bool NetMessage_isMsgHeaderFeatureFlagSet(NetMessage* this, unsigned flag);
|
||||
static inline void NetMessage_addMsgHeaderFeatureFlag(NetMessage* this, unsigned flag);
|
||||
static inline unsigned NetMessage_getMsgLength(NetMessage* this);
|
||||
static inline void NetMessage_setMsgHeaderUserID(NetMessage* this, unsigned userID);
|
||||
static inline void NetMessage_setMsgHeaderTargetID(NetMessage* this, uint16_t userID);
|
||||
|
||||
static inline void _NetMessage_setMsgType(NetMessage* this, unsigned short msgType);
|
||||
|
||||
|
||||
#define MSGHDRFLAG_BUDDYMIRROR_SECOND (0x01)
|
||||
#define MSGHDRFLAG_IS_SELECTIVE_ACK (0x02)
|
||||
#define MSGHDRFLAG_HAS_SEQUENCE_NO (0x04)
|
||||
|
||||
struct NetMessageHeader
|
||||
{
|
||||
unsigned msgLength; // in bytes
|
||||
uint16_t msgFeatureFlags; // feature flags for derived messages (depend on msgType)
|
||||
uint8_t msgCompatFeatureFlags; /* for derived messages, similar to msgFeatureFlags, but
|
||||
"compat" because there is no check whether receiver
|
||||
understands these flags, so they might be ignored. */
|
||||
uint8_t msgFlags;
|
||||
// char* msgPrefix; // NETMSG_PREFIX_STR (8 bytes)
|
||||
unsigned short msgType; // the type of payload, defined as NETMSGTYPE_x
|
||||
uint16_t msgTargetID; // targetID (not groupID) for per-target workers on storage server
|
||||
unsigned msgUserID; // system user ID for per-user msg queues, stats etc.
|
||||
uint64_t msgSequence; // for retries, 0 if not present
|
||||
uint64_t msgSequenceDone; // a sequence number that has been fully processed, or 0
|
||||
};
|
||||
|
||||
struct NetMessageOps
|
||||
{
|
||||
void (*serializePayload) (NetMessage* this, SerializeCtx* ctx);
|
||||
bool (*deserializePayload) (NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
bool (*processIncoming) (NetMessage* this, struct App* app, fhgfs_sockaddr_in* fromAddr,
|
||||
struct Socket* sock, char* respBuf, size_t bufLen);
|
||||
unsigned (*getSupportedHeaderFeatureFlagsMask) (NetMessage* this);
|
||||
|
||||
void (*release)(NetMessage* this);
|
||||
|
||||
|
||||
// not strictly operations, but these are common to all messages and do not warrant their own
|
||||
// functions
|
||||
bool supportsSequenceNumbers;
|
||||
};
|
||||
|
||||
struct NetMessage
|
||||
{
|
||||
struct NetMessageHeader msgHeader;
|
||||
|
||||
const struct NetMessageOps* ops;
|
||||
};
|
||||
|
||||
|
||||
void NetMessage_init(NetMessage* this, unsigned short msgType, const struct NetMessageOps* ops)
|
||||
{
|
||||
memset(this, 0, sizeof(*this) ); // clear function pointers etc.
|
||||
|
||||
// this->msgLength = 0; // zero'ed by memset
|
||||
// this->msgFeatureFlags = 0; // zero'ed by memset
|
||||
|
||||
this->msgHeader.msgType = msgType;
|
||||
|
||||
// needs to be set to actual ID by some async flushers etc
|
||||
this->msgHeader.msgUserID = FhgfsCommon_getCurrentUserID();
|
||||
|
||||
// this->msgTargetID = 0; // zero'ed by memset
|
||||
|
||||
this->ops = ops;
|
||||
}
|
||||
|
||||
#define NETMESSAGE_CONSTRUCT(TYPE) \
|
||||
({ \
|
||||
TYPE* msg = os_kmalloc(sizeof(TYPE)); \
|
||||
TYPE##_init(msg); \
|
||||
(NetMessage*)msg; \
|
||||
})
|
||||
|
||||
static inline void NETMESSAGE_FREE(NetMessage* msg)
|
||||
{
|
||||
if (msg->ops->release)
|
||||
msg->ops->release(msg);
|
||||
|
||||
kfree(msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* recvBuf must be at least NETMSG_MIN_LENGTH long
|
||||
*/
|
||||
unsigned NetMessage_extractMsgLengthFromBuf(const char* recvBuf)
|
||||
{
|
||||
unsigned msgLength;
|
||||
DeserializeCtx ctx = { recvBuf, sizeof(msgLength) };
|
||||
|
||||
Serialization_deserializeUInt(&ctx, &msgLength);
|
||||
|
||||
return msgLength;
|
||||
}
|
||||
|
||||
bool NetMessage_serialize(NetMessage* this, char* buf, size_t bufLen)
|
||||
{
|
||||
SerializeCtx ctx = {
|
||||
.data = buf,
|
||||
};
|
||||
|
||||
if(unlikely(bufLen < NetMessage_getMsgLength(this) ) )
|
||||
return false;
|
||||
|
||||
__NetMessage_serializeHeader(this, &ctx, false);
|
||||
this->ops->serializePayload(this, &ctx);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the msg sender has set an incompatible feature flag.
|
||||
*
|
||||
* @return false if an incompatible feature flag was set
|
||||
*/
|
||||
bool NetMessage_checkHeaderFeatureFlagsCompat(NetMessage* this)
|
||||
{
|
||||
unsigned unsupportedFlags = ~(this->ops->getSupportedHeaderFeatureFlagsMask(this) );
|
||||
if(unlikely(this->msgHeader.msgFeatureFlags & unsupportedFlags) )
|
||||
return false; // an unsupported flag was set
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned short NetMessage_getMsgType(NetMessage* this)
|
||||
{
|
||||
return this->msgHeader.msgType;
|
||||
}
|
||||
|
||||
unsigned NetMessage_getMsgHeaderFeatureFlags(NetMessage* this)
|
||||
{
|
||||
return this->msgHeader.msgFeatureFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test flag. (For convenience and readability.)
|
||||
*
|
||||
* @return true if given flag is set.
|
||||
*/
|
||||
bool NetMessage_isMsgHeaderFeatureFlagSet(NetMessage* this, unsigned flag)
|
||||
{
|
||||
return (this->msgHeader.msgFeatureFlags & flag) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another flag without clearing the previously set flags.
|
||||
*
|
||||
* Note: The receiver will reject this message if it doesn't know the given feature flag.
|
||||
*/
|
||||
void NetMessage_addMsgHeaderFeatureFlag(NetMessage* this, unsigned flag)
|
||||
{
|
||||
this->msgHeader.msgFeatureFlags |= flag;
|
||||
}
|
||||
|
||||
unsigned NetMessage_getMsgLength(NetMessage* this)
|
||||
{
|
||||
if(!this->msgHeader.msgLength)
|
||||
{
|
||||
SerializeCtx ctx = { NULL, 0 };
|
||||
|
||||
__NetMessage_serializeHeader(this, &ctx, true);
|
||||
this->ops->serializePayload(this, &ctx);
|
||||
|
||||
this->msgHeader.msgLength = ctx.length;
|
||||
}
|
||||
|
||||
return this->msgHeader.msgLength;
|
||||
}
|
||||
|
||||
void NetMessage_setMsgHeaderUserID(NetMessage* this, unsigned userID)
|
||||
{
|
||||
this->msgHeader.msgUserID = userID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetID this has to be an actual targetID (not a groupID).
|
||||
*/
|
||||
void NetMessage_setMsgHeaderTargetID(NetMessage* this, uint16_t targetID)
|
||||
{
|
||||
this->msgHeader.msgTargetID = targetID;
|
||||
}
|
||||
|
||||
void _NetMessage_setMsgType(NetMessage* this, unsigned short msgType)
|
||||
{
|
||||
this->msgHeader.msgType = msgType;
|
||||
}
|
||||
|
||||
|
||||
#endif /*NETMESSAGE_H_*/
|
||||
273
client_module/source/common/net/message/NetMessageTypes.h
Normal file
273
client_module/source/common/net/message/NetMessageTypes.h
Normal file
@@ -0,0 +1,273 @@
|
||||
#ifndef NETMESSAGETYPES_H_
|
||||
#define NETMESSAGETYPES_H_
|
||||
|
||||
/* This file MUST be kept in sync with the corresponding fhgfs_common file!
|
||||
See fhgfs_common/source/common/net/message/NetMessageTypes.h */
|
||||
|
||||
// invalid messages
|
||||
#define NETMSGTYPE_Invalid 0
|
||||
|
||||
// nodes messages
|
||||
#define NETMSGTYPE_RemoveNode 1013
|
||||
#define NETMSGTYPE_RemoveNodeResp 1014
|
||||
#define NETMSGTYPE_GetNodes 1017
|
||||
#define NETMSGTYPE_GetNodesResp 1018
|
||||
#define NETMSGTYPE_HeartbeatRequest 1019
|
||||
#define NETMSGTYPE_Heartbeat 1020
|
||||
#define NETMSGTYPE_GetNodeCapacityPools 1021
|
||||
#define NETMSGTYPE_GetNodeCapacityPoolsResp 1022
|
||||
#define NETMSGTYPE_MapTargets 1023
|
||||
#define NETMSGTYPE_MapTargetsResp 1024
|
||||
#define NETMSGTYPE_GetTargetMappings 1025
|
||||
#define NETMSGTYPE_GetTargetMappingsResp 1026
|
||||
#define NETMSGTYPE_UnmapTarget 1027
|
||||
#define NETMSGTYPE_UnmapTargetResp 1028
|
||||
#define NETMSGTYPE_GenericDebug 1029
|
||||
#define NETMSGTYPE_GenericDebugResp 1030
|
||||
#define NETMSGTYPE_GetClientStats 1031
|
||||
#define NETMSGTYPE_GetClientStatsResp 1032
|
||||
#define NETMSGTYPE_RefreshCapacityPools 1035
|
||||
#define NETMSGTYPE_StorageBenchControlMsg 1037
|
||||
#define NETMSGTYPE_StorageBenchControlMsgResp 1038
|
||||
#define NETMSGTYPE_RegisterNode 1039
|
||||
#define NETMSGTYPE_RegisterNodeResp 1040
|
||||
#define NETMSGTYPE_RegisterTarget 1041
|
||||
#define NETMSGTYPE_RegisterTargetResp 1042
|
||||
#define NETMSGTYPE_SetMirrorBuddyGroup 1045
|
||||
#define NETMSGTYPE_SetMirrorBuddyGroupResp 1046
|
||||
#define NETMSGTYPE_GetMirrorBuddyGroups 1047
|
||||
#define NETMSGTYPE_GetMirrorBuddyGroupsResp 1048
|
||||
#define NETMSGTYPE_GetTargetStates 1049
|
||||
#define NETMSGTYPE_GetTargetStatesResp 1050
|
||||
#define NETMSGTYPE_RefreshTargetStates 1051
|
||||
#define NETMSGTYPE_GetStatesAndBuddyGroups 1053
|
||||
#define NETMSGTYPE_GetStatesAndBuddyGroupsResp 1054
|
||||
#define NETMSGTYPE_SetTargetConsistencyStates 1055
|
||||
#define NETMSGTYPE_SetTargetConsistencyStatesResp 1056
|
||||
#define NETMSGTYPE_ChangeTargetConsistencyStates 1057
|
||||
#define NETMSGTYPE_ChangeTargetConsistencyStatesResp 1058
|
||||
#define NETMSGTYPE_PublishCapacities 1059
|
||||
#define NETMSGTYPE_RemoveBuddyGroup 1060
|
||||
#define NETMSGTYPE_RemoveBuddyGroupResp 1061
|
||||
#define NETMSGTYPE_GetTargetConsistencyStates 1062
|
||||
#define NETMSGTYPE_GetTargetConsistencyStatesResp 1063
|
||||
|
||||
|
||||
// storage messages
|
||||
#define NETMSGTYPE_MkDir 2001
|
||||
#define NETMSGTYPE_MkDirResp 2002
|
||||
#define NETMSGTYPE_RmDir 2003
|
||||
#define NETMSGTYPE_RmDirResp 2004
|
||||
#define NETMSGTYPE_MkFile 2005
|
||||
#define NETMSGTYPE_MkFileResp 2006
|
||||
#define NETMSGTYPE_UnlinkFile 2007
|
||||
#define NETMSGTYPE_UnlinkFileResp 2008
|
||||
#define NETMSGTYPE_UnlinkLocalFile 2011
|
||||
#define NETMSGTYPE_UnlinkLocalFileResp 2012
|
||||
#define NETMSGTYPE_Stat 2015
|
||||
#define NETMSGTYPE_StatResp 2016
|
||||
#define NETMSGTYPE_GetChunkFileAttribs 2017
|
||||
#define NETMSGTYPE_GetChunkFileAttribsResp 2018
|
||||
#define NETMSGTYPE_TruncFile 2019
|
||||
#define NETMSGTYPE_TruncFileResp 2020
|
||||
#define NETMSGTYPE_TruncLocalFile 2021
|
||||
#define NETMSGTYPE_TruncLocalFileResp 2022
|
||||
#define NETMSGTYPE_Rename 2023
|
||||
#define NETMSGTYPE_RenameResp 2024
|
||||
#define NETMSGTYPE_SetAttr 2025
|
||||
#define NETMSGTYPE_SetAttrResp 2026
|
||||
#define NETMSGTYPE_ListDirFromOffset 2029
|
||||
#define NETMSGTYPE_ListDirFromOffsetResp 2030
|
||||
#define NETMSGTYPE_StatStoragePath 2031
|
||||
#define NETMSGTYPE_StatStoragePathResp 2032
|
||||
#define NETMSGTYPE_SetLocalAttr 2033
|
||||
#define NETMSGTYPE_SetLocalAttrResp 2034
|
||||
#define NETMSGTYPE_FindOwner 2035
|
||||
#define NETMSGTYPE_FindOwnerResp 2036
|
||||
#define NETMSGTYPE_MkLocalDir 2037
|
||||
#define NETMSGTYPE_MkLocalDirResp 2038
|
||||
#define NETMSGTYPE_RmLocalDir 2039
|
||||
#define NETMSGTYPE_RmLocalDirResp 2040
|
||||
#define NETMSGTYPE_MovingFileInsert 2041
|
||||
#define NETMSGTYPE_MovingFileInsertResp 2042
|
||||
#define NETMSGTYPE_MovingDirInsert 2043
|
||||
#define NETMSGTYPE_MovingDirInsertResp 2044
|
||||
#define NETMSGTYPE_GetEntryInfo 2045
|
||||
#define NETMSGTYPE_GetEntryInfoResp 2046
|
||||
#define NETMSGTYPE_SetDirPattern 2047
|
||||
#define NETMSGTYPE_SetDirPatternResp 2048
|
||||
#define NETMSGTYPE_GetHighResStats 2051
|
||||
#define NETMSGTYPE_GetHighResStatsResp 2052
|
||||
#define NETMSGTYPE_MkFileWithPattern 2053
|
||||
#define NETMSGTYPE_MkFileWithPatternResp 2054
|
||||
#define NETMSGTYPE_RefreshEntryInfo 2055
|
||||
#define NETMSGTYPE_RefreshEntryInfoResp 2056
|
||||
#define NETMSGTYPE_RmDirEntry 2057
|
||||
#define NETMSGTYPE_RmDirEntryResp 2058
|
||||
#define NETMSGTYPE_LookupIntent 2059
|
||||
#define NETMSGTYPE_LookupIntentResp 2060
|
||||
#define NETMSGTYPE_FindLinkOwner 2063
|
||||
#define NETMSGTYPE_FindLinkOwnerResp 2064
|
||||
#define NETMSGTYPE_MirrorMetadata 2067
|
||||
#define NETMSGTYPE_MirrorMetadataResp 2068
|
||||
#define NETMSGTYPE_SetMetadataMirroring 2069
|
||||
#define NETMSGTYPE_SetMetadataMirroringResp 2070
|
||||
#define NETMSGTYPE_Hardlink 2071
|
||||
#define NETMSGTYPE_HardlinkResp 2072
|
||||
#define NETMSGTYPE_SetQuota 2075
|
||||
#define NETMSGTYPE_SetQuotaResp 2076
|
||||
#define NETMSGTYPE_SetExceededQuota 2077
|
||||
#define NETMSGTYPE_SetExceededQuotaResp 2078
|
||||
#define NETMSGTYPE_RequestExceededQuota 2079
|
||||
#define NETMSGTYPE_RequestExceededQuotaResp 2080
|
||||
#define NETMSGTYPE_UpdateDirParent 2081
|
||||
#define NETMSGTYPE_UpdateDirParentResp 2082
|
||||
#define NETMSGTYPE_ResyncLocalFile 2083
|
||||
#define NETMSGTYPE_ResyncLocalFileResp 2084
|
||||
#define NETMSGTYPE_StartStorageTargetResync 2085
|
||||
#define NETMSGTYPE_StartStorageTargetResyncResp 2086
|
||||
#define NETMSGTYPE_StorageResyncStarted 2087
|
||||
#define NETMSGTYPE_StorageResyncStartedResp 2088
|
||||
#define NETMSGTYPE_ListChunkDirIncremental 2089
|
||||
#define NETMSGTYPE_ListChunkDirIncrementalResp 2090
|
||||
#define NETMSGTYPE_RmChunkPaths 2091
|
||||
#define NETMSGTYPE_RmChunkPathsResp 2092
|
||||
#define NETMSGTYPE_GetStorageResyncStats 2093
|
||||
#define NETMSGTYPE_GetStorageResyncStatsResp 2094
|
||||
#define NETMSGTYPE_SetLastBuddyCommOverride 2095
|
||||
#define NETMSGTYPE_SetLastBuddyCommOverrideResp 2096
|
||||
#define NETMSGTYPE_GetQuotaInfo 2097
|
||||
#define NETMSGTYPE_GetQuotaInfoResp 2098
|
||||
#define NETMSGTYPE_SetStorageTargetInfo 2099
|
||||
#define NETMSGTYPE_SetStorageTargetInfoResp 2100
|
||||
#define NETMSGTYPE_ListXAttr 2101
|
||||
#define NETMSGTYPE_ListXAttrResp 2102
|
||||
#define NETMSGTYPE_GetXAttr 2103
|
||||
#define NETMSGTYPE_GetXAttrResp 2104
|
||||
#define NETMSGTYPE_RemoveXAttr 2105
|
||||
#define NETMSGTYPE_RemoveXAttrResp 2106
|
||||
#define NETMSGTYPE_SetXAttr 2107
|
||||
#define NETMSGTYPE_SetXAttrResp 2108
|
||||
#define NETMSGTYPE_GetDefaultQuota 2109
|
||||
#define NETMSGTYPE_GetDefaultQuotaResp 2110
|
||||
#define NETMSGTYPE_SetDefaultQuota 2111
|
||||
#define NETMSGTYPE_SetDefaultQuotaResp 2112
|
||||
#define NETMSGTYPE_ResyncSessionStore 2113
|
||||
#define NETMSGTYPE_ResyncSessionStoreResp 2114
|
||||
#define NETMSGTYPE_ResyncRawInodes 2115
|
||||
#define NETMSGTYPE_ResyncRawInodesResp 2116
|
||||
#define NETMSGTYPE_GetMetaResyncStats 2117
|
||||
#define NETMSGTYPE_GetMetaResyncStatsResp 2118
|
||||
#define NETMSGTYPE_MoveFileInode 2119
|
||||
#define NETMSGTYPE_MoveFileInodeResp 2120
|
||||
#define NETMSGTYPE_UnlinkLocalFileInode 2121
|
||||
#define NETMSGTYPE_UnlinkLocalFileInodeResp 2122
|
||||
#define NETMSGTYPE_SetFilePattern 2123
|
||||
#define NETMSGTYPE_SetFilePatternResp 2124
|
||||
#define NETMSGTYPE_CpChunkPaths 2125
|
||||
#define NETMSGTYPE_CpChunkPathsResp 2126
|
||||
#define NETMSGTYPE_ChunkBalance 2127
|
||||
#define NETMSGTYPE_ChunkBalanceResp 2128
|
||||
#define NETMSGTYPE_StripePatternUpdate 2129
|
||||
#define NETMSGTYPE_StripePatternUpdateResp 2130
|
||||
#define NETMSGTYPE_SetFileState 2131
|
||||
#define NETMSGTYPE_SetFileStateResp 2132
|
||||
|
||||
// session messages
|
||||
#define NETMSGTYPE_OpenFile 3001
|
||||
#define NETMSGTYPE_OpenFileResp 3002
|
||||
#define NETMSGTYPE_CloseFile 3003
|
||||
#define NETMSGTYPE_CloseFileResp 3004
|
||||
#define NETMSGTYPE_OpenLocalFile 3005
|
||||
#define NETMSGTYPE_OpenLocalFileResp 3006
|
||||
#define NETMSGTYPE_CloseChunkFile 3007
|
||||
#define NETMSGTYPE_CloseChunkFileResp 3008
|
||||
#define NETMSGTYPE_WriteLocalFile 3009
|
||||
#define NETMSGTYPE_WriteLocalFileResp 3010
|
||||
#define NETMSGTYPE_FSyncLocalFile 3013
|
||||
#define NETMSGTYPE_FSyncLocalFileResp 3014
|
||||
#define NETMSGTYPE_ReadLocalFileV2 3019
|
||||
#define NETMSGTYPE_RefreshSession 3021
|
||||
#define NETMSGTYPE_RefreshSessionResp 3022
|
||||
#define NETMSGTYPE_LockGranted 3023
|
||||
#define NETMSGTYPE_FLockEntry 3025
|
||||
#define NETMSGTYPE_FLockEntryResp 3026
|
||||
#define NETMSGTYPE_FLockRange 3027
|
||||
#define NETMSGTYPE_FLockRangeResp 3028
|
||||
#define NETMSGTYPE_FLockAppend 3029
|
||||
#define NETMSGTYPE_FLockAppendResp 3030
|
||||
#define NETMSGTYPE_AckNotify 3031
|
||||
#define NETMSGTYPE_AckNotifyResp 3032
|
||||
#define NETMSGTYPE_BumpFileVersion 3033
|
||||
#define NETMSGTYPE_BumpFileVersionResp 3034
|
||||
#define NETMSGTYPE_GetFileVersion 3035
|
||||
#define NETMSGTYPE_GetFileVersionResp 3036
|
||||
#ifdef BEEGFS_NVFS
|
||||
#define NETMSGTYPE_WriteLocalFileRDMA 3037
|
||||
#define NETMSGTYPE_WriteLocalFileRDMAResp 3038
|
||||
#define NETMSGTYPE_ReadLocalFileRDMA 3039
|
||||
#define NETMSGTYPE_ReadLocalFileRDMAResp 3040
|
||||
#endif
|
||||
|
||||
// control messages
|
||||
#define NETMSGTYPE_SetChannelDirect 4001
|
||||
#define NETMSGTYPE_Ack 4003
|
||||
#define NETMSGTYPE_Dummy 4005
|
||||
#define NETMSGTYPE_AuthenticateChannel 4007
|
||||
#define NETMSGTYPE_GenericResponse 4009
|
||||
#define NETMSGTYPE_PeerInfo 4011
|
||||
|
||||
// mon messages
|
||||
#define NETMSGTYPE_GetNodesFromRootMetaNode 6001
|
||||
#define NETMSGTYPE_SendNodesList 6002
|
||||
#define NETMSGTYPE_RequestMetaData 6003
|
||||
#define NETMSGTYPE_RequestStorageData 6004
|
||||
#define NETMSGTYPE_RequestMetaDataResp 6005
|
||||
#define NETMSGTYPE_RequestStorageDataResp 6006
|
||||
|
||||
// fsck messages
|
||||
#define NETMSGTYPE_RetrieveDirEntries 7001
|
||||
#define NETMSGTYPE_RetrieveDirEntriesResp 7002
|
||||
#define NETMSGTYPE_RetrieveInodes 7003
|
||||
#define NETMSGTYPE_RetrieveInodesResp 7004
|
||||
#define NETMSGTYPE_RetrieveChunks 7005
|
||||
#define NETMSGTYPE_RetrieveChunksResp 7006
|
||||
#define NETMSGTYPE_RetrieveFsIDs 7007
|
||||
#define NETMSGTYPE_RetrieveFsIDsResp 7008
|
||||
#define NETMSGTYPE_DeleteDirEntries 7009
|
||||
#define NETMSGTYPE_DeleteDirEntriesResp 7010
|
||||
#define NETMSGTYPE_CreateDefDirInodes 7011
|
||||
#define NETMSGTYPE_CreateDefDirInodesResp 7012
|
||||
#define NETMSGTYPE_FixInodeOwnersInDentry 7013
|
||||
#define NETMSGTYPE_FixInodeOwnersInDentryResp 7014
|
||||
#define NETMSGTYPE_FixInodeOwners 7015
|
||||
#define NETMSGTYPE_FixInodeOwnersResp 7016
|
||||
#define NETMSGTYPE_LinkToLostAndFound 7017
|
||||
#define NETMSGTYPE_LinkToLostAndFoundResp 7018
|
||||
#define NETMSGTYPE_DeleteChunks 7019
|
||||
#define NETMSGTYPE_DeleteChunksResp 7020
|
||||
#define NETMSGTYPE_CreateEmptyContDirs 7021
|
||||
#define NETMSGTYPE_CreateEmptyContDirsResp 7022
|
||||
#define NETMSGTYPE_UpdateFileAttribs 7023
|
||||
#define NETMSGTYPE_UpdateFileAttribsResp 7024
|
||||
#define NETMSGTYPE_UpdateDirAttribs 7025
|
||||
#define NETMSGTYPE_UpdateDirAttribsResp 7026
|
||||
#define NETMSGTYPE_RemoveInodes 7027
|
||||
#define NETMSGTYPE_RemoveInodesResp 7028
|
||||
#define NETMSGTYPE_RecreateFsIDs 7031
|
||||
#define NETMSGTYPE_RecreateFsIDsResp 7032
|
||||
#define NETMSGTYPE_RecreateDentries 7033
|
||||
#define NETMSGTYPE_RecreateDentriesResp 7034
|
||||
#define NETMSGTYPE_FsckModificationEvent 7035
|
||||
#define NETMSGTYPE_FsckSetEventLogging 7036
|
||||
#define NETMSGTYPE_FsckSetEventLoggingResp 7037
|
||||
#define NETMSGTYPE_FetchFsckChunkList 7038
|
||||
#define NETMSGTYPE_FetchFsckChunkListResp 7039
|
||||
#define NETMSGTYPE_AdjustChunkPermissions 7040
|
||||
#define NETMSGTYPE_AdjustChunkPermissionsResp 7041
|
||||
#define NETMSGTYPE_MoveChunkFile 7042
|
||||
#define NETMSGTYPE_MoveChunkFileResp 7043
|
||||
#define NETMSGTYPE_CheckAndRepairDupInode 7044
|
||||
#define NETMSGTYPE_CheckAndRepairDupInodeResp 7045
|
||||
|
||||
#endif /*NETMESSAGETYPES_H_*/
|
||||
22
client_module/source/common/net/message/SimpleInt64Msg.c
Normal file
22
client_module/source/common/net/message/SimpleInt64Msg.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "SimpleInt64Msg.h"
|
||||
|
||||
const struct NetMessageOps SimpleInt64Msg_Ops = {
|
||||
.serializePayload = SimpleInt64Msg_serializePayload,
|
||||
.deserializePayload = SimpleInt64Msg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void SimpleInt64Msg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
SimpleInt64Msg* thisCast = (SimpleInt64Msg*)this;
|
||||
|
||||
Serialization_serializeInt64(ctx, thisCast->value);
|
||||
}
|
||||
|
||||
bool SimpleInt64Msg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
SimpleInt64Msg* thisCast = (SimpleInt64Msg*)this;
|
||||
|
||||
return Serialization_deserializeInt64(ctx, &thisCast->value);
|
||||
}
|
||||
46
client_module/source/common/net/message/SimpleInt64Msg.h
Normal file
46
client_module/source/common/net/message/SimpleInt64Msg.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef SIMPLEINT64MSG_H_
|
||||
#define SIMPLEINT64MSG_H_
|
||||
|
||||
#include "NetMessage.h"
|
||||
|
||||
struct SimpleInt64Msg;
|
||||
typedef struct SimpleInt64Msg SimpleInt64Msg;
|
||||
|
||||
static inline void SimpleInt64Msg_init(SimpleInt64Msg* this, unsigned short msgType);
|
||||
static inline void SimpleInt64Msg_initFromValue(SimpleInt64Msg* this, unsigned short msgType,
|
||||
int64_t value);
|
||||
|
||||
// virtual functions
|
||||
extern void SimpleInt64Msg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool SimpleInt64Msg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
// getters & setters
|
||||
static inline int64_t SimpleInt64Msg_getValue(SimpleInt64Msg* this);
|
||||
|
||||
struct SimpleInt64Msg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
int64_t value;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps SimpleInt64Msg_Ops;
|
||||
|
||||
void SimpleInt64Msg_init(SimpleInt64Msg* this, unsigned short msgType)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, msgType, &SimpleInt64Msg_Ops);
|
||||
}
|
||||
|
||||
void SimpleInt64Msg_initFromValue(SimpleInt64Msg* this, unsigned short msgType, int64_t value)
|
||||
{
|
||||
SimpleInt64Msg_init(this, msgType);
|
||||
|
||||
this->value = value;
|
||||
}
|
||||
|
||||
int64_t SimpleInt64Msg_getValue(SimpleInt64Msg* this)
|
||||
{
|
||||
return this->value;
|
||||
}
|
||||
|
||||
#endif /*SIMPLEINT64MSG_H_*/
|
||||
22
client_module/source/common/net/message/SimpleIntMsg.c
Normal file
22
client_module/source/common/net/message/SimpleIntMsg.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "SimpleIntMsg.h"
|
||||
|
||||
const struct NetMessageOps SimpleIntMsg_Ops = {
|
||||
.serializePayload = SimpleIntMsg_serializePayload,
|
||||
.deserializePayload = SimpleIntMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void SimpleIntMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
SimpleIntMsg* thisCast = (SimpleIntMsg*)this;
|
||||
|
||||
Serialization_serializeInt(ctx, thisCast->value);
|
||||
}
|
||||
|
||||
bool SimpleIntMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
SimpleIntMsg* thisCast = (SimpleIntMsg*)this;
|
||||
|
||||
return Serialization_deserializeInt(ctx, &thisCast->value);
|
||||
}
|
||||
48
client_module/source/common/net/message/SimpleIntMsg.h
Normal file
48
client_module/source/common/net/message/SimpleIntMsg.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef SIMPLEINTMSG_H_
|
||||
#define SIMPLEINTMSG_H_
|
||||
|
||||
#include "NetMessage.h"
|
||||
|
||||
struct SimpleIntMsg;
|
||||
typedef struct SimpleIntMsg SimpleIntMsg;
|
||||
|
||||
static inline void SimpleIntMsg_init(SimpleIntMsg* this, unsigned short msgType);
|
||||
static inline void SimpleIntMsg_initFromValue(SimpleIntMsg* this, unsigned short msgType,
|
||||
int value);
|
||||
|
||||
// virtual functions
|
||||
extern void SimpleIntMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool SimpleIntMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
// getters & setters
|
||||
static inline int SimpleIntMsg_getValue(SimpleIntMsg* this);
|
||||
|
||||
|
||||
struct SimpleIntMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
int value;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps SimpleIntMsg_Ops;
|
||||
|
||||
void SimpleIntMsg_init(SimpleIntMsg* this, unsigned short msgType)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, msgType, &SimpleIntMsg_Ops);
|
||||
}
|
||||
|
||||
void SimpleIntMsg_initFromValue(SimpleIntMsg* this, unsigned short msgType, int value)
|
||||
{
|
||||
SimpleIntMsg_init(this, msgType);
|
||||
|
||||
this->value = value;
|
||||
}
|
||||
|
||||
int SimpleIntMsg_getValue(SimpleIntMsg* this)
|
||||
{
|
||||
return this->value;
|
||||
}
|
||||
|
||||
|
||||
#endif /*SIMPLEINTMSG_H_*/
|
||||
31
client_module/source/common/net/message/SimpleIntStringMsg.c
Normal file
31
client_module/source/common/net/message/SimpleIntStringMsg.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "SimpleIntStringMsg.h"
|
||||
|
||||
const struct NetMessageOps SimpleIntStringMsg_Ops = {
|
||||
.serializePayload = SimpleIntStringMsg_serializePayload,
|
||||
.deserializePayload = SimpleIntStringMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void SimpleIntStringMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
SimpleIntStringMsg* thisCast = (SimpleIntStringMsg*)this;
|
||||
|
||||
Serialization_serializeInt(ctx, thisCast->intValue);
|
||||
Serialization_serializeStr(ctx, thisCast->strValueLen, thisCast->strValue);
|
||||
}
|
||||
|
||||
bool SimpleIntStringMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
SimpleIntStringMsg* thisCast = (SimpleIntStringMsg*)this;
|
||||
|
||||
// intValue
|
||||
if(!Serialization_deserializeInt(ctx, &thisCast->intValue) )
|
||||
return false;
|
||||
|
||||
// strValue
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->strValueLen, &thisCast->strValue) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
69
client_module/source/common/net/message/SimpleIntStringMsg.h
Normal file
69
client_module/source/common/net/message/SimpleIntStringMsg.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#ifndef SIMPLEINTSTRINGMSG_H_
|
||||
#define SIMPLEINTSTRINGMSG_H_
|
||||
|
||||
#include "NetMessage.h"
|
||||
|
||||
struct SimpleIntStringMsg;
|
||||
typedef struct SimpleIntStringMsg SimpleIntStringMsg;
|
||||
|
||||
static inline void SimpleIntStringMsg_init(SimpleIntStringMsg* this, unsigned short msgType);
|
||||
static inline void SimpleIntStringMsg_initFromValue(SimpleIntStringMsg* this, unsigned short msgType,
|
||||
int intValue, const char* strValue);
|
||||
|
||||
// virtual functions
|
||||
extern void SimpleIntStringMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool SimpleIntStringMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
// getters & setters
|
||||
static inline int SimpleIntStringMsg_getIntValue(SimpleIntStringMsg* this);
|
||||
static inline const char* SimpleIntStringMsg_getStrValue(SimpleIntStringMsg* this);
|
||||
|
||||
|
||||
/**
|
||||
* Simple message containing an integer value and a string (e.g. int error code and human-readable
|
||||
* explantion with more details as string).
|
||||
*/
|
||||
struct SimpleIntStringMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
int intValue;
|
||||
|
||||
const char* strValue;
|
||||
unsigned strValueLen;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps SimpleIntStringMsg_Ops;
|
||||
|
||||
void SimpleIntStringMsg_init(SimpleIntStringMsg* this, unsigned short msgType)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, msgType, &SimpleIntStringMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param strValue just a reference, so don't free or modify it while this msg is used.
|
||||
*/
|
||||
void SimpleIntStringMsg_initFromValue(SimpleIntStringMsg* this, unsigned short msgType,
|
||||
int intValue, const char* strValue)
|
||||
{
|
||||
SimpleIntStringMsg_init(this, msgType);
|
||||
|
||||
this->intValue = intValue;
|
||||
|
||||
this->strValue = strValue;
|
||||
this->strValueLen = strlen(strValue);
|
||||
}
|
||||
|
||||
int SimpleIntStringMsg_getIntValue(SimpleIntStringMsg* this)
|
||||
{
|
||||
return this->intValue;
|
||||
}
|
||||
|
||||
const char* SimpleIntStringMsg_getStrValue(SimpleIntStringMsg* this)
|
||||
{
|
||||
return this->strValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* SIMPLEINTSTRINGMSG_H_ */
|
||||
19
client_module/source/common/net/message/SimpleMsg.c
Normal file
19
client_module/source/common/net/message/SimpleMsg.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "SimpleMsg.h"
|
||||
|
||||
const struct NetMessageOps SimpleMsg_Ops = {
|
||||
.serializePayload = SimpleMsg_serializePayload,
|
||||
.deserializePayload = SimpleMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void SimpleMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
// nothing to be done here for simple messages
|
||||
}
|
||||
|
||||
bool SimpleMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
// nothing to be done here for simple messages
|
||||
return true;
|
||||
}
|
||||
33
client_module/source/common/net/message/SimpleMsg.h
Normal file
33
client_module/source/common/net/message/SimpleMsg.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef SIMPLEMSG_H_
|
||||
#define SIMPLEMSG_H_
|
||||
|
||||
#include "NetMessage.h"
|
||||
|
||||
/**
|
||||
* Note: Simple messages are defined by the header (resp. the msgType) only and
|
||||
* require no additional data
|
||||
*/
|
||||
|
||||
struct SimpleMsg;
|
||||
typedef struct SimpleMsg SimpleMsg;
|
||||
|
||||
static inline void SimpleMsg_init(SimpleMsg* this, unsigned short msgType);
|
||||
|
||||
// virtual functions
|
||||
extern void SimpleMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool SimpleMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
|
||||
struct SimpleMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps SimpleMsg_Ops;
|
||||
|
||||
void SimpleMsg_init(SimpleMsg* this, unsigned short msgType)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, msgType, &SimpleMsg_Ops);
|
||||
}
|
||||
|
||||
#endif /*SIMPLEMSG_H_*/
|
||||
22
client_module/source/common/net/message/SimpleStringMsg.c
Normal file
22
client_module/source/common/net/message/SimpleStringMsg.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "SimpleStringMsg.h"
|
||||
|
||||
const struct NetMessageOps SimpleStringMsg_Ops = {
|
||||
.serializePayload = SimpleStringMsg_serializePayload,
|
||||
.deserializePayload = SimpleStringMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void SimpleStringMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
SimpleStringMsg* thisCast = (SimpleStringMsg*)this;
|
||||
|
||||
Serialization_serializeStr(ctx, thisCast->valueLen, thisCast->value);
|
||||
}
|
||||
|
||||
bool SimpleStringMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
SimpleStringMsg* thisCast = (SimpleStringMsg*)this;
|
||||
|
||||
return Serialization_deserializeStr(ctx, &thisCast->valueLen, &thisCast->value);
|
||||
}
|
||||
48
client_module/source/common/net/message/SimpleStringMsg.h
Normal file
48
client_module/source/common/net/message/SimpleStringMsg.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef SIMPLESTRINGMSG_H_
|
||||
#define SIMPLESTRINGMSG_H_
|
||||
|
||||
#include "NetMessage.h"
|
||||
|
||||
struct SimpleStringMsg;
|
||||
typedef struct SimpleStringMsg SimpleStringMsg;
|
||||
|
||||
static inline void SimpleStringMsg_init(SimpleStringMsg* this, unsigned short msgType);
|
||||
static inline void SimpleStringMsg_initFromValue(SimpleStringMsg* this, unsigned short msgType,
|
||||
const char* value);
|
||||
|
||||
// virtual functions
|
||||
extern void SimpleStringMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool SimpleStringMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
// getters & setters
|
||||
static inline const char* SimpleStringMsg_getValue(SimpleStringMsg* this);
|
||||
|
||||
struct SimpleStringMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
const char* value;
|
||||
unsigned valueLen;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps SimpleStringMsg_Ops;
|
||||
|
||||
void SimpleStringMsg_init(SimpleStringMsg* this, unsigned short msgType)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, msgType, &SimpleStringMsg_Ops);
|
||||
}
|
||||
|
||||
void SimpleStringMsg_initFromValue(SimpleStringMsg* this, unsigned short msgType, const char* value)
|
||||
{
|
||||
SimpleStringMsg_init(this, msgType);
|
||||
|
||||
this->value = value;
|
||||
this->valueLen = strlen(value);
|
||||
}
|
||||
|
||||
const char* SimpleStringMsg_getValue(SimpleStringMsg* this)
|
||||
{
|
||||
return this->value;
|
||||
}
|
||||
|
||||
#endif /* SIMPLESTRINGMSG_H_ */
|
||||
22
client_module/source/common/net/message/SimpleUInt16Msg.c
Normal file
22
client_module/source/common/net/message/SimpleUInt16Msg.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "SimpleUInt16Msg.h"
|
||||
|
||||
const struct NetMessageOps SimpleUInt16Msg_Ops = {
|
||||
.serializePayload = SimpleUInt16Msg_serializePayload,
|
||||
.deserializePayload = SimpleUInt16Msg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void SimpleUInt16Msg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
SimpleUInt16Msg* thisCast = (SimpleUInt16Msg*)this;
|
||||
|
||||
Serialization_serializeUShort(ctx, thisCast->value);
|
||||
}
|
||||
|
||||
bool SimpleUInt16Msg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
SimpleUInt16Msg* thisCast = (SimpleUInt16Msg*)this;
|
||||
|
||||
return Serialization_deserializeUShort(ctx, &thisCast->value);
|
||||
}
|
||||
48
client_module/source/common/net/message/SimpleUInt16Msg.h
Normal file
48
client_module/source/common/net/message/SimpleUInt16Msg.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef SIMPLEUINT16MSG_H_
|
||||
#define SIMPLEUINT16MSG_H_
|
||||
|
||||
#include "NetMessage.h"
|
||||
|
||||
struct SimpleUInt16Msg;
|
||||
typedef struct SimpleUInt16Msg SimpleUInt16Msg;
|
||||
|
||||
static inline void SimpleUInt16Msg_init(SimpleUInt16Msg* this, unsigned short msgType);
|
||||
static inline void SimpleUInt16Msg_initFromValue(SimpleUInt16Msg* this, unsigned short msgType,
|
||||
uint16_t value);
|
||||
|
||||
// virtual functions
|
||||
extern void SimpleUInt16Msg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool SimpleUInt16Msg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
// getters & setters
|
||||
static inline uint16_t SimpleUInt16Msg_getValue(SimpleUInt16Msg* this);
|
||||
|
||||
|
||||
struct SimpleUInt16Msg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
uint16_t value;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps SimpleUInt16Msg_Ops;
|
||||
|
||||
void SimpleUInt16Msg_init(SimpleUInt16Msg* this, unsigned short msgType)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, msgType, &SimpleUInt16Msg_Ops);
|
||||
}
|
||||
|
||||
void SimpleUInt16Msg_initFromValue(SimpleUInt16Msg* this, unsigned short msgType, uint16_t value)
|
||||
{
|
||||
SimpleUInt16Msg_init(this, msgType);
|
||||
|
||||
this->value = value;
|
||||
}
|
||||
|
||||
uint16_t SimpleUInt16Msg_getValue(SimpleUInt16Msg* this)
|
||||
{
|
||||
return this->value;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SIMPLEUINT16MSG_H_ */
|
||||
40
client_module/source/common/net/message/control/AckMsgEx.h
Normal file
40
client_module/source/common/net/message/control/AckMsgEx.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef ACKMSGEX_H_
|
||||
#define ACKMSGEX_H_
|
||||
|
||||
#include "../SimpleStringMsg.h"
|
||||
|
||||
|
||||
struct AckMsgEx;
|
||||
typedef struct AckMsgEx AckMsgEx;
|
||||
|
||||
static inline void AckMsgEx_init(AckMsgEx* this);
|
||||
static inline void AckMsgEx_initFromValue(AckMsgEx* this,
|
||||
const char* value);
|
||||
|
||||
// getters & setters
|
||||
static inline const char* AckMsgEx_getValue(AckMsgEx* this);
|
||||
|
||||
|
||||
struct AckMsgEx
|
||||
{
|
||||
SimpleStringMsg simpleStringMsg;
|
||||
};
|
||||
|
||||
|
||||
void AckMsgEx_init(AckMsgEx* this)
|
||||
{
|
||||
SimpleStringMsg_init( (SimpleStringMsg*)this, NETMSGTYPE_Ack);
|
||||
}
|
||||
|
||||
void AckMsgEx_initFromValue(AckMsgEx* this, const char* value)
|
||||
{
|
||||
SimpleStringMsg_initFromValue( (SimpleStringMsg*)this, NETMSGTYPE_Ack, value);
|
||||
}
|
||||
|
||||
const char* AckMsgEx_getValue(AckMsgEx* this)
|
||||
{
|
||||
return SimpleStringMsg_getValue( (SimpleStringMsg*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /* ACKMSGEX_H_ */
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef AUTHENTICATECHANNELMSG_H_
|
||||
#define AUTHENTICATECHANNELMSG_H_
|
||||
|
||||
#include <common/net/message/SimpleInt64Msg.h>
|
||||
|
||||
|
||||
struct AuthenticateChannelMsg;
|
||||
typedef struct AuthenticateChannelMsg AuthenticateChannelMsg;
|
||||
|
||||
|
||||
static inline void AuthenticateChannelMsg_init(AuthenticateChannelMsg* this);
|
||||
static inline void AuthenticateChannelMsg_initFromValue(AuthenticateChannelMsg* this,
|
||||
uint64_t authHash);
|
||||
|
||||
|
||||
struct AuthenticateChannelMsg
|
||||
{
|
||||
SimpleInt64Msg simpleInt64Msg;
|
||||
};
|
||||
|
||||
|
||||
void AuthenticateChannelMsg_init(AuthenticateChannelMsg* this)
|
||||
{
|
||||
SimpleInt64Msg_init( (SimpleInt64Msg*)this, NETMSGTYPE_AuthenticateChannel);
|
||||
}
|
||||
|
||||
void AuthenticateChannelMsg_initFromValue(AuthenticateChannelMsg* this, uint64_t authHash)
|
||||
{
|
||||
SimpleInt64Msg_initFromValue( (SimpleInt64Msg*)this, NETMSGTYPE_AuthenticateChannel, authHash);
|
||||
}
|
||||
|
||||
#endif /* AUTHENTICATECHANNELMSG_H_ */
|
||||
@@ -0,0 +1,65 @@
|
||||
#ifndef GENERICRESPONSEMSG_H_
|
||||
#define GENERICRESPONSEMSG_H_
|
||||
|
||||
#include <common/net/message/SimpleIntStringMsg.h>
|
||||
|
||||
|
||||
/**
|
||||
* Note: Remember to keep this in sync with userspace common lib.
|
||||
*/
|
||||
enum GenericRespMsgCode
|
||||
{
|
||||
GenericRespMsgCode_TRYAGAIN = 0, /* requestor shall try again in a few seconds */
|
||||
GenericRespMsgCode_INDIRECTCOMMERR = 1, /* indirect communication error and requestor should
|
||||
try again (e.g. msg forwarding to other server failed) */
|
||||
GenericRespMsgCode_NEWSEQNOBASE = 2, /* client has restarted its seq# sequence. server provides
|
||||
the new starting seq#. */
|
||||
};
|
||||
typedef enum GenericRespMsgCode GenericRespMsgCode;
|
||||
|
||||
|
||||
struct GenericResponseMsg;
|
||||
typedef struct GenericResponseMsg GenericResponseMsg;
|
||||
|
||||
|
||||
static inline void GenericResponseMsg_init(GenericResponseMsg* this);
|
||||
|
||||
// getters & setters
|
||||
static inline GenericRespMsgCode GenericResponseMsg_getControlCode(GenericResponseMsg* this);
|
||||
static inline const char* GenericResponseMsg_getLogStr(GenericResponseMsg* this);
|
||||
|
||||
|
||||
/**
|
||||
* A generic response that can be sent as a reply to any message. This special control message will
|
||||
* be handled internally by the requestors MessageTk::requestResponse...() method.
|
||||
*
|
||||
* This is intended to submit internal information (like asking for a communication retry) to the
|
||||
* requestors MessageTk through the control code. So the MessageTk caller on the requestor side
|
||||
* will never actually see this GenericResponseMsg.
|
||||
*
|
||||
* The message string is intended to provide additional human-readable information like why this
|
||||
* control code was submitted instead of the actually expected response msg.
|
||||
*/
|
||||
struct GenericResponseMsg
|
||||
{
|
||||
SimpleIntStringMsg simpleIntStringMsg;
|
||||
};
|
||||
|
||||
|
||||
void GenericResponseMsg_init(GenericResponseMsg* this)
|
||||
{
|
||||
SimpleIntStringMsg_init( (SimpleIntStringMsg*)this, NETMSGTYPE_GenericResponse);
|
||||
}
|
||||
|
||||
GenericRespMsgCode GenericResponseMsg_getControlCode(GenericResponseMsg* this)
|
||||
{
|
||||
return (GenericRespMsgCode)SimpleIntStringMsg_getIntValue( (SimpleIntStringMsg*)this);
|
||||
}
|
||||
|
||||
const char* GenericResponseMsg_getLogStr(GenericResponseMsg* this)
|
||||
{
|
||||
return SimpleIntStringMsg_getStrValue( (SimpleIntStringMsg*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /* GENERICRESPONSEMSG_H_ */
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "PeerInfoMsg.h"
|
||||
|
||||
static void PeerInfoMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
PeerInfoMsg* thisCast = (PeerInfoMsg*)this;
|
||||
|
||||
Serialization_serializeUInt(ctx, thisCast->type);
|
||||
NumNodeID_serialize(ctx, &thisCast->id);
|
||||
}
|
||||
|
||||
static bool PeerInfoMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
PeerInfoMsg* thisCast = (PeerInfoMsg*)this;
|
||||
|
||||
unsigned type = 0;
|
||||
bool result =
|
||||
Serialization_deserializeUInt(ctx, &type)
|
||||
&& NumNodeID_deserialize(ctx, &thisCast->id);
|
||||
|
||||
thisCast->type = type;
|
||||
return result;
|
||||
}
|
||||
|
||||
const struct NetMessageOps PeerInfoMsg_Ops = {
|
||||
.serializePayload = PeerInfoMsg_serializePayload,
|
||||
.deserializePayload = PeerInfoMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef COMMON_NET_MESSAGE_CONTROL_PEERINFOMSG_H
|
||||
#define COMMON_NET_MESSAGE_CONTROL_PEERINFOMSG_H
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/nodes/Node.h>
|
||||
|
||||
struct PeerInfoMsg;
|
||||
typedef struct PeerInfoMsg PeerInfoMsg;
|
||||
|
||||
struct PeerInfoMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
NodeType type;
|
||||
NumNodeID id;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps PeerInfoMsg_Ops;
|
||||
|
||||
static inline void PeerInfoMsg_init(PeerInfoMsg* this, NodeType type, NumNodeID id)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_PeerInfo, &PeerInfoMsg_Ops);
|
||||
|
||||
this->type = type;
|
||||
this->id = id;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef SETCHANNELDIRECTMSG_H_
|
||||
#define SETCHANNELDIRECTMSG_H_
|
||||
|
||||
#include <common/net/message/SimpleIntMsg.h>
|
||||
|
||||
|
||||
struct SetChannelDirectMsg;
|
||||
typedef struct SetChannelDirectMsg SetChannelDirectMsg;
|
||||
|
||||
static inline void SetChannelDirectMsg_init(SetChannelDirectMsg* this);
|
||||
static inline void SetChannelDirectMsg_initFromValue(SetChannelDirectMsg* this, int value);
|
||||
|
||||
struct SetChannelDirectMsg
|
||||
{
|
||||
SimpleIntMsg simpleIntMsg;
|
||||
};
|
||||
|
||||
|
||||
void SetChannelDirectMsg_init(SetChannelDirectMsg* this)
|
||||
{
|
||||
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_SetChannelDirect);
|
||||
}
|
||||
|
||||
void SetChannelDirectMsg_initFromValue(SetChannelDirectMsg* this, int value)
|
||||
{
|
||||
SimpleIntMsg_initFromValue( (SimpleIntMsg*)this, NETMSGTYPE_SetChannelDirect, value);
|
||||
}
|
||||
|
||||
#endif /*SETCHANNELDIRECTMSG_H_*/
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <app/App.h>
|
||||
#include <common/toolkit/SocketTk.h>
|
||||
#include "GetHostByNameMsg.h"
|
||||
|
||||
const struct NetMessageOps GetHostByNameMsg_Ops = {
|
||||
.serializePayload = GetHostByNameMsg_serializePayload,
|
||||
.deserializePayload = GetHostByNameMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void GetHostByNameMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
GetHostByNameMsg* thisCast = (GetHostByNameMsg*)this;
|
||||
|
||||
// hostname
|
||||
Serialization_serializeStr(ctx, thisCast->hostnameLen, thisCast->hostname);
|
||||
}
|
||||
|
||||
bool GetHostByNameMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
GetHostByNameMsg* thisCast = (GetHostByNameMsg*)this;
|
||||
|
||||
// hostname
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->hostnameLen, &thisCast->hostname) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef GETHOSTBYNAMEMSG_H_
|
||||
#define GETHOSTBYNAMEMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
|
||||
|
||||
struct GetHostByNameMsg;
|
||||
typedef struct GetHostByNameMsg GetHostByNameMsg;
|
||||
|
||||
static inline void GetHostByNameMsg_init(GetHostByNameMsg* this);
|
||||
static inline void GetHostByNameMsg_initFromHostname(GetHostByNameMsg* this,
|
||||
const char* hostname);
|
||||
|
||||
// virtual functions
|
||||
extern void GetHostByNameMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool GetHostByNameMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
struct GetHostByNameMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
unsigned hostnameLen;
|
||||
const char* hostname;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps GetHostByNameMsg_Ops;
|
||||
|
||||
void GetHostByNameMsg_init(GetHostByNameMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_GetHostByName, &GetHostByNameMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hostname just a reference, so do not free it as long as you use this object!
|
||||
*/
|
||||
void GetHostByNameMsg_initFromHostname(GetHostByNameMsg* this,
|
||||
const char* hostname)
|
||||
{
|
||||
GetHostByNameMsg_init(this);
|
||||
|
||||
this->hostname = hostname;
|
||||
this->hostnameLen = strlen(hostname);
|
||||
}
|
||||
|
||||
#endif /*GETHOSTBYNAMEMSG_H_*/
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <app/App.h>
|
||||
#include <common/toolkit/SocketTk.h>
|
||||
#include "GetHostByNameRespMsg.h"
|
||||
|
||||
const struct NetMessageOps GetHostByNameRespMsg_Ops = {
|
||||
.serializePayload = _NetMessage_serializeDummy,
|
||||
.deserializePayload = GetHostByNameRespMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
bool GetHostByNameRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
GetHostByNameRespMsg* thisCast = (GetHostByNameRespMsg*)this;
|
||||
|
||||
// hostAddr
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->hostAddrLen, &thisCast->hostAddr) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef GETHOSTBYNAMERESPMSG_H_
|
||||
#define GETHOSTBYNAMERESPMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
|
||||
|
||||
struct GetHostByNameRespMsg;
|
||||
typedef struct GetHostByNameRespMsg GetHostByNameRespMsg;
|
||||
|
||||
static inline void GetHostByNameRespMsg_init(GetHostByNameRespMsg* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool GetHostByNameRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
// getters & setters
|
||||
static inline const char* GetHostByNameRespMsg_getHostAddr(GetHostByNameRespMsg* this);
|
||||
|
||||
|
||||
struct GetHostByNameRespMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
unsigned hostAddrLen;
|
||||
const char* hostAddr;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps GetHostByNameRespMsg_Ops;
|
||||
|
||||
void GetHostByNameRespMsg_init(GetHostByNameRespMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_GetHostByNameResp, &GetHostByNameRespMsg_Ops);
|
||||
}
|
||||
|
||||
const char* GetHostByNameRespMsg_getHostAddr(GetHostByNameRespMsg* this)
|
||||
{
|
||||
return this->hostAddr;
|
||||
}
|
||||
|
||||
#endif /*GETHOSTBYNAMERESPMSG_H_*/
|
||||
61
client_module/source/common/net/message/helperd/LogMsg.c
Normal file
61
client_module/source/common/net/message/helperd/LogMsg.c
Normal file
@@ -0,0 +1,61 @@
|
||||
#include <app/App.h>
|
||||
#include <common/nodes/Node.h>
|
||||
#include <common/toolkit/SocketTk.h>
|
||||
#include <common/toolkit/ListTk.h>
|
||||
#include <nodes/NodeStoreEx.h>
|
||||
#include "LogMsg.h"
|
||||
|
||||
|
||||
const struct NetMessageOps LogMsg_Ops = {
|
||||
.serializePayload = LogMsg_serializePayload,
|
||||
.deserializePayload = LogMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void LogMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
LogMsg* thisCast = (LogMsg*)this;
|
||||
|
||||
// level
|
||||
Serialization_serializeInt(ctx, thisCast->level);
|
||||
|
||||
// threadID
|
||||
Serialization_serializeInt(ctx, thisCast->threadID);
|
||||
|
||||
// threadName
|
||||
Serialization_serializeStr(ctx, thisCast->threadNameLen, thisCast->threadName);
|
||||
|
||||
// context
|
||||
Serialization_serializeStr(ctx, thisCast->contextLen, thisCast->context);
|
||||
|
||||
// logMsg
|
||||
Serialization_serializeStr(ctx, thisCast->logMsgLen, thisCast->logMsg);
|
||||
}
|
||||
|
||||
bool LogMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
LogMsg* thisCast = (LogMsg*)this;
|
||||
|
||||
// level
|
||||
if(!Serialization_deserializeInt(ctx, &thisCast->level) )
|
||||
return false;
|
||||
|
||||
// threadID
|
||||
if(!Serialization_deserializeInt(ctx, &thisCast->threadID) )
|
||||
return false;
|
||||
|
||||
// threadName
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->threadNameLen, &thisCast->threadName) )
|
||||
return false;
|
||||
|
||||
// context
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->contextLen, &thisCast->context) )
|
||||
return false;
|
||||
|
||||
// logMsg
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->logMsgLen, &thisCast->logMsg) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
62
client_module/source/common/net/message/helperd/LogMsg.h
Normal file
62
client_module/source/common/net/message/helperd/LogMsg.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#ifndef LOGMSG_H_
|
||||
#define LOGMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
|
||||
|
||||
struct LogMsg;
|
||||
typedef struct LogMsg LogMsg;
|
||||
|
||||
static inline void LogMsg_init(LogMsg* this);
|
||||
static inline void LogMsg_initFromEntry(LogMsg* this, int level,
|
||||
int threadID, const char* threadName, const char* context, const char* logMsg);
|
||||
|
||||
// virtual functions
|
||||
extern void LogMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool LogMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
|
||||
struct LogMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
int level;
|
||||
int threadID;
|
||||
unsigned threadNameLen;
|
||||
const char* threadName;
|
||||
unsigned contextLen;
|
||||
const char* context;
|
||||
unsigned logMsgLen;
|
||||
const char* logMsg;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps LogMsg_Ops;
|
||||
|
||||
void LogMsg_init(LogMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_Log, &LogMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context just a reference, so do not free it as long as you use this object!
|
||||
* @param logMsg just a reference, so do not free it as long as you use this object!
|
||||
*/
|
||||
void LogMsg_initFromEntry(LogMsg* this, int level, int threadID, const char* threadName,
|
||||
const char* context, const char* logMsg)
|
||||
{
|
||||
LogMsg_init(this);
|
||||
|
||||
this->level = level;
|
||||
this->threadID = threadID;
|
||||
|
||||
this->threadName = threadName;
|
||||
this->threadNameLen = strlen(threadName);
|
||||
|
||||
this->context = context;
|
||||
this->contextLen = strlen(context);
|
||||
|
||||
this->logMsg = logMsg;
|
||||
this->logMsgLen = strlen(logMsg);
|
||||
}
|
||||
|
||||
#endif /*LOGMSG_H_*/
|
||||
32
client_module/source/common/net/message/helperd/LogRespMsg.h
Normal file
32
client_module/source/common/net/message/helperd/LogRespMsg.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef LOGRESPMSG_H_
|
||||
#define LOGRESPMSG_H_
|
||||
|
||||
#include <common/net/message/SimpleIntMsg.h>
|
||||
|
||||
|
||||
struct LogRespMsg;
|
||||
typedef struct LogRespMsg LogRespMsg;
|
||||
|
||||
static inline void LogRespMsg_init(LogRespMsg* this);
|
||||
|
||||
// getters & setters
|
||||
static inline int LogRespMsg_getValue(LogRespMsg* this);
|
||||
|
||||
struct LogRespMsg
|
||||
{
|
||||
SimpleIntMsg simpleIntMsg;
|
||||
};
|
||||
|
||||
|
||||
void LogRespMsg_init(LogRespMsg* this)
|
||||
{
|
||||
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_LogResp);
|
||||
}
|
||||
|
||||
int LogRespMsg_getValue(LogRespMsg* this)
|
||||
{
|
||||
return SimpleIntMsg_getValue( (SimpleIntMsg*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /*LOGRESPMSG_H_*/
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef GETMIRRORBUDDYGROUPSMSG_H
|
||||
#define GETMIRRORBUDDYGROUPSMSG_H
|
||||
|
||||
#include <common/net/message/SimpleIntMsg.h>
|
||||
|
||||
struct GetMirrorBuddyGroupsMsg;
|
||||
typedef struct GetMirrorBuddyGroupsMsg GetMirrorBuddyGroupsMsg;
|
||||
|
||||
static inline void GetMirrorBuddyGroupsMsg_init(GetMirrorBuddyGroupsMsg* this, NodeType nodeType);
|
||||
|
||||
struct GetMirrorBuddyGroupsMsg
|
||||
{
|
||||
SimpleIntMsg simpleIntMsg;
|
||||
};
|
||||
|
||||
void GetMirrorBuddyGroupsMsg_init(GetMirrorBuddyGroupsMsg* this, NodeType nodeType)
|
||||
{
|
||||
SimpleIntMsg_initFromValue( (SimpleIntMsg*)this, NETMSGTYPE_GetMirrorBuddyGroups, nodeType);
|
||||
}
|
||||
|
||||
#endif /* GETMIRRORBUDDYGROUPSMSG_H */
|
||||
32
client_module/source/common/net/message/nodes/GetNodesMsg.h
Normal file
32
client_module/source/common/net/message/nodes/GetNodesMsg.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef GETNODESMSG_H_
|
||||
#define GETNODESMSG_H_
|
||||
|
||||
#include <common/net/message/SimpleIntMsg.h>
|
||||
|
||||
|
||||
struct GetNodesMsg;
|
||||
typedef struct GetNodesMsg GetNodesMsg;
|
||||
|
||||
static inline void GetNodesMsg_init(GetNodesMsg* this);
|
||||
static inline void GetNodesMsg_initFromValue(GetNodesMsg* this, int nodeType);
|
||||
|
||||
struct GetNodesMsg
|
||||
{
|
||||
SimpleIntMsg simpleIntMsg;
|
||||
};
|
||||
|
||||
|
||||
void GetNodesMsg_init(GetNodesMsg* this)
|
||||
{
|
||||
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_GetNodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeType NODETYPE_...
|
||||
*/
|
||||
void GetNodesMsg_initFromValue(GetNodesMsg* this, int nodeType)
|
||||
{
|
||||
SimpleIntMsg_initFromValue( (SimpleIntMsg*)this, NETMSGTYPE_GetNodes, nodeType);
|
||||
}
|
||||
|
||||
#endif /* GETNODESMSG_H_ */
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "GetNodesRespMsg.h"
|
||||
|
||||
const struct NetMessageOps GetNodesRespMsg_Ops = {
|
||||
.serializePayload = _NetMessage_serializeDummy,
|
||||
.deserializePayload = GetNodesRespMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
|
||||
bool GetNodesRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
GetNodesRespMsg* thisCast = (GetNodesRespMsg*)this;
|
||||
|
||||
// nodeList
|
||||
if(!Serialization_deserializeNodeListPreprocess(ctx, &thisCast->rawNodeList) )
|
||||
return false;
|
||||
|
||||
// rootNumID
|
||||
if(!NumNodeID_deserialize(ctx, &thisCast->rootNumID) )
|
||||
return false;
|
||||
|
||||
// rootIsBuddyMirrored
|
||||
if(!Serialization_deserializeBool(ctx, &thisCast->rootIsBuddyMirrored) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef GETNODESRESPMSG_H_
|
||||
#define GETNODESRESPMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/nodes/NodeList.h>
|
||||
|
||||
/*
|
||||
* note: serialization not implemented
|
||||
*/
|
||||
struct GetNodesRespMsg;
|
||||
typedef struct GetNodesRespMsg GetNodesRespMsg;
|
||||
|
||||
static inline void GetNodesRespMsg_init(GetNodesRespMsg* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool GetNodesRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
// inliners
|
||||
static inline void GetNodesRespMsg_parseNodeList(App* app, GetNodesRespMsg* this,
|
||||
NodeList* outNodeList);
|
||||
|
||||
// getters & setters
|
||||
static inline NumNodeID GetNodesRespMsg_getRootNumID(GetNodesRespMsg* this);
|
||||
static inline bool GetNodesRespMsg_getRootIsBuddyMirrored(GetNodesRespMsg* this);
|
||||
|
||||
|
||||
struct GetNodesRespMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
NumNodeID rootNumID;
|
||||
bool rootIsBuddyMirrored;
|
||||
|
||||
// for deserialization
|
||||
RawList rawNodeList;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps GetNodesRespMsg_Ops;
|
||||
|
||||
void GetNodesRespMsg_init(GetNodesRespMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_GetNodesResp, &GetNodesRespMsg_Ops);
|
||||
|
||||
this->rootNumID = (NumNodeID){0};
|
||||
}
|
||||
|
||||
void GetNodesRespMsg_parseNodeList(App* app, GetNodesRespMsg* this, NodeList* outNodeList)
|
||||
{
|
||||
Serialization_deserializeNodeList(app, &this->rawNodeList, outNodeList);
|
||||
}
|
||||
|
||||
NumNodeID GetNodesRespMsg_getRootNumID(GetNodesRespMsg* this)
|
||||
{
|
||||
return this->rootNumID;
|
||||
}
|
||||
|
||||
bool GetNodesRespMsg_getRootIsBuddyMirrored(GetNodesRespMsg* this)
|
||||
{
|
||||
return this->rootIsBuddyMirrored;
|
||||
}
|
||||
|
||||
#endif /* GETNODESRESPMSG_H_ */
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "GetStatesAndBuddyGroupsMsg.h"
|
||||
|
||||
static void GetStatesAndBuddyGroupsMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
GetStatesAndBuddyGroupsMsg* thisCast = (GetStatesAndBuddyGroupsMsg*)this;
|
||||
|
||||
Serialization_serializeInt(ctx, thisCast->nodeType);
|
||||
NumNodeID_serialize(ctx, &thisCast->requestedByClientID);
|
||||
}
|
||||
|
||||
static bool GetStatesAndBuddyGroupsMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
GetStatesAndBuddyGroupsMsg* thisCast = (GetStatesAndBuddyGroupsMsg*)this;
|
||||
|
||||
bool result =
|
||||
Serialization_deserializeInt(ctx, (int32_t*)&thisCast->nodeType)
|
||||
&& NumNodeID_deserialize(ctx, &thisCast->requestedByClientID);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const struct NetMessageOps GetStatesAndBuddyGroupsMsg_Ops = {
|
||||
.serializePayload = GetStatesAndBuddyGroupsMsg_serializePayload,
|
||||
.deserializePayload = GetStatesAndBuddyGroupsMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef GETSTATESANDBUDDYGROUPSMSG_H_
|
||||
#define GETSTATESANDBUDDYGROUPSMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include "common/nodes/NumNodeID.h"
|
||||
#include <common/nodes/Node.h>
|
||||
|
||||
struct GetStatesAndBuddyGroupsMsg;
|
||||
typedef struct GetStatesAndBuddyGroupsMsg GetStatesAndBuddyGroupsMsg;
|
||||
|
||||
|
||||
static inline void GetStatesAndBuddyGroupsMsg_init(GetStatesAndBuddyGroupsMsg* this,
|
||||
NodeType nodeType, NumNodeID requestedByClientID);
|
||||
|
||||
|
||||
struct GetStatesAndBuddyGroupsMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
NodeType nodeType;
|
||||
NumNodeID requestedByClientID;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps GetStatesAndBuddyGroupsMsg_Ops;
|
||||
|
||||
void GetStatesAndBuddyGroupsMsg_init(GetStatesAndBuddyGroupsMsg* this, NodeType nodeType, NumNodeID requestedByClientID)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_GetStatesAndBuddyGroups, &GetStatesAndBuddyGroupsMsg_Ops);
|
||||
|
||||
this->nodeType = nodeType;
|
||||
this->requestedByClientID = requestedByClientID;
|
||||
}
|
||||
|
||||
#endif /* GETSTATESANDBUDDYGROUPSMSG_H_ */
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "GetStatesAndBuddyGroupsRespMsg.h"
|
||||
|
||||
static void GetStatesAndBuddyGroupsRespMsg_release(NetMessage* msg)
|
||||
{
|
||||
GetStatesAndBuddyGroupsRespMsg* this = container_of(msg, struct GetStatesAndBuddyGroupsRespMsg,
|
||||
netMessage);
|
||||
|
||||
BEEGFS_KFREE_LIST(&this->groups, struct BuddyGroupMapping, _list);
|
||||
BEEGFS_KFREE_LIST(&this->states, struct TargetStateMapping, _list);
|
||||
}
|
||||
|
||||
const struct NetMessageOps GetStatesAndBuddyGroupsRespMsg_Ops = {
|
||||
.serializePayload = _NetMessage_serializeDummy,
|
||||
.deserializePayload = GetStatesAndBuddyGroupsRespMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
.release = GetStatesAndBuddyGroupsRespMsg_release,
|
||||
};
|
||||
|
||||
bool GetStatesAndBuddyGroupsRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
GetStatesAndBuddyGroupsRespMsg* thisCast = (GetStatesAndBuddyGroupsRespMsg*)this;
|
||||
|
||||
if (!BuddyGroupMappingList_deserialize(ctx, &thisCast->groups))
|
||||
return false;
|
||||
|
||||
if (!TargetStateMappingList_deserialize(ctx, &thisCast->states))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef GETSTATESANDBUDDYGROUPSRESPMSG_H_
|
||||
#define GETSTATESANDBUDDYGROUPSRESPMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
|
||||
|
||||
struct GetStatesAndBuddyGroupsRespMsg;
|
||||
typedef struct GetStatesAndBuddyGroupsRespMsg GetStatesAndBuddyGroupsRespMsg;
|
||||
|
||||
static inline void GetStatesAndBuddyGroupsRespMsg_init(GetStatesAndBuddyGroupsRespMsg* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool GetStatesAndBuddyGroupsRespMsg_deserializePayload(NetMessage* this,
|
||||
DeserializeCtx* ctx);
|
||||
|
||||
/**
|
||||
* This message carries two maps:
|
||||
* 1) buddyGroupID -> primaryTarget, secondaryTarget
|
||||
* 2) targetID -> targetReachabilityState, targetConsistencyState
|
||||
*
|
||||
* Note: This message can only be received/deserialized (send/serialization not implemented).
|
||||
*/
|
||||
struct GetStatesAndBuddyGroupsRespMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
struct list_head groups; /* struct BuddyGroupMapping */
|
||||
struct list_head states; /* struct TargetStateMapping */
|
||||
};
|
||||
extern const struct NetMessageOps GetStatesAndBuddyGroupsRespMsg_Ops;
|
||||
|
||||
void GetStatesAndBuddyGroupsRespMsg_init(GetStatesAndBuddyGroupsRespMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_GetStatesAndBuddyGroupsResp,
|
||||
&GetStatesAndBuddyGroupsRespMsg_Ops);
|
||||
|
||||
INIT_LIST_HEAD(&this->groups);
|
||||
INIT_LIST_HEAD(&this->states);
|
||||
}
|
||||
|
||||
#endif /* GETSTATESANDBUDDYGROUPSRESPMSG_H_ */
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef GETTARGETMAPPINGSMSG_H_
|
||||
#define GETTARGETMAPPINGSMSG_H_
|
||||
|
||||
#include "../SimpleMsg.h"
|
||||
|
||||
|
||||
struct GetTargetMappingsMsg;
|
||||
typedef struct GetTargetMappingsMsg GetTargetMappingsMsg;
|
||||
|
||||
static inline void GetTargetMappingsMsg_init(GetTargetMappingsMsg* this);
|
||||
|
||||
|
||||
struct GetTargetMappingsMsg
|
||||
{
|
||||
SimpleMsg simpleMsg;
|
||||
};
|
||||
|
||||
|
||||
void GetTargetMappingsMsg_init(GetTargetMappingsMsg* this)
|
||||
{
|
||||
SimpleMsg_init( (SimpleMsg*)this, NETMSGTYPE_GetTargetMappings);
|
||||
}
|
||||
|
||||
#endif /* GETTARGETMAPPINGSMSG_H_ */
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "GetTargetMappingsRespMsg.h"
|
||||
|
||||
#include <common/nodes/TargetMapper.h>
|
||||
|
||||
static void GetTargetMappingsRespMsg_release(NetMessage* this)
|
||||
{
|
||||
GetTargetMappingsRespMsg* thisCast = (GetTargetMappingsRespMsg*)this;
|
||||
|
||||
BEEGFS_KFREE_LIST(&thisCast->mappings, struct TargetMapping, _list);
|
||||
}
|
||||
|
||||
bool GetTargetMappingsRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
GetTargetMappingsRespMsg* thisCast = (GetTargetMappingsRespMsg*)this;
|
||||
|
||||
if (!TargetMappingList_deserialize(ctx, &thisCast->mappings))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const struct NetMessageOps GetTargetMappingsRespMsg_Ops = {
|
||||
.serializePayload = _NetMessage_serializeDummy,
|
||||
.deserializePayload = GetTargetMappingsRespMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
.release = GetTargetMappingsRespMsg_release,
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef GETTARGETMAPPINGSRESPMSG_H_
|
||||
#define GETTARGETMAPPINGSRESPMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/Common.h>
|
||||
|
||||
/**
|
||||
* Note: This message can only be received/deserialized (send/serialization not implemented)
|
||||
*/
|
||||
|
||||
|
||||
struct GetTargetMappingsRespMsg;
|
||||
typedef struct GetTargetMappingsRespMsg GetTargetMappingsRespMsg;
|
||||
|
||||
static inline void GetTargetMappingsRespMsg_init(GetTargetMappingsRespMsg* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool GetTargetMappingsRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
|
||||
struct GetTargetMappingsRespMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
struct list_head mappings; /* TargetMapping */
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps GetTargetMappingsRespMsg_Ops;
|
||||
|
||||
void GetTargetMappingsRespMsg_init(GetTargetMappingsRespMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_GetTargetMappingsResp,
|
||||
&GetTargetMappingsRespMsg_Ops);
|
||||
|
||||
INIT_LIST_HEAD(&this->mappings);
|
||||
}
|
||||
|
||||
#endif /* GETTARGETMAPPINGSRESPMSG_H_ */
|
||||
257
client_module/source/common/net/message/nodes/HeartbeatMsgEx.c
Normal file
257
client_module/source/common/net/message/nodes/HeartbeatMsgEx.c
Normal file
@@ -0,0 +1,257 @@
|
||||
#include <app/App.h>
|
||||
#include <common/nodes/Node.h>
|
||||
#include <common/toolkit/SocketTk.h>
|
||||
#include <common/net/msghelpers/MsgHelperAck.h>
|
||||
#include <common/toolkit/ListTk.h>
|
||||
#include <nodes/NodeStoreEx.h>
|
||||
#include <app/config/Config.h>
|
||||
#include "HeartbeatMsgEx.h"
|
||||
|
||||
const struct NetMessageOps HeartbeatMsgEx_Ops = {
|
||||
.serializePayload = HeartbeatMsgEx_serializePayload,
|
||||
.deserializePayload = HeartbeatMsgEx_deserializePayload,
|
||||
.processIncoming = __HeartbeatMsgEx_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void HeartbeatMsgEx_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
HeartbeatMsgEx* thisCast = (HeartbeatMsgEx*)this;
|
||||
|
||||
// instanceVersion
|
||||
Serialization_serializeUInt64(ctx, thisCast->instanceVersion);
|
||||
|
||||
// nicListVersion
|
||||
Serialization_serializeUInt64(ctx, thisCast->nicListVersion);
|
||||
|
||||
// nodeType
|
||||
Serialization_serializeInt(ctx, thisCast->nodeType);
|
||||
|
||||
// nodeID
|
||||
Serialization_serializeStr(ctx, thisCast->nodeIDLen, thisCast->nodeID);
|
||||
|
||||
// ackID
|
||||
Serialization_serializeStrAlign4(ctx, thisCast->ackIDLen, thisCast->ackID);
|
||||
|
||||
// nodeNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->nodeNumID);
|
||||
|
||||
// rootNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->rootNumID);
|
||||
|
||||
// rootIsBuddyMirrored
|
||||
Serialization_serializeBool(ctx, thisCast->rootIsBuddyMirrored);
|
||||
|
||||
// portUDP
|
||||
Serialization_serializeUShort(ctx, thisCast->portUDP);
|
||||
|
||||
// portTCP
|
||||
Serialization_serializeUShort(ctx, thisCast->portTCP);
|
||||
|
||||
// nicList
|
||||
Serialization_serializeNicList(ctx, thisCast->nicList);
|
||||
|
||||
// machineUUID
|
||||
Serialization_serializeStr(ctx, thisCast->machineUUIDLen, thisCast->machineUUID);
|
||||
}
|
||||
|
||||
bool HeartbeatMsgEx_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
HeartbeatMsgEx* thisCast = (HeartbeatMsgEx*)this;
|
||||
|
||||
// instanceVersion
|
||||
if(!Serialization_deserializeUInt64(ctx, &thisCast->instanceVersion) )
|
||||
return false;
|
||||
|
||||
// nicListVersion
|
||||
if(!Serialization_deserializeUInt64(ctx, &thisCast->nicListVersion) )
|
||||
return false;
|
||||
|
||||
// nodeType
|
||||
if(!Serialization_deserializeInt(ctx, &thisCast->nodeType) )
|
||||
return false;
|
||||
|
||||
// nodeID
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->nodeIDLen, &thisCast->nodeID) )
|
||||
return false;
|
||||
|
||||
// ackID
|
||||
if(!Serialization_deserializeStrAlign4(ctx, &thisCast->ackIDLen, &thisCast->ackID) )
|
||||
return false;
|
||||
|
||||
// nodeNumID
|
||||
if(!NumNodeID_deserialize(ctx, &thisCast->nodeNumID) )
|
||||
return false;
|
||||
|
||||
// rootNumID
|
||||
if(!NumNodeID_deserialize(ctx, &thisCast->rootNumID) )
|
||||
return false;
|
||||
|
||||
// rootIsBuddyMirrored
|
||||
if(!Serialization_deserializeBool(ctx, &thisCast->rootIsBuddyMirrored) )
|
||||
return false;
|
||||
|
||||
// portUDP
|
||||
if(!Serialization_deserializeUShort(ctx, &thisCast->portUDP) )
|
||||
return false;
|
||||
|
||||
// portTCP
|
||||
if(!Serialization_deserializeUShort(ctx, &thisCast->portTCP) )
|
||||
return false;
|
||||
|
||||
// nicList
|
||||
if(!Serialization_deserializeNicListPreprocess(ctx, &thisCast->rawNicList) )
|
||||
return false;
|
||||
|
||||
// machineUUID
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->machineUUIDLen, &thisCast->machineUUID) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __HeartbeatMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen)
|
||||
{
|
||||
Logger* log = App_getLogger(app);
|
||||
const char* logContext = "Heartbeat incoming";
|
||||
|
||||
HeartbeatMsgEx* thisCast = (HeartbeatMsgEx*)this;
|
||||
|
||||
NicAddressList nicList;
|
||||
Node* node;
|
||||
NodeConnPool* connPool;
|
||||
Node* localNode;
|
||||
NicAddressList localNicList;
|
||||
NicListCapabilities localNicCaps;
|
||||
NodeStoreEx* nodes = NULL;
|
||||
bool isNodeNew;
|
||||
NumNodeID nodeNumID;
|
||||
int nodeType;
|
||||
|
||||
// check if nodeNumID is set
|
||||
nodeNumID = HeartbeatMsgEx_getNodeNumID(thisCast);
|
||||
if(NumNodeID_isZero(&nodeNumID))
|
||||
{ // shouldn't happen: this node would need to register first to get a nodeNumID assigned
|
||||
Logger_logFormatted(log, Log_WARNING, logContext,
|
||||
"Rejecting heartbeat of node without numeric ID: %s (Type: %s)",
|
||||
HeartbeatMsgEx_getNodeID(thisCast),
|
||||
Node_nodeTypeToStr(HeartbeatMsgEx_getNodeType(thisCast) ) );
|
||||
|
||||
goto ack_resp;
|
||||
}
|
||||
|
||||
// find the corresponding node store for this node type
|
||||
|
||||
nodeType = HeartbeatMsgEx_getNodeType(thisCast);
|
||||
switch(nodeType)
|
||||
{
|
||||
case NODETYPE_Meta:
|
||||
nodes = App_getMetaNodes(app); break;
|
||||
|
||||
case NODETYPE_Storage:
|
||||
nodes = App_getStorageNodes(app); break;
|
||||
|
||||
case NODETYPE_Mgmt:
|
||||
nodes = App_getMgmtNodes(app); break;
|
||||
|
||||
default:
|
||||
{
|
||||
const char* nodeID = HeartbeatMsgEx_getNodeID(thisCast);
|
||||
|
||||
Logger_logErrFormatted(log, logContext, "Invalid node type: %d (%s); ID: %s",
|
||||
nodeType, Node_nodeTypeToStr(nodeType), nodeID);
|
||||
|
||||
goto ack_resp;
|
||||
} break;
|
||||
}
|
||||
|
||||
// construct node
|
||||
|
||||
NicAddressList_init(&nicList);
|
||||
|
||||
HeartbeatMsgEx_parseNicList(thisCast, &nicList);
|
||||
|
||||
App_lockNicList(app);
|
||||
node = Node_construct(app,
|
||||
HeartbeatMsgEx_getNodeID(thisCast), HeartbeatMsgEx_getNodeNumID(thisCast),
|
||||
HeartbeatMsgEx_getPortUDP(thisCast), HeartbeatMsgEx_getPortTCP(thisCast), &nicList,
|
||||
nodeType == NODETYPE_Meta || nodeType == NODETYPE_Storage? App_getLocalRDMANicListLocked(app) : NULL);
|
||||
// (will belong to the NodeStore => no destruct() required)
|
||||
App_unlockNicList(app);
|
||||
|
||||
Node_setNodeAliasAndType(node, NULL, nodeType);
|
||||
|
||||
// set local nic capabilities
|
||||
|
||||
localNode = App_getLocalNode(app);
|
||||
Node_cloneNicList(localNode, &localNicList);
|
||||
connPool = Node_getConnPool(node);
|
||||
|
||||
NIC_supportedCapabilities(&localNicList, &localNicCaps);
|
||||
NodeConnPool_setLocalNicCaps(connPool, &localNicCaps);
|
||||
|
||||
// add node to store (or update it)
|
||||
|
||||
isNodeNew = NodeStoreEx_addOrUpdateNode(nodes, &node);
|
||||
if(isNodeNew)
|
||||
{
|
||||
bool supportsRDMA = NIC_supportsRDMA(&nicList);
|
||||
|
||||
Logger_logFormatted(log, Log_WARNING, logContext,
|
||||
"New node: %s %s [ID: %hu]; %s",
|
||||
Node_nodeTypeToStr(nodeType),
|
||||
HeartbeatMsgEx_getNodeID(thisCast),
|
||||
HeartbeatMsgEx_getNodeNumID(thisCast).value,
|
||||
(supportsRDMA ? "RDMA; " : "") );
|
||||
}
|
||||
|
||||
__HeartbeatMsgEx_processIncomingRoot(thisCast, app);
|
||||
|
||||
ack_resp:
|
||||
// send ack
|
||||
MsgHelperAck_respondToAckRequest(app, HeartbeatMsgEx_getAckID(thisCast), fromAddr, sock,
|
||||
respBuf, bufLen);
|
||||
|
||||
// clean-up
|
||||
ListTk_kfreeNicAddressListElems(&nicList);
|
||||
NicAddressList_uninit(&nicList);
|
||||
ListTk_kfreeNicAddressListElems(&localNicList);
|
||||
NicAddressList_uninit(&localNicList);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the contained root information.
|
||||
*/
|
||||
void __HeartbeatMsgEx_processIncomingRoot(HeartbeatMsgEx* this, App* app)
|
||||
{
|
||||
Logger* log = App_getLogger(app);
|
||||
const char* logContext = "Heartbeat incoming (root)";
|
||||
|
||||
NodeStoreEx* metaNodes;
|
||||
bool setRootRes;
|
||||
NodeOrGroup rootOwner = this->rootIsBuddyMirrored
|
||||
? NodeOrGroup_fromGroup(this->rootNumID.value)
|
||||
: NodeOrGroup_fromNode(this->rootNumID);
|
||||
NumNodeID rootNumID = HeartbeatMsgEx_getRootNumID(this);
|
||||
|
||||
// check whether root info is defined
|
||||
if( (HeartbeatMsgEx_getNodeType(this) != NODETYPE_Meta) || (NumNodeID_isZero(&rootNumID)))
|
||||
return;
|
||||
|
||||
// try to apply the contained root info
|
||||
|
||||
metaNodes = App_getMetaNodes(app);
|
||||
|
||||
setRootRes = NodeStoreEx_setRootOwner(metaNodes, rootOwner, false);
|
||||
|
||||
if(setRootRes)
|
||||
{ // found the very first root
|
||||
Logger_logFormatted(log, Log_CRITICAL, logContext, "Root (by Heartbeat): %hu",
|
||||
HeartbeatMsgEx_getRootNumID(this).value );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
152
client_module/source/common/net/message/nodes/HeartbeatMsgEx.h
Normal file
152
client_module/source/common/net/message/nodes/HeartbeatMsgEx.h
Normal file
@@ -0,0 +1,152 @@
|
||||
#ifndef HEARTBEATMSG_H_
|
||||
#define HEARTBEATMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/net/sock/NetworkInterfaceCard.h>
|
||||
|
||||
|
||||
struct HeartbeatMsgEx;
|
||||
typedef struct HeartbeatMsgEx HeartbeatMsgEx;
|
||||
|
||||
static inline void HeartbeatMsgEx_init(HeartbeatMsgEx* this);
|
||||
static inline void HeartbeatMsgEx_initFromNodeData(HeartbeatMsgEx* this,
|
||||
const char* nodeID, NumNodeID nodeNumID, int nodeType, NicAddressList* nicList);
|
||||
|
||||
extern void __HeartbeatMsgEx_processIncomingRoot(HeartbeatMsgEx* this, struct App* app);
|
||||
|
||||
// virtual functions
|
||||
extern void HeartbeatMsgEx_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool HeartbeatMsgEx_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
extern bool __HeartbeatMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen);
|
||||
|
||||
// inliners
|
||||
static inline void HeartbeatMsgEx_parseNicList(HeartbeatMsgEx* this,
|
||||
NicAddressList* outNicList);
|
||||
|
||||
// getters & setters
|
||||
static inline const char* HeartbeatMsgEx_getNodeID(HeartbeatMsgEx* this);
|
||||
static inline NumNodeID HeartbeatMsgEx_getNodeNumID(HeartbeatMsgEx* this);
|
||||
static inline int HeartbeatMsgEx_getNodeType(HeartbeatMsgEx* this);
|
||||
static inline NumNodeID HeartbeatMsgEx_getRootNumID(HeartbeatMsgEx* this);
|
||||
static inline const char* HeartbeatMsgEx_getAckID(HeartbeatMsgEx* this);
|
||||
static inline void HeartbeatMsgEx_setPorts(HeartbeatMsgEx* this,
|
||||
uint16_t portUDP, uint16_t portTCP);
|
||||
static inline uint16_t HeartbeatMsgEx_getPortUDP(HeartbeatMsgEx* this);
|
||||
static inline uint16_t HeartbeatMsgEx_getPortTCP(HeartbeatMsgEx* this);
|
||||
|
||||
|
||||
struct HeartbeatMsgEx
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
unsigned nodeIDLen;
|
||||
const char* nodeID;
|
||||
int nodeType;
|
||||
NumNodeID nodeNumID;
|
||||
NumNodeID rootNumID; // 0 means unknown/undefined
|
||||
bool rootIsBuddyMirrored;
|
||||
uint64_t instanceVersion; // not used currently
|
||||
uint64_t nicListVersion; // not used currently
|
||||
uint16_t portUDP; // 0 means "undefined"
|
||||
uint16_t portTCP; // 0 means "undefined"
|
||||
unsigned ackIDLen;
|
||||
const char* ackID;
|
||||
const char* machineUUID;
|
||||
unsigned machineUUIDLen;
|
||||
|
||||
// for serialization
|
||||
NicAddressList* nicList; // not owned by this object
|
||||
|
||||
// for deserialization
|
||||
RawList rawNicList;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps HeartbeatMsgEx_Ops;
|
||||
|
||||
void HeartbeatMsgEx_init(HeartbeatMsgEx* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_Heartbeat, &HeartbeatMsgEx_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeID just a reference, so do not free it as long as you use this object
|
||||
* @param nicList just a reference, so do not free it as long as you use this object
|
||||
*/
|
||||
void HeartbeatMsgEx_initFromNodeData(HeartbeatMsgEx* this,
|
||||
const char* nodeID, NumNodeID nodeNumID, int nodeType, NicAddressList* nicList)
|
||||
{
|
||||
HeartbeatMsgEx_init(this);
|
||||
|
||||
this->nodeID = nodeID;
|
||||
this->nodeIDLen = strlen(nodeID);
|
||||
this->nodeNumID = nodeNumID;
|
||||
|
||||
this->nodeType = nodeType;
|
||||
|
||||
this->rootNumID = (NumNodeID){0}; // 0 means undefined/unknown
|
||||
this->rootIsBuddyMirrored = false;
|
||||
|
||||
this->instanceVersion = 0; // reserverd for future use
|
||||
|
||||
this->nicListVersion = 0; // reserverd for future use
|
||||
this->nicList = nicList;
|
||||
|
||||
this->portUDP = 0; // 0 means "undefined"
|
||||
this->portTCP = 0; // 0 means "undefined"
|
||||
|
||||
this->ackID = "";
|
||||
this->ackIDLen = 0;
|
||||
|
||||
this->machineUUID = ""; // not currently needed on the client
|
||||
this->machineUUIDLen = 0;
|
||||
}
|
||||
|
||||
void HeartbeatMsgEx_parseNicList(HeartbeatMsgEx* this, NicAddressList* outNicList)
|
||||
{
|
||||
Serialization_deserializeNicList(&this->rawNicList, outNicList);
|
||||
}
|
||||
|
||||
const char* HeartbeatMsgEx_getNodeID(HeartbeatMsgEx* this)
|
||||
{
|
||||
return this->nodeID;
|
||||
}
|
||||
|
||||
NumNodeID HeartbeatMsgEx_getNodeNumID(HeartbeatMsgEx* this)
|
||||
{
|
||||
return this->nodeNumID;
|
||||
}
|
||||
|
||||
int HeartbeatMsgEx_getNodeType(HeartbeatMsgEx* this)
|
||||
{
|
||||
return this->nodeType;
|
||||
}
|
||||
|
||||
NumNodeID HeartbeatMsgEx_getRootNumID(HeartbeatMsgEx* this)
|
||||
{
|
||||
return this->rootNumID;
|
||||
}
|
||||
|
||||
const char* HeartbeatMsgEx_getAckID(HeartbeatMsgEx* this)
|
||||
{
|
||||
return this->ackID;
|
||||
}
|
||||
|
||||
void HeartbeatMsgEx_setPorts(HeartbeatMsgEx* this, uint16_t portUDP, uint16_t portTCP)
|
||||
{
|
||||
this->portUDP = portUDP;
|
||||
this->portTCP = portTCP;
|
||||
}
|
||||
|
||||
uint16_t HeartbeatMsgEx_getPortUDP(HeartbeatMsgEx* this)
|
||||
{
|
||||
return this->portUDP;
|
||||
}
|
||||
|
||||
uint16_t HeartbeatMsgEx_getPortTCP(HeartbeatMsgEx* this)
|
||||
{
|
||||
return this->portTCP;
|
||||
}
|
||||
|
||||
|
||||
#endif /*HEARTBEATMSG_H_*/
|
||||
@@ -0,0 +1,65 @@
|
||||
#include <common/nodes/Node.h>
|
||||
#include <components/DatagramListener.h>
|
||||
#include <common/toolkit/SocketTk.h>
|
||||
#include <app/App.h>
|
||||
#include "HeartbeatMsgEx.h"
|
||||
#include "HeartbeatRequestMsgEx.h"
|
||||
|
||||
|
||||
const struct NetMessageOps HeartbeatRequestMsgEx_Ops = {
|
||||
.serializePayload = SimpleMsg_serializePayload,
|
||||
.deserializePayload = SimpleMsg_deserializePayload,
|
||||
.processIncoming = __HeartbeatRequestMsgEx_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
bool __HeartbeatRequestMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen)
|
||||
{
|
||||
Logger* log = App_getLogger(app);
|
||||
const char* logContext = "HeartbeatRequest incoming";
|
||||
|
||||
Config* cfg = App_getConfig(app);
|
||||
Node* localNode = App_getLocalNode(app);
|
||||
NodeString alias;
|
||||
NumNodeID localNodeNumID = Node_getNumID(localNode);
|
||||
NicAddressList nicList;
|
||||
|
||||
HeartbeatMsgEx hbMsg;
|
||||
unsigned respLen;
|
||||
bool serializeRes;
|
||||
ssize_t sendRes;
|
||||
|
||||
Node_cloneNicList(localNode, &nicList);
|
||||
Node_copyAlias(localNode, &alias);
|
||||
HeartbeatMsgEx_initFromNodeData(&hbMsg, alias.buf, localNodeNumID, NODETYPE_Client, &nicList);
|
||||
HeartbeatMsgEx_setPorts(&hbMsg, Config_getConnClientPort(cfg), 0);
|
||||
|
||||
respLen = NetMessage_getMsgLength( (NetMessage*)&hbMsg);
|
||||
serializeRes = NetMessage_serialize( (NetMessage*)&hbMsg, respBuf, bufLen);
|
||||
if(unlikely(!serializeRes) )
|
||||
{
|
||||
Logger_logErrFormatted(log, logContext, "Unable to serialize response");
|
||||
goto err_uninit;
|
||||
}
|
||||
|
||||
if(fromAddr)
|
||||
{ // datagram => sync via dgramLis send method
|
||||
DatagramListener* dgramLis = App_getDatagramListener(app);
|
||||
sendRes = DatagramListener_sendto_kernel(dgramLis, respBuf, respLen, 0, fromAddr);
|
||||
}
|
||||
else
|
||||
sendRes = Socket_sendto_kernel(sock, respBuf, respLen, 0, NULL);
|
||||
|
||||
if(unlikely(sendRes <= 0) )
|
||||
Logger_logErrFormatted(log, logContext, "Send error. ErrCode: %lld", (long long)sendRes);
|
||||
|
||||
err_uninit:
|
||||
|
||||
ListTk_kfreeNicAddressListElems(&nicList);
|
||||
NicAddressList_uninit(&nicList);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef HEARTBEATREQUESTMSGEX_H_
|
||||
#define HEARTBEATREQUESTMSGEX_H_
|
||||
|
||||
#include "../SimpleMsg.h"
|
||||
|
||||
|
||||
struct HeartbeatRequestMsgEx;
|
||||
typedef struct HeartbeatRequestMsgEx HeartbeatRequestMsgEx;
|
||||
|
||||
static inline void HeartbeatRequestMsgEx_init(HeartbeatRequestMsgEx* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool __HeartbeatRequestMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen);
|
||||
|
||||
|
||||
struct HeartbeatRequestMsgEx
|
||||
{
|
||||
SimpleMsg simpleMsg;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps HeartbeatRequestMsgEx_Ops;
|
||||
|
||||
void HeartbeatRequestMsgEx_init(HeartbeatRequestMsgEx* this)
|
||||
{
|
||||
SimpleMsg_init(&this->simpleMsg, NETMSGTYPE_HeartbeatRequest);
|
||||
this->simpleMsg.netMessage.ops = &HeartbeatRequestMsgEx_Ops;
|
||||
}
|
||||
|
||||
#endif /* HEARTBEATREQUESTMSGEX_H_ */
|
||||
@@ -0,0 +1,84 @@
|
||||
#include <app/App.h>
|
||||
#include <common/nodes/Node.h>
|
||||
#include <common/toolkit/SocketTk.h>
|
||||
#include <common/net/msghelpers/MsgHelperAck.h>
|
||||
#include <common/toolkit/ListTk.h>
|
||||
#include <nodes/NodeStoreEx.h>
|
||||
#include <app/config/Config.h>
|
||||
#include "MapTargetsMsgEx.h"
|
||||
|
||||
|
||||
static void MapTargetsMsgEx_release(NetMessage* msg)
|
||||
{
|
||||
MapTargetsMsgEx* this = container_of(msg, struct MapTargetsMsgEx, netMessage);
|
||||
|
||||
BEEGFS_KFREE_LIST(&this->poolMappings, struct TargetPoolMapping, _list);
|
||||
}
|
||||
|
||||
const struct NetMessageOps MapTargetsMsgEx_Ops = {
|
||||
.serializePayload = _NetMessage_serializeDummy,
|
||||
.deserializePayload = MapTargetsMsgEx_deserializePayload,
|
||||
.processIncoming = __MapTargetsMsgEx_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
.release = MapTargetsMsgEx_release,
|
||||
};
|
||||
|
||||
bool MapTargetsMsgEx_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
MapTargetsMsgEx* thisCast = (MapTargetsMsgEx*)this;
|
||||
|
||||
// targets
|
||||
if (!TargetPoolMappingList_deserialize(ctx, &thisCast->poolMappings))
|
||||
return false;
|
||||
|
||||
// nodeID
|
||||
if(!NumNodeID_deserialize(ctx, &thisCast->nodeID) )
|
||||
return false;
|
||||
|
||||
// ackID
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->ackIDLen, &thisCast->ackID) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __MapTargetsMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen)
|
||||
{
|
||||
Logger* log = App_getLogger(app);
|
||||
const char* logContext = "MapTargetsMsg incoming";
|
||||
|
||||
MapTargetsMsgEx* thisCast = (MapTargetsMsgEx*)this;
|
||||
|
||||
const char* peer;
|
||||
|
||||
TargetMapper* targetMapper = App_getTargetMapper(app);
|
||||
NumNodeID nodeID = MapTargetsMsgEx_getNodeID(thisCast);
|
||||
struct TargetPoolMapping* mapping;
|
||||
|
||||
|
||||
peer = fromAddr ?
|
||||
SocketTk_ipaddrToStr(fromAddr->addr) : StringTk_strDup(Socket_getPeername(sock) );
|
||||
LOG_DEBUG_FORMATTED(log, 4, logContext, "Received a MapTargetsMsg from: %s", peer);
|
||||
kfree(peer);
|
||||
|
||||
IGNORE_UNUSED_VARIABLE(log);
|
||||
IGNORE_UNUSED_VARIABLE(logContext);
|
||||
|
||||
list_for_each_entry(mapping, &thisCast->poolMappings, _list)
|
||||
{
|
||||
bool wasNewTarget = TargetMapper_mapTarget(targetMapper, mapping->targetID, nodeID);
|
||||
if(wasNewTarget)
|
||||
{
|
||||
LOG_DEBUG_FORMATTED(log, Log_WARNING, logContext, "Mapping target %hu => node %hu",
|
||||
mapping->targetID, nodeID.value);
|
||||
}
|
||||
}
|
||||
|
||||
// send ack
|
||||
MsgHelperAck_respondToAckRequest(app, MapTargetsMsgEx_getAckID(thisCast), fromAddr, sock,
|
||||
respBuf, bufLen);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef MAPTARGETSMSGEX_H_
|
||||
#define MAPTARGETSMSGEX_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/storage/StoragePoolId.h>
|
||||
|
||||
/**
|
||||
* Note: Only the receive/deserialize part of this message is implemented (so it cannot be sent).
|
||||
* Note: Processing only sends response when ackID is set (no MapTargetsRespMsg implemented).
|
||||
*/
|
||||
|
||||
struct MapTargetsMsgEx;
|
||||
typedef struct MapTargetsMsgEx MapTargetsMsgEx;
|
||||
|
||||
static inline void MapTargetsMsgEx_init(MapTargetsMsgEx* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool MapTargetsMsgEx_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
extern bool __MapTargetsMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen);
|
||||
|
||||
// getters & setters
|
||||
static inline NumNodeID MapTargetsMsgEx_getNodeID(MapTargetsMsgEx* this);
|
||||
static inline const char* MapTargetsMsgEx_getAckID(MapTargetsMsgEx* this);
|
||||
|
||||
|
||||
struct MapTargetsMsgEx
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
NumNodeID nodeID;
|
||||
unsigned ackIDLen;
|
||||
const char* ackID;
|
||||
|
||||
struct list_head poolMappings; /* struct TargetPoolMapping */
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps MapTargetsMsgEx_Ops;
|
||||
|
||||
void MapTargetsMsgEx_init(MapTargetsMsgEx* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_MapTargets, &MapTargetsMsgEx_Ops);
|
||||
|
||||
INIT_LIST_HEAD(&this->poolMappings);
|
||||
}
|
||||
|
||||
NumNodeID MapTargetsMsgEx_getNodeID(MapTargetsMsgEx* this)
|
||||
{
|
||||
return this->nodeID;
|
||||
}
|
||||
|
||||
const char* MapTargetsMsgEx_getAckID(MapTargetsMsgEx* this)
|
||||
{
|
||||
return this->ackID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* MAPTARGETSMSGEX_H_ */
|
||||
@@ -0,0 +1,53 @@
|
||||
#include <app/App.h>
|
||||
#include <common/toolkit/SocketTk.h>
|
||||
#include <common/net/msghelpers/MsgHelperAck.h>
|
||||
#include <components/InternodeSyncer.h>
|
||||
|
||||
#include "RefreshTargetStatesMsgEx.h"
|
||||
|
||||
|
||||
const struct NetMessageOps RefreshTargetStatesMsgEx_Ops = {
|
||||
.serializePayload = _NetMessage_serializeDummy,
|
||||
.deserializePayload = RefreshTargetStatesMsgEx_deserializePayload,
|
||||
.processIncoming = __RefreshTargetStatesMsgEx_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
bool RefreshTargetStatesMsgEx_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
RefreshTargetStatesMsgEx* thisCast = (RefreshTargetStatesMsgEx*)this;
|
||||
|
||||
// ackID
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->ackIDLen, &thisCast->ackID) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __RefreshTargetStatesMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen)
|
||||
{
|
||||
Logger* log = App_getLogger(app);
|
||||
const char* logContext = "RefreshTargetStatesMsg incoming";
|
||||
|
||||
RefreshTargetStatesMsgEx* thisCast = (RefreshTargetStatesMsgEx*)this;
|
||||
|
||||
const char* peer;
|
||||
|
||||
InternodeSyncer* internodeSyncer = App_getInternodeSyncer(app);
|
||||
InternodeSyncer_setForceTargetStatesUpdate(internodeSyncer);
|
||||
|
||||
peer = fromAddr ?
|
||||
SocketTk_ipaddrToStr(fromAddr->addr) : StringTk_strDup(Socket_getPeername(sock) );
|
||||
LOG_DEBUG_FORMATTED(log, 4, logContext, "Received a RefreshTargetStatesMsg from: %s", peer);
|
||||
kfree(peer);
|
||||
|
||||
IGNORE_UNUSED_VARIABLE(log);
|
||||
IGNORE_UNUSED_VARIABLE(logContext);
|
||||
|
||||
// send ack
|
||||
MsgHelperAck_respondToAckRequest(app, RefreshTargetStatesMsgEx_getAckID(thisCast), fromAddr,
|
||||
sock, respBuf, bufLen);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef REFRESHTARGETSTATESMSGEX_H_
|
||||
#define REFRESHTARGETSTATESMSGEX_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/Common.h>
|
||||
|
||||
/**
|
||||
* Note: Only the receive/deserialize part of this message is implemented (so it cannot be sent).
|
||||
* Note: Processing only sends response when ackID is set (no RefreshTargetStatesRespMsg
|
||||
* implemented).
|
||||
*/
|
||||
|
||||
struct RefreshTargetStatesMsgEx;
|
||||
typedef struct RefreshTargetStatesMsgEx RefreshTargetStatesMsgEx;
|
||||
|
||||
static inline void RefreshTargetStatesMsgEx_init(RefreshTargetStatesMsgEx* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool RefreshTargetStatesMsgEx_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
extern bool __RefreshTargetStatesMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen);
|
||||
|
||||
// getters & setters
|
||||
static inline const char* RefreshTargetStatesMsgEx_getAckID(RefreshTargetStatesMsgEx* this);
|
||||
|
||||
|
||||
struct RefreshTargetStatesMsgEx
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
unsigned ackIDLen;
|
||||
const char* ackID;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps RefreshTargetStatesMsgEx_Ops;
|
||||
|
||||
void RefreshTargetStatesMsgEx_init(RefreshTargetStatesMsgEx* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_RefreshTargetStates, &RefreshTargetStatesMsgEx_Ops);
|
||||
}
|
||||
|
||||
const char* RefreshTargetStatesMsgEx_getAckID(RefreshTargetStatesMsgEx* this)
|
||||
{
|
||||
return this->ackID;
|
||||
}
|
||||
|
||||
#endif /* REFRESHTARGETSTATESMSGEX_H_ */
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "RegisterNodeMsg.h"
|
||||
|
||||
const struct NetMessageOps RegisterNodeMsg_Ops = {
|
||||
.serializePayload = RegisterNodeMsg_serializePayload,
|
||||
.deserializePayload = _NetMessage_deserializeDummy,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void RegisterNodeMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
RegisterNodeMsg* thisCast = (RegisterNodeMsg*)this;
|
||||
|
||||
// instanceVersion
|
||||
Serialization_serializeUInt64(ctx, thisCast->instanceVersion);
|
||||
|
||||
// nicListVersion
|
||||
Serialization_serializeUInt64(ctx, thisCast->nicListVersion);
|
||||
|
||||
// nodeID
|
||||
Serialization_serializeStr(ctx, thisCast->nodeIDLen, thisCast->nodeID);
|
||||
|
||||
// nicList
|
||||
Serialization_serializeNicList(ctx, thisCast->nicList);
|
||||
|
||||
// nodeType
|
||||
Serialization_serializeInt(ctx, thisCast->nodeType);
|
||||
|
||||
// nodeNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->nodeNumID);
|
||||
|
||||
// rootNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->rootNumID);
|
||||
|
||||
// rootIsBuddyMirrored
|
||||
Serialization_serializeBool(ctx, thisCast->rootIsBuddyMirrored);
|
||||
|
||||
// portUDP
|
||||
Serialization_serializeUShort(ctx, thisCast->portUDP);
|
||||
|
||||
// portTCP
|
||||
Serialization_serializeUShort(ctx, thisCast->portTCP);
|
||||
|
||||
// machineUUID
|
||||
Serialization_serializeStr(ctx, thisCast->machineUUIDLen, thisCast->machineUUID);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
#ifndef REGISTERNODEMSG_H
|
||||
#define REGISTERNODEMSG_H
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/net/sock/NetworkInterfaceCard.h>
|
||||
#include <toolkit/BitStore.h>
|
||||
|
||||
struct RegisterNodeMsg;
|
||||
typedef struct RegisterNodeMsg RegisterNodeMsg;
|
||||
|
||||
static inline void RegisterNodeMsg_init(RegisterNodeMsg* this);
|
||||
static inline void RegisterNodeMsg_initFromNodeData(RegisterNodeMsg* this, const char* nodeID,
|
||||
const NumNodeID nodeNumID, const int nodeType, NicAddressList* nicList, const uint16_t portUDP);
|
||||
|
||||
// virtual functions
|
||||
extern void RegisterNodeMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
|
||||
struct RegisterNodeMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
const char* nodeID; // not owned by this object
|
||||
unsigned nodeIDLen;
|
||||
NumNodeID nodeNumID;
|
||||
|
||||
NumNodeID rootNumID;
|
||||
bool rootIsBuddyMirrored;
|
||||
|
||||
int nodeType;
|
||||
|
||||
NicAddressList* nicList; // not owned by this object
|
||||
|
||||
uint16_t portUDP;
|
||||
uint16_t portTCP;
|
||||
|
||||
uint64_t instanceVersion; // not used currently
|
||||
uint64_t nicListVersion; // not used currently
|
||||
|
||||
const char* machineUUID;
|
||||
unsigned machineUUIDLen;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps RegisterNodeMsg_Ops;
|
||||
|
||||
void RegisterNodeMsg_init(RegisterNodeMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_RegisterNode, &RegisterNodeMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeID just a reference, so do not free it as long as you use this object
|
||||
* @param nicList just a reference, so do not free it as long as you use this object
|
||||
*/
|
||||
void RegisterNodeMsg_initFromNodeData(RegisterNodeMsg* this, const char* nodeID,
|
||||
const NumNodeID nodeNumID, const int nodeType,
|
||||
NicAddressList* nicList, const uint16_t portUDP)
|
||||
{
|
||||
RegisterNodeMsg_init(this);
|
||||
|
||||
this->nodeID = nodeID;
|
||||
this->nodeIDLen = strlen(nodeID);
|
||||
this->nodeNumID = nodeNumID;
|
||||
this->nodeType = nodeType;
|
||||
this->nicList = nicList;
|
||||
this->portUDP = portUDP;
|
||||
|
||||
// not used in client, but general RegisterNodeMsg has it and expects it to be serialized
|
||||
this->rootNumID = (NumNodeID){0};
|
||||
this->rootIsBuddyMirrored = false;
|
||||
|
||||
this->nicListVersion = 0; // undefined
|
||||
this->instanceVersion = 0; // undefined
|
||||
this->portTCP = 0; // undefined
|
||||
this->machineUUID = ""; // not currently needed on the client
|
||||
this->machineUUIDLen = 0;
|
||||
}
|
||||
|
||||
#endif /*REGISTERNODEMSG_H*/
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "RegisterNodeRespMsg.h"
|
||||
|
||||
const struct NetMessageOps RegisterNodeRespMsg_Ops = {
|
||||
.serializePayload = _NetMessage_serializeDummy, // serialization not implemented
|
||||
.deserializePayload = RegisterNodeRespMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
bool RegisterNodeRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
RegisterNodeRespMsg* thisCast = (RegisterNodeRespMsg*)this;
|
||||
|
||||
// nodeNumID
|
||||
if(!NumNodeID_deserialize(ctx, &thisCast->nodeNumID) )
|
||||
return false;
|
||||
|
||||
// GRPC Port
|
||||
if(!Serialization_deserializeUShort(ctx, &thisCast->grpcPort) )
|
||||
return false;
|
||||
|
||||
// fsUUID
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->fsUUIDLen,
|
||||
&thisCast->fsUUID) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#ifndef REGISTERNODERESPMSG_H
|
||||
#define REGISTERNODERESPMSG_H
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
|
||||
struct RegisterNodeRespMsg;
|
||||
typedef struct RegisterNodeRespMsg RegisterNodeRespMsg;
|
||||
|
||||
static inline void RegisterNodeRespMsg_init(RegisterNodeRespMsg* this);
|
||||
static inline NumNodeID RegisterNodeRespMsg_getNodeNumID(RegisterNodeRespMsg* this);
|
||||
static inline int RegisterNodeRespMsg_getGrpcPort(RegisterNodeRespMsg* this);
|
||||
static inline const char* RegisterNodeRespMsg_getFsUUID(RegisterNodeRespMsg* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool RegisterNodeRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
struct RegisterNodeRespMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
NumNodeID nodeNumID;
|
||||
unsigned short grpcPort;
|
||||
unsigned fsUUIDLen;
|
||||
const char* fsUUID;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps RegisterNodeRespMsg_Ops;
|
||||
|
||||
void RegisterNodeRespMsg_init(RegisterNodeRespMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_RegisterNodeResp, &RegisterNodeRespMsg_Ops);
|
||||
}
|
||||
|
||||
NumNodeID RegisterNodeRespMsg_getNodeNumID(RegisterNodeRespMsg* this)
|
||||
{
|
||||
return this->nodeNumID;
|
||||
}
|
||||
|
||||
int RegisterNodeRespMsg_getGrpcPort(RegisterNodeRespMsg* this)
|
||||
{
|
||||
return this->grpcPort;
|
||||
}
|
||||
|
||||
const char* RegisterNodeRespMsg_getFsUUID(RegisterNodeRespMsg* this)
|
||||
{
|
||||
return this->fsUUID;
|
||||
}
|
||||
|
||||
#endif /*REGISTERNODERESPMSG_H*/
|
||||
126
client_module/source/common/net/message/nodes/RemoveNodeMsgEx.c
Normal file
126
client_module/source/common/net/message/nodes/RemoveNodeMsgEx.c
Normal file
@@ -0,0 +1,126 @@
|
||||
#include <common/nodes/Node.h>
|
||||
#include <components/DatagramListener.h>
|
||||
#include <nodes/NodeStoreEx.h>
|
||||
#include <common/toolkit/SocketTk.h>
|
||||
#include <common/net/msghelpers/MsgHelperAck.h>
|
||||
#include <app/App.h>
|
||||
#include "RemoveNodeRespMsg.h"
|
||||
#include "RemoveNodeMsgEx.h"
|
||||
|
||||
|
||||
const struct NetMessageOps RemoveNodeMsgEx_Ops = {
|
||||
.serializePayload = RemoveNodeMsgEx_serializePayload,
|
||||
.deserializePayload = RemoveNodeMsgEx_deserializePayload,
|
||||
.processIncoming = __RemoveNodeMsgEx_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void RemoveNodeMsgEx_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
RemoveNodeMsgEx* thisCast = (RemoveNodeMsgEx*)this;
|
||||
|
||||
// nodeType
|
||||
Serialization_serializeShort(ctx, thisCast->nodeType);
|
||||
|
||||
// nodeNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->nodeNumID);
|
||||
|
||||
// ackID
|
||||
Serialization_serializeStr(ctx, thisCast->ackIDLen, thisCast->ackID);
|
||||
}
|
||||
|
||||
bool RemoveNodeMsgEx_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
RemoveNodeMsgEx* thisCast = (RemoveNodeMsgEx*)this;
|
||||
|
||||
// nodeType
|
||||
if(!Serialization_deserializeShort(ctx, &thisCast->nodeType) )
|
||||
return false;
|
||||
|
||||
// nodeNumID
|
||||
if(!NumNodeID_deserialize(ctx, &thisCast->nodeNumID) )
|
||||
return false;
|
||||
|
||||
// ackID
|
||||
if(!Serialization_deserializeStr(ctx, &thisCast->ackIDLen, &thisCast->ackID) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __RemoveNodeMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen)
|
||||
{
|
||||
Logger* log = App_getLogger(app);
|
||||
const char* logContext = "RemoveNodeMsg incoming";
|
||||
|
||||
RemoveNodeMsgEx* thisCast = (RemoveNodeMsgEx*)this;
|
||||
|
||||
const char* peer;
|
||||
NodeType nodeType = (NodeType)RemoveNodeMsgEx_getNodeType(thisCast);
|
||||
NumNodeID nodeID = RemoveNodeMsgEx_getNodeNumID(thisCast);
|
||||
|
||||
RemoveNodeRespMsg respMsg;
|
||||
unsigned respLen;
|
||||
bool serializeRes;
|
||||
ssize_t sendRes;
|
||||
|
||||
peer = fromAddr ?
|
||||
SocketTk_ipaddrToStr(fromAddr->addr) : StringTk_strDup(Socket_getPeername(sock) );
|
||||
LOG_DEBUG_FORMATTED(log, Log_DEBUG, logContext,
|
||||
"Received a RemoveNodeMsg from: %s; Node: %s %hu",
|
||||
peer, Node_nodeTypeToStr(nodeType), nodeID.value);
|
||||
kfree(peer);
|
||||
|
||||
|
||||
if(nodeType == NODETYPE_Meta)
|
||||
{
|
||||
NodeStoreEx* nodes = App_getMetaNodes(app);
|
||||
if(NodeStoreEx_deleteNode(nodes, nodeID) )
|
||||
Logger_logFormatted(log, Log_WARNING, logContext, "Removed metadata node: %hu", nodeID.value);
|
||||
}
|
||||
else
|
||||
if(nodeType == NODETYPE_Storage)
|
||||
{
|
||||
NodeStoreEx* nodes = App_getStorageNodes(app);
|
||||
if(NodeStoreEx_deleteNode(nodes, nodeID) )
|
||||
Logger_logFormatted(log, Log_WARNING, logContext, "Removed storage node: %hu", nodeID.value);
|
||||
}
|
||||
else
|
||||
{ // should never happen
|
||||
Logger_logFormatted(log, Log_WARNING, logContext,
|
||||
"Received removal request for invalid node type: %d (%s)",
|
||||
(int)nodeType, Node_nodeTypeToStr(nodeType) );
|
||||
}
|
||||
|
||||
|
||||
// send response
|
||||
if(!MsgHelperAck_respondToAckRequest(app, RemoveNodeMsgEx_getAckID(thisCast),
|
||||
fromAddr, sock, respBuf, bufLen) )
|
||||
{
|
||||
RemoveNodeRespMsg_initFromValue(&respMsg, 0);
|
||||
|
||||
respLen = NetMessage_getMsgLength( (NetMessage*)&respMsg);
|
||||
serializeRes = NetMessage_serialize( (NetMessage*)&respMsg, respBuf, bufLen);
|
||||
if(unlikely(!serializeRes) )
|
||||
{
|
||||
Logger_logErrFormatted(log, logContext, "Unable to serialize response");
|
||||
goto err_resp_uninit;
|
||||
}
|
||||
|
||||
if(fromAddr)
|
||||
{ // datagram => sync via dgramLis send method
|
||||
DatagramListener* dgramLis = App_getDatagramListener(app);
|
||||
sendRes = DatagramListener_sendto_kernel(dgramLis, respBuf, respLen, 0, fromAddr);
|
||||
}
|
||||
else
|
||||
sendRes = Socket_sendto_kernel(sock, respBuf, respLen, 0, NULL);
|
||||
|
||||
if(unlikely(sendRes <= 0) )
|
||||
Logger_logErrFormatted(log, logContext, "Send error. ErrCode: %lld", (long long)sendRes);
|
||||
}
|
||||
|
||||
err_resp_uninit:
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#ifndef REMOVENODEMSGEX_H_
|
||||
#define REMOVENODEMSGEX_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
|
||||
|
||||
struct RemoveNodeMsgEx;
|
||||
typedef struct RemoveNodeMsgEx RemoveNodeMsgEx;
|
||||
|
||||
static inline void RemoveNodeMsgEx_init(RemoveNodeMsgEx* this);
|
||||
static inline void RemoveNodeMsgEx_initFromNodeData(RemoveNodeMsgEx* this,
|
||||
NumNodeID nodeNumID, NodeType nodeType);
|
||||
|
||||
// virtual functions
|
||||
extern void RemoveNodeMsgEx_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
extern bool RemoveNodeMsgEx_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
extern bool __RemoveNodeMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen);
|
||||
|
||||
// getters & setters
|
||||
static inline NumNodeID RemoveNodeMsgEx_getNodeNumID(RemoveNodeMsgEx* this);
|
||||
static inline NodeType RemoveNodeMsgEx_getNodeType(RemoveNodeMsgEx* this);
|
||||
static inline const char* RemoveNodeMsgEx_getAckID(RemoveNodeMsgEx* this);
|
||||
|
||||
|
||||
struct RemoveNodeMsgEx
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
NumNodeID nodeNumID;
|
||||
int16_t nodeType;
|
||||
unsigned ackIDLen;
|
||||
const char* ackID;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps RemoveNodeMsgEx_Ops;
|
||||
|
||||
void RemoveNodeMsgEx_init(RemoveNodeMsgEx* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_RemoveNode, &RemoveNodeMsgEx_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeID just a reference, so do not free it as long as you use this object!
|
||||
*/
|
||||
void RemoveNodeMsgEx_initFromNodeData(RemoveNodeMsgEx* this,
|
||||
NumNodeID nodeNumID, NodeType nodeType)
|
||||
{
|
||||
RemoveNodeMsgEx_init(this);
|
||||
|
||||
this->nodeNumID = nodeNumID;
|
||||
|
||||
this->nodeType = (int16_t)nodeType;
|
||||
|
||||
this->ackID = "";
|
||||
this->ackIDLen = 0;
|
||||
}
|
||||
|
||||
NumNodeID RemoveNodeMsgEx_getNodeNumID(RemoveNodeMsgEx* this)
|
||||
{
|
||||
return this->nodeNumID;
|
||||
}
|
||||
|
||||
NodeType RemoveNodeMsgEx_getNodeType(RemoveNodeMsgEx* this)
|
||||
{
|
||||
return (NodeType)this->nodeType;
|
||||
}
|
||||
|
||||
const char* RemoveNodeMsgEx_getAckID(RemoveNodeMsgEx* this)
|
||||
{
|
||||
return this->ackID;
|
||||
}
|
||||
|
||||
#endif /* REMOVENODEMSGEX_H_ */
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef REMOVENODERESPMSG_H_
|
||||
#define REMOVENODERESPMSG_H_
|
||||
|
||||
#include <common/net/message/SimpleIntMsg.h>
|
||||
|
||||
|
||||
struct RemoveNodeRespMsg;
|
||||
typedef struct RemoveNodeRespMsg RemoveNodeRespMsg;
|
||||
|
||||
static inline void RemoveNodeRespMsg_init(RemoveNodeRespMsg* this);
|
||||
static inline void RemoveNodeRespMsg_initFromValue(RemoveNodeRespMsg* this, int value);
|
||||
|
||||
struct RemoveNodeRespMsg
|
||||
{
|
||||
SimpleIntMsg simpleIntMsg;
|
||||
};
|
||||
|
||||
|
||||
void RemoveNodeRespMsg_init(RemoveNodeRespMsg* this)
|
||||
{
|
||||
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_RemoveNodeResp);
|
||||
}
|
||||
|
||||
void RemoveNodeRespMsg_initFromValue(RemoveNodeRespMsg* this, int value)
|
||||
{
|
||||
SimpleIntMsg_initFromValue( (SimpleIntMsg*)this, NETMSGTYPE_RemoveNodeResp, value);
|
||||
}
|
||||
|
||||
#endif /* REMOVENODERESPMSG_H_ */
|
||||
@@ -0,0 +1,103 @@
|
||||
#include <common/net/msghelpers/MsgHelperAck.h>
|
||||
#include <common/nodes/MirrorBuddyGroupMapper.h>
|
||||
#include <app/App.h>
|
||||
|
||||
#include "SetMirrorBuddyGroupMsgEx.h"
|
||||
|
||||
const struct NetMessageOps SetMirrorBuddyGroupMsgEx_Ops = {
|
||||
.serializePayload = _NetMessage_serializeDummy,
|
||||
.deserializePayload = SetMirrorBuddyGroupMsgEx_deserializePayload,
|
||||
.processIncoming = __SetMirrorBuddyGroupMsgEx_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
bool SetMirrorBuddyGroupMsgEx_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
SetMirrorBuddyGroupMsgEx* thisCast = (SetMirrorBuddyGroupMsgEx*)this;
|
||||
|
||||
// nodeType
|
||||
if (!Serialization_deserializeInt(ctx, &thisCast->nodeType) )
|
||||
return false;
|
||||
|
||||
// primaryTargetID
|
||||
if (!Serialization_deserializeUShort(ctx, &thisCast->primaryTargetID) )
|
||||
return false;
|
||||
|
||||
// secondaryTargetID
|
||||
if (!Serialization_deserializeUShort(ctx, &thisCast->secondaryTargetID) )
|
||||
return false;
|
||||
|
||||
// buddyGroupID
|
||||
if (!Serialization_deserializeUShort(ctx, &thisCast->buddyGroupID) )
|
||||
return false;
|
||||
|
||||
// allowUpdate
|
||||
if (!Serialization_deserializeBool(ctx, &thisCast->allowUpdate) )
|
||||
return false;
|
||||
|
||||
// ackID
|
||||
if (!Serialization_deserializeStr(ctx, &thisCast->ackIDLen, &thisCast->ackID) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __SetMirrorBuddyGroupMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen)
|
||||
{
|
||||
Logger* log = App_getLogger(app);
|
||||
MirrorBuddyGroupMapper* mirrorBuddyGroupMapper;
|
||||
TargetMapper* targetMapper = NULL;
|
||||
const char* logContext = "SetMirrorBuddyGroupMsg Incoming";
|
||||
FhgfsOpsErr addGroupResult;
|
||||
|
||||
SetMirrorBuddyGroupMsgEx* thisCast = (SetMirrorBuddyGroupMsgEx*)this;
|
||||
|
||||
const char* peer;
|
||||
|
||||
uint16_t primaryTargetID = SetMirrorBuddyGroupMsgEx_getPrimaryTargetID(thisCast);
|
||||
uint16_t secondaryTargetID = SetMirrorBuddyGroupMsgEx_getSecondaryTargetID(thisCast);
|
||||
uint16_t buddyGroupID = SetMirrorBuddyGroupMsgEx_getBuddyGroupID(thisCast);
|
||||
bool allowUpdate = SetMirrorBuddyGroupMsgEx_getAllowUpdate(thisCast);
|
||||
|
||||
NodeType nodeType = SetMirrorBuddyGroupMsgEx_getNodeType(thisCast);
|
||||
|
||||
switch (nodeType)
|
||||
{
|
||||
case NODETYPE_Storage:
|
||||
mirrorBuddyGroupMapper = App_getStorageBuddyGroupMapper(app);
|
||||
targetMapper = App_getTargetMapper(app);
|
||||
break;
|
||||
|
||||
case NODETYPE_Meta:
|
||||
mirrorBuddyGroupMapper = App_getMetaBuddyGroupMapper(app);
|
||||
break;
|
||||
|
||||
default:
|
||||
Logger_logErr(log, logContext, "Node type mismatch");
|
||||
return false;
|
||||
}
|
||||
|
||||
addGroupResult = MirrorBuddyGroupMapper_addGroup(mirrorBuddyGroupMapper, app->cfg, targetMapper,
|
||||
buddyGroupID, primaryTargetID, secondaryTargetID, allowUpdate);
|
||||
|
||||
if (addGroupResult == FhgfsOpsErr_SUCCESS)
|
||||
Logger_logFormatted(log, Log_NOTICE, logContext, "Added mirror group: Node type: %s; "
|
||||
"Group ID: %hu; Primary target ID: %hu; Secondary target ID: %hu.",
|
||||
Node_nodeTypeToStr(nodeType), buddyGroupID, primaryTargetID, secondaryTargetID);
|
||||
else
|
||||
Logger_logFormatted(log, Log_WARNING, logContext, "Error adding mirror buddy group: "
|
||||
"Node type: %s, Group ID: %hu; Primary target ID: %hu; Secondary target ID: %hu; "
|
||||
"Error: %s",
|
||||
Node_nodeTypeToStr(nodeType), buddyGroupID, primaryTargetID, secondaryTargetID,
|
||||
FhgfsOpsErr_toErrString(addGroupResult) );
|
||||
|
||||
peer = fromAddr ?
|
||||
SocketTk_ipaddrToStr(fromAddr->addr) : StringTk_strDup(Socket_getPeername(sock) );
|
||||
|
||||
// send Ack
|
||||
MsgHelperAck_respondToAckRequest(app, SetMirrorBuddyGroupMsgEx_getAckID(thisCast), fromAddr,
|
||||
sock, respBuf, bufLen);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
#ifndef SETMIRRORBUDDYGROUPMSGEX_H_
|
||||
#define SETMIRRORBUDDYGROUPMSGEX_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
|
||||
|
||||
struct SetMirrorBuddyGroupMsgEx;
|
||||
typedef struct SetMirrorBuddyGroupMsgEx SetMirrorBuddyGroupMsgEx;
|
||||
|
||||
static inline void SetMirrorBuddyGroupMsgEx_init(SetMirrorBuddyGroupMsgEx* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool SetMirrorBuddyGroupMsgEx_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
extern bool __SetMirrorBuddyGroupMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen);
|
||||
|
||||
// getters and setters
|
||||
static inline NodeType SetMirrorBuddyGroupMsgEx_getNodeType(SetMirrorBuddyGroupMsgEx* this);
|
||||
static inline uint16_t SetMirrorBuddyGroupMsgEx_getPrimaryTargetID(SetMirrorBuddyGroupMsgEx* this);
|
||||
static inline uint16_t SetMirrorBuddyGroupMsgEx_getSecondaryTargetID(SetMirrorBuddyGroupMsgEx* this);
|
||||
static inline uint16_t SetMirrorBuddyGroupMsgEx_getBuddyGroupID(SetMirrorBuddyGroupMsgEx* this);
|
||||
static inline bool SetMirrorBuddyGroupMsgEx_getAllowUpdate(SetMirrorBuddyGroupMsgEx* this);
|
||||
static inline const char* SetMirrorBuddyGroupMsgEx_getAckID(SetMirrorBuddyGroupMsgEx* this);
|
||||
|
||||
struct SetMirrorBuddyGroupMsgEx
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
int nodeType;
|
||||
uint16_t primaryTargetID;
|
||||
uint16_t secondaryTargetID;
|
||||
uint16_t buddyGroupID;
|
||||
bool allowUpdate;
|
||||
|
||||
unsigned ackIDLen;
|
||||
const char* ackID;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps SetMirrorBuddyGroupMsgEx_Ops;
|
||||
|
||||
void SetMirrorBuddyGroupMsgEx_init(SetMirrorBuddyGroupMsgEx* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_SetMirrorBuddyGroup,
|
||||
&SetMirrorBuddyGroupMsgEx_Ops);
|
||||
}
|
||||
|
||||
static inline NodeType SetMirrorBuddyGroupMsgEx_getNodeType(SetMirrorBuddyGroupMsgEx* this)
|
||||
{
|
||||
return (NodeType)this->nodeType;
|
||||
}
|
||||
|
||||
static inline uint16_t SetMirrorBuddyGroupMsgEx_getPrimaryTargetID(SetMirrorBuddyGroupMsgEx* this)
|
||||
{
|
||||
return this->primaryTargetID;
|
||||
}
|
||||
|
||||
static inline uint16_t SetMirrorBuddyGroupMsgEx_getSecondaryTargetID(SetMirrorBuddyGroupMsgEx* this)
|
||||
{
|
||||
return this->secondaryTargetID;
|
||||
}
|
||||
|
||||
static inline uint16_t SetMirrorBuddyGroupMsgEx_getBuddyGroupID(SetMirrorBuddyGroupMsgEx* this)
|
||||
{
|
||||
return this->buddyGroupID;
|
||||
}
|
||||
|
||||
static inline bool SetMirrorBuddyGroupMsgEx_getAllowUpdate(SetMirrorBuddyGroupMsgEx* this)
|
||||
{
|
||||
return this->allowUpdate;
|
||||
}
|
||||
|
||||
const char* SetMirrorBuddyGroupMsgEx_getAckID(SetMirrorBuddyGroupMsgEx* this)
|
||||
{
|
||||
return this->ackID;
|
||||
}
|
||||
|
||||
#endif /* SETMIRRORBUDDYGROUPMSGEX_H_ */
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "BumpFileVersion.h"
|
||||
|
||||
static void BumpFileVersionMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
struct BumpFileVersionMsg* msg = container_of(this, struct BumpFileVersionMsg, netMessage);
|
||||
|
||||
EntryInfo_serialize(ctx, msg->entryInfo);
|
||||
|
||||
if (this->msgHeader.msgFeatureFlags & BUMPFILEVERSIONMSG_FLAG_HASEVENT)
|
||||
FileEvent_serialize(ctx, msg->fileEvent);
|
||||
}
|
||||
|
||||
const struct NetMessageOps BumpFileVersionMsg_Ops = {
|
||||
.serializePayload = BumpFileVersionMsg_serializePayload,
|
||||
.deserializePayload = _NetMessage_deserializeDummy,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
.supportsSequenceNumbers = true,
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef BUMPFILEVERSIONMSG_H_
|
||||
#define BUMPFILEVERSIONMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/storage/EntryInfo.h>
|
||||
#include <common/storage/FileEvent.h>
|
||||
|
||||
#define BUMPFILEVERSIONMSG_FLAG_PERSISTENT 1 /* change persistent file version number too */
|
||||
#define BUMPFILEVERSIONMSG_FLAG_HASEVENT 2 /* has a loggable event attached */
|
||||
|
||||
/**
|
||||
* Note: This message supports only serialization, deserialization is not implemented.
|
||||
*/
|
||||
struct BumpFileVersionMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
const EntryInfo* entryInfo;
|
||||
const struct FileEvent* fileEvent;
|
||||
};
|
||||
extern const struct NetMessageOps BumpFileVersionMsg_Ops;
|
||||
|
||||
static inline void BumpFileVersionMsg_init(struct BumpFileVersionMsg* this,
|
||||
const EntryInfo* entryInfo, bool persistent, const struct FileEvent* fileEvent)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_BumpFileVersion, &BumpFileVersionMsg_Ops);
|
||||
|
||||
this->entryInfo = entryInfo;
|
||||
this->fileEvent = fileEvent;
|
||||
|
||||
if (persistent)
|
||||
this->netMessage.msgHeader.msgFeatureFlags |= BUMPFILEVERSIONMSG_FLAG_PERSISTENT;
|
||||
|
||||
if (fileEvent)
|
||||
this->netMessage.msgHeader.msgFeatureFlags |= BUMPFILEVERSIONMSG_FLAG_HASEVENT;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef BUMPFILEVERSIONRESPMSG_H_
|
||||
#define BUMPFILEVERSIONRESPMSG_H_
|
||||
|
||||
#include "../SimpleIntMsg.h"
|
||||
|
||||
typedef struct BumpFileVersionRespMsg BumpFileVersionRespMsg;
|
||||
|
||||
struct BumpFileVersionRespMsg
|
||||
{
|
||||
SimpleIntMsg base;
|
||||
};
|
||||
|
||||
|
||||
static inline void BumpFileVersionRespMsg_init(struct BumpFileVersionRespMsg* this)
|
||||
{
|
||||
SimpleIntMsg_init(&this->base, NETMSGTYPE_BumpFileVersionResp);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "FSyncLocalFileMsg.h"
|
||||
|
||||
|
||||
const struct NetMessageOps FSyncLocalFileMsg_Ops = {
|
||||
.serializePayload = FSyncLocalFileMsg_serializePayload,
|
||||
.deserializePayload = _NetMessage_deserializeDummy,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void FSyncLocalFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
FSyncLocalFileMsg* thisCast = (FSyncLocalFileMsg*)this;
|
||||
|
||||
// clientNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->clientNumID);
|
||||
|
||||
// fileHandleID
|
||||
Serialization_serializeStrAlign4(ctx, thisCast->fileHandleIDLen, thisCast->fileHandleID);
|
||||
|
||||
// targetID
|
||||
Serialization_serializeUShort(ctx, thisCast->targetID);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef FSYNCLOCALFILEMSG_H_
|
||||
#define FSYNCLOCALFILEMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
|
||||
|
||||
#define FSYNCLOCALFILEMSG_FLAG_NO_SYNC 1 /* if a sync is not needed */
|
||||
#define FSYNCLOCALFILEMSG_FLAG_SESSION_CHECK 2 /* if session check should be done */
|
||||
#define FSYNCLOCALFILEMSG_FLAG_BUDDYMIRROR 4 /* given targetID is a buddymirrorgroup ID */
|
||||
#define FSYNCLOCALFILEMSG_FLAG_BUDDYMIRROR_SECOND 8 /* secondary of group, otherwise primary */
|
||||
|
||||
|
||||
struct FSyncLocalFileMsg;
|
||||
typedef struct FSyncLocalFileMsg FSyncLocalFileMsg;
|
||||
|
||||
static inline void FSyncLocalFileMsg_init(FSyncLocalFileMsg* this);
|
||||
static inline void FSyncLocalFileMsg_initFromSession(FSyncLocalFileMsg* this,
|
||||
NumNodeID clientNumID, const char* fileHandleID, uint16_t targetID);
|
||||
|
||||
// virtual functions
|
||||
extern void FSyncLocalFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Note: This message supports only serialization, deserialization is not implemented.
|
||||
*/
|
||||
struct FSyncLocalFileMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
NumNodeID clientNumID;
|
||||
const char* fileHandleID;
|
||||
unsigned fileHandleIDLen;
|
||||
uint16_t targetID;
|
||||
};
|
||||
extern const struct NetMessageOps FSyncLocalFileMsg_Ops;
|
||||
|
||||
void FSyncLocalFileMsg_init(FSyncLocalFileMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_FSyncLocalFile, &FSyncLocalFileMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileHandleID just a reference, so do not free it as long as you use this object!
|
||||
*/
|
||||
void FSyncLocalFileMsg_initFromSession(FSyncLocalFileMsg* this, NumNodeID clientNumID,
|
||||
const char* fileHandleID, uint16_t targetID)
|
||||
{
|
||||
FSyncLocalFileMsg_init(this);
|
||||
|
||||
this->clientNumID = clientNumID;
|
||||
|
||||
this->fileHandleID = fileHandleID;
|
||||
this->fileHandleIDLen = strlen(fileHandleID);
|
||||
|
||||
this->targetID = targetID;
|
||||
}
|
||||
|
||||
#endif /*FSYNCLOCALFILEMSG_H_*/
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef FSYNCLOCALFILERESPMSG_H_
|
||||
#define FSYNCLOCALFILERESPMSG_H_
|
||||
|
||||
#include "../SimpleInt64Msg.h"
|
||||
|
||||
|
||||
struct FSyncLocalFileRespMsg;
|
||||
typedef struct FSyncLocalFileRespMsg FSyncLocalFileRespMsg;
|
||||
|
||||
static inline void FSyncLocalFileRespMsg_init(FSyncLocalFileRespMsg* this);
|
||||
|
||||
// getters & setters
|
||||
static inline int64_t FSyncLocalFileRespMsg_getValue(FSyncLocalFileRespMsg* this);
|
||||
|
||||
|
||||
struct FSyncLocalFileRespMsg
|
||||
{
|
||||
SimpleInt64Msg simpleInt64Msg;
|
||||
};
|
||||
|
||||
|
||||
void FSyncLocalFileRespMsg_init(FSyncLocalFileRespMsg* this)
|
||||
{
|
||||
SimpleInt64Msg_init( (SimpleInt64Msg*)this, NETMSGTYPE_FSyncLocalFileResp);
|
||||
}
|
||||
|
||||
int64_t FSyncLocalFileRespMsg_getValue(FSyncLocalFileRespMsg* this)
|
||||
{
|
||||
return SimpleInt64Msg_getValue( (SimpleInt64Msg*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /*FSYNCLOCALFILERESPMSG_H_*/
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "GetFileVersionMsg.h"
|
||||
|
||||
static void GetFileVersionMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
struct GetFileVersionMsg* msg = container_of(this, struct GetFileVersionMsg, netMessage);
|
||||
|
||||
EntryInfo_serialize(ctx, msg->entryInfo);
|
||||
}
|
||||
|
||||
const struct NetMessageOps GetFileVersionMsg_Ops = {
|
||||
.serializePayload = GetFileVersionMsg_serializePayload,
|
||||
.deserializePayload = _NetMessage_deserializeDummy,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef GETFILEVERSIONMSG_H_
|
||||
#define GETFILEVERSIONMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/storage/EntryInfo.h>
|
||||
|
||||
/**
|
||||
* Note: This message supports only serialization, deserialization is not implemented.
|
||||
*/
|
||||
struct GetFileVersionMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
const EntryInfo* entryInfo;
|
||||
};
|
||||
extern const struct NetMessageOps GetFileVersionMsg_Ops;
|
||||
|
||||
static inline void GetFileVersionMsg_init(struct GetFileVersionMsg* this,
|
||||
const EntryInfo* entryInfo)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_GetFileVersion, &GetFileVersionMsg_Ops);
|
||||
|
||||
this->entryInfo = entryInfo;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "GetFileVersionRespMsg.h"
|
||||
|
||||
static bool GetFileVersionRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
struct GetFileVersionRespMsg* msg = container_of(this, struct GetFileVersionRespMsg, base);
|
||||
|
||||
int result;
|
||||
|
||||
if (!Serialization_deserializeInt(ctx, &result) ||
|
||||
!Serialization_deserializeUInt(ctx, &msg->version))
|
||||
return false;
|
||||
|
||||
msg->result = result;
|
||||
return true;
|
||||
}
|
||||
|
||||
const struct NetMessageOps GetFileVersionRespMsg_Ops = {
|
||||
.serializePayload = _NetMessage_serializeDummy,
|
||||
.deserializePayload = GetFileVersionRespMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef GETFILEVERSIONRESPMSG_H_
|
||||
#define GETFILEVERSIONRESPMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/storage/StorageErrors.h>
|
||||
|
||||
typedef struct GetFileVersionRespMsg GetFileVersionRespMsg;
|
||||
|
||||
struct GetFileVersionRespMsg
|
||||
{
|
||||
NetMessage base;
|
||||
|
||||
FhgfsOpsErr result;
|
||||
uint32_t version;
|
||||
};
|
||||
extern const struct NetMessageOps GetFileVersionRespMsg_Ops;
|
||||
|
||||
|
||||
static inline void GetFileVersionRespMsg_init(struct GetFileVersionRespMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->base, NETMSGTYPE_GetFileVersionResp, &GetFileVersionRespMsg_Ops);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "FLockAppendMsg.h"
|
||||
|
||||
|
||||
const struct NetMessageOps FLockAppendMsg_Ops = {
|
||||
.serializePayload = FLockAppendMsg_serializePayload,
|
||||
.deserializePayload = _NetMessage_deserializeDummy,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void FLockAppendMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
FLockAppendMsg* thisCast = (FLockAppendMsg*)this;
|
||||
|
||||
// clientNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->clientNumID);
|
||||
|
||||
// clientFD
|
||||
Serialization_serializeInt64(ctx, thisCast->clientFD);
|
||||
|
||||
// ownerPID
|
||||
Serialization_serializeInt(ctx, thisCast->ownerPID);
|
||||
|
||||
// lockTypeFlags
|
||||
Serialization_serializeInt(ctx, thisCast->lockTypeFlags);
|
||||
|
||||
// entryInfo
|
||||
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
|
||||
|
||||
// fileHandleID
|
||||
Serialization_serializeStrAlign4(ctx, thisCast->fileHandleIDLen, thisCast->fileHandleID);
|
||||
|
||||
// lockAckID
|
||||
Serialization_serializeStrAlign4(ctx, thisCast->lockAckIDLen, thisCast->lockAckID);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
#ifndef FLOCKAPPENDMSG_H_
|
||||
#define FLOCKAPPENDMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/storage/EntryInfo.h>
|
||||
|
||||
/**
|
||||
* This message is for serialiazation (outgoing) only, deserialization is not implemented!!
|
||||
*/
|
||||
|
||||
struct FLockAppendMsg;
|
||||
typedef struct FLockAppendMsg FLockAppendMsg;
|
||||
|
||||
static inline void FLockAppendMsg_init(FLockAppendMsg* this);
|
||||
static inline void FLockAppendMsg_initFromSession(FLockAppendMsg* this, NumNodeID clientNumID,
|
||||
const char* fileHandleID, const EntryInfo* entryInfo, int64_t clientFD, int ownerPID,
|
||||
int lockTypeFlags, const char* lockAckID);
|
||||
|
||||
// virtual functions
|
||||
extern void FLockAppendMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
|
||||
|
||||
struct FLockAppendMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
NumNodeID clientNumID;
|
||||
const char* fileHandleID;
|
||||
unsigned fileHandleIDLen;
|
||||
const EntryInfo* entryInfoPtr; // not owned by this object
|
||||
int64_t clientFD; /* client-wide unique identifier (typically not really the fd number)
|
||||
* corresponds to 'struct file_lock* fileLock->fl_file on the client side'
|
||||
*/
|
||||
|
||||
int ownerPID; // pid on client (just informative, because shared on fork() )
|
||||
int lockTypeFlags; // ENTRYLOCKTYPE_...
|
||||
const char* lockAckID; // ID for ack message when log is granted
|
||||
unsigned lockAckIDLen;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps FLockAppendMsg_Ops;
|
||||
|
||||
void FLockAppendMsg_init(FLockAppendMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_FLockAppend, &FLockAppendMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileHandleID just a reference, so do not free it as long as you use this object!
|
||||
* @param entryInfo just a reference, so do not free it as long as you use this object!
|
||||
*/
|
||||
void FLockAppendMsg_initFromSession(FLockAppendMsg* this, NumNodeID clientNumID,
|
||||
const char* fileHandleID, const EntryInfo* entryInfo, int64_t clientFD, int ownerPID,
|
||||
int lockTypeFlags, const char* lockAckID)
|
||||
{
|
||||
FLockAppendMsg_init(this);
|
||||
|
||||
this->clientNumID = clientNumID;
|
||||
|
||||
this->fileHandleID = fileHandleID;
|
||||
this->fileHandleIDLen = strlen(fileHandleID);
|
||||
|
||||
this->entryInfoPtr = entryInfo;
|
||||
|
||||
this->clientFD = clientFD;
|
||||
this->ownerPID = ownerPID;
|
||||
this->lockTypeFlags = lockTypeFlags;
|
||||
|
||||
this->lockAckID = lockAckID;
|
||||
this->lockAckIDLen = strlen(lockAckID);
|
||||
}
|
||||
|
||||
#endif /* FLOCKAPPENDMSG_H_ */
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef FLOCKAPPENDRESPMSG_H_
|
||||
#define FLOCKAPPENDRESPMSG_H_
|
||||
|
||||
#include <common/net/message/SimpleIntMsg.h>
|
||||
#include <common/storage/StorageErrors.h>
|
||||
|
||||
/**
|
||||
* This message is for deserialiazation (incoming) only, serialization is not implemented!!
|
||||
*/
|
||||
|
||||
struct FLockAppendRespMsg;
|
||||
typedef struct FLockAppendRespMsg FLockAppendRespMsg;
|
||||
|
||||
static inline void FLockAppendRespMsg_init(FLockAppendRespMsg* this);
|
||||
|
||||
struct FLockAppendRespMsg
|
||||
{
|
||||
SimpleIntMsg simpleIntMsg;
|
||||
};
|
||||
|
||||
|
||||
void FLockAppendRespMsg_init(FLockAppendRespMsg* this)
|
||||
{
|
||||
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_FLockAppendResp);
|
||||
}
|
||||
|
||||
#endif /* FLOCKAPPENDRESPMSG_H_ */
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "FLockEntryMsg.h"
|
||||
|
||||
|
||||
const struct NetMessageOps FLockEntryMsg_Ops = {
|
||||
.serializePayload = FLockEntryMsg_serializePayload,
|
||||
.deserializePayload = _NetMessage_deserializeDummy,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
.supportsSequenceNumbers = true,
|
||||
};
|
||||
|
||||
void FLockEntryMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
FLockEntryMsg* thisCast = (FLockEntryMsg*)this;
|
||||
|
||||
// clientNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->clientNumID);
|
||||
|
||||
// clientFD
|
||||
Serialization_serializeInt64(ctx, thisCast->clientFD);
|
||||
|
||||
// ownerPID
|
||||
Serialization_serializeInt(ctx, thisCast->ownerPID);
|
||||
|
||||
// lockTypeFlags
|
||||
Serialization_serializeInt(ctx, thisCast->lockTypeFlags);
|
||||
|
||||
// entryInfo
|
||||
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
|
||||
|
||||
// fileHandleID
|
||||
Serialization_serializeStrAlign4(ctx, thisCast->fileHandleIDLen, thisCast->fileHandleID);
|
||||
|
||||
// lockAckID
|
||||
Serialization_serializeStrAlign4(ctx, thisCast->lockAckIDLen, thisCast->lockAckID);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
#ifndef FLOCKENTRYMSG_H_
|
||||
#define FLOCKENTRYMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/storage/EntryInfo.h>
|
||||
|
||||
/**
|
||||
* This message is for serialiazation (outgoing) only, deserialization is not implemented!!
|
||||
*/
|
||||
|
||||
struct FLockEntryMsg;
|
||||
typedef struct FLockEntryMsg FLockEntryMsg;
|
||||
|
||||
static inline void FLockEntryMsg_init(FLockEntryMsg* this);
|
||||
static inline void FLockEntryMsg_initFromSession(FLockEntryMsg* this, NumNodeID clientNumID,
|
||||
const char* fileHandleID, const EntryInfo* entryInfo, int64_t clientFD, int ownerPID,
|
||||
int lockTypeFlags, const char* lockAckID);
|
||||
|
||||
// virtual functions
|
||||
extern void FLockEntryMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
|
||||
|
||||
struct FLockEntryMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
NumNodeID clientNumID;
|
||||
const char* fileHandleID;
|
||||
unsigned fileHandleIDLen;
|
||||
const EntryInfo* entryInfoPtr; // not owned by this object
|
||||
int64_t clientFD; /* client-wide unique identifier (typically not really the fd number)
|
||||
* corresponds to 'struct file_lock* fileLock->fl_file on the client side'
|
||||
*/
|
||||
|
||||
int ownerPID; // pid on client (just informative, because shared on fork() )
|
||||
int lockTypeFlags; // ENTRYLOCKTYPE_...
|
||||
const char* lockAckID; // ID for ack message when log is granted
|
||||
unsigned lockAckIDLen;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps FLockEntryMsg_Ops;
|
||||
|
||||
void FLockEntryMsg_init(FLockEntryMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_FLockEntry, &FLockEntryMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileHandleID just a reference, so do not free it as long as you use this object!
|
||||
* @param entryInfo just a reference, so do not free it as long as you use this object!
|
||||
*/
|
||||
void FLockEntryMsg_initFromSession(FLockEntryMsg* this, NumNodeID clientNumID,
|
||||
const char* fileHandleID, const EntryInfo* entryInfo, int64_t clientFD, int ownerPID,
|
||||
int lockTypeFlags, const char* lockAckID)
|
||||
{
|
||||
FLockEntryMsg_init(this);
|
||||
|
||||
this->clientNumID = clientNumID;
|
||||
|
||||
this->fileHandleID = fileHandleID;
|
||||
this->fileHandleIDLen = strlen(fileHandleID);
|
||||
|
||||
this->entryInfoPtr = entryInfo;
|
||||
|
||||
this->clientFD = clientFD;
|
||||
this->ownerPID = ownerPID;
|
||||
this->lockTypeFlags = lockTypeFlags;
|
||||
|
||||
this->lockAckID = lockAckID;
|
||||
this->lockAckIDLen = strlen(lockAckID);
|
||||
}
|
||||
|
||||
#endif /* FLOCKENTRYMSG_H_ */
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef FLOCKENTRYRESPMSG_H_
|
||||
#define FLOCKENTRYRESPMSG_H_
|
||||
|
||||
#include <common/net/message/SimpleIntMsg.h>
|
||||
#include <common/storage/StorageErrors.h>
|
||||
|
||||
/**
|
||||
* This message is for deserialiazation (incoming) only, serialization is not implemented!!
|
||||
*/
|
||||
|
||||
struct FLockEntryRespMsg;
|
||||
typedef struct FLockEntryRespMsg FLockEntryRespMsg;
|
||||
|
||||
static inline void FLockEntryRespMsg_init(FLockEntryRespMsg* this);
|
||||
|
||||
struct FLockEntryRespMsg
|
||||
{
|
||||
SimpleIntMsg simpleIntMsg;
|
||||
};
|
||||
|
||||
|
||||
void FLockEntryRespMsg_init(FLockEntryRespMsg* this)
|
||||
{
|
||||
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_FLockEntryResp);
|
||||
}
|
||||
|
||||
#endif /* FLOCKENTRYRESPMSG_H_ */
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "FLockRangeMsg.h"
|
||||
|
||||
|
||||
const struct NetMessageOps FLockRangeMsg_Ops = {
|
||||
.serializePayload = FLockRangeMsg_serializePayload,
|
||||
.deserializePayload = _NetMessage_deserializeDummy,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
.supportsSequenceNumbers = true,
|
||||
};
|
||||
|
||||
void FLockRangeMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
FLockRangeMsg* thisCast = (FLockRangeMsg*)this;
|
||||
|
||||
// clientNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->clientNumID);
|
||||
|
||||
// start
|
||||
Serialization_serializeUInt64(ctx, thisCast->start);
|
||||
|
||||
// end
|
||||
Serialization_serializeUInt64(ctx, thisCast->end);
|
||||
|
||||
// ownerPID
|
||||
Serialization_serializeInt(ctx, thisCast->ownerPID);
|
||||
|
||||
// lockTypeFlags
|
||||
Serialization_serializeInt(ctx, thisCast->lockTypeFlags);
|
||||
|
||||
// entryInfo
|
||||
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
|
||||
|
||||
// fileHandleID
|
||||
Serialization_serializeStrAlign4(ctx, thisCast->fileHandleIDLen, thisCast->fileHandleID);
|
||||
|
||||
// lockAckID
|
||||
Serialization_serializeStrAlign4(ctx, thisCast->lockAckIDLen, thisCast->lockAckID);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
#ifndef FLOCKRANGEMSG_H_
|
||||
#define FLOCKRANGEMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/storage/EntryInfo.h>
|
||||
|
||||
/**
|
||||
* This message is for serialiazation (outgoing) only, deserialization is not implemented!!
|
||||
*/
|
||||
|
||||
struct FLockRangeMsg;
|
||||
typedef struct FLockRangeMsg FLockRangeMsg;
|
||||
|
||||
static inline void FLockRangeMsg_init(FLockRangeMsg* this);
|
||||
static inline void FLockRangeMsg_initFromSession(FLockRangeMsg* this, NumNodeID clientNumID,
|
||||
const char* fileHandleID, const EntryInfo* entryInfo,
|
||||
int ownerPID, int lockTypeFlags, uint64_t start, uint64_t end, const char* lockAckID);
|
||||
|
||||
// virtual functions
|
||||
extern void FLockRangeMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
|
||||
|
||||
struct FLockRangeMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
NumNodeID clientNumID;
|
||||
const char* fileHandleID;
|
||||
unsigned fileHandleIDLen;
|
||||
const EntryInfo* entryInfoPtr; // not owned by this object
|
||||
int ownerPID; // pid on client (just informative, because shared on fork() )
|
||||
int lockTypeFlags; // ENTRYLOCKTYPE_...
|
||||
uint64_t start;
|
||||
uint64_t end;
|
||||
const char* lockAckID; // ID for ack message when log is granted
|
||||
unsigned lockAckIDLen;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps FLockRangeMsg_Ops;
|
||||
|
||||
void FLockRangeMsg_init(FLockRangeMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_FLockRange, &FLockRangeMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileHandleID just a reference, so do not free it as long as you use this object!
|
||||
* @param entryInfo just a reference, so do not free it as long as you use this object!
|
||||
*/
|
||||
void FLockRangeMsg_initFromSession(FLockRangeMsg* this, NumNodeID clientNumID,
|
||||
const char* fileHandleID, const EntryInfo* entryInfo,
|
||||
int ownerPID, int lockTypeFlags, uint64_t start, uint64_t end, const char* lockAckID)
|
||||
{
|
||||
FLockRangeMsg_init(this);
|
||||
|
||||
this->clientNumID = clientNumID;
|
||||
|
||||
this->fileHandleID = fileHandleID;
|
||||
this->fileHandleIDLen = strlen(fileHandleID);
|
||||
|
||||
this->entryInfoPtr = entryInfo;
|
||||
|
||||
this->ownerPID = ownerPID;
|
||||
this->lockTypeFlags = lockTypeFlags;
|
||||
|
||||
this->start = start;
|
||||
this->end = end;
|
||||
|
||||
this->lockAckID = lockAckID;
|
||||
this->lockAckIDLen = strlen(lockAckID);
|
||||
}
|
||||
|
||||
#endif /* FLOCKRANGEMSG_H_ */
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef FLOCKRANGERESPMSG_H_
|
||||
#define FLOCKRANGERESPMSG_H_
|
||||
|
||||
#include <common/net/message/SimpleIntMsg.h>
|
||||
#include <common/storage/StorageErrors.h>
|
||||
|
||||
/**
|
||||
* This message is for deserialiazation (incoming) only, serialization is not implemented!!
|
||||
*/
|
||||
|
||||
struct FLockRangeRespMsg;
|
||||
typedef struct FLockRangeRespMsg FLockRangeRespMsg;
|
||||
|
||||
static inline void FLockRangeRespMsg_init(FLockRangeRespMsg* this);
|
||||
|
||||
struct FLockRangeRespMsg
|
||||
{
|
||||
SimpleIntMsg simpleIntMsg;
|
||||
};
|
||||
|
||||
|
||||
void FLockRangeRespMsg_init(FLockRangeRespMsg* this)
|
||||
{
|
||||
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_FLockRangeResp);
|
||||
}
|
||||
|
||||
#endif /* FLOCKRANGERESPMSG_H_ */
|
||||
@@ -0,0 +1,79 @@
|
||||
#include <app/App.h>
|
||||
#include <components/AckManager.h>
|
||||
#include <common/toolkit/ackstore/AcknowledgmentStore.h>
|
||||
#include <common/toolkit/SocketTk.h>
|
||||
#include <common/net/msghelpers/MsgHelperAck.h>
|
||||
#include "LockGrantedMsgEx.h"
|
||||
|
||||
const struct NetMessageOps LockGrantedMsgEx_Ops = {
|
||||
.serializePayload = _NetMessage_serializeDummy,
|
||||
.deserializePayload = LockGrantedMsgEx_deserializePayload,
|
||||
.processIncoming = __LockGrantedMsgEx_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
bool LockGrantedMsgEx_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
LockGrantedMsgEx* thisCast = (LockGrantedMsgEx*)this;
|
||||
|
||||
// lockAckID
|
||||
if(!Serialization_deserializeStrAlign4(ctx,
|
||||
&thisCast->lockAckIDLen, &thisCast->lockAckID) )
|
||||
return false;
|
||||
|
||||
// ackID
|
||||
if(!Serialization_deserializeStrAlign4(ctx, &thisCast->ackIDLen, &thisCast->ackID) )
|
||||
return false;
|
||||
|
||||
// granterNodeID
|
||||
if(!NumNodeID_deserialize(ctx, &thisCast->granterNodeID) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __LockGrantedMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen)
|
||||
{
|
||||
const char* logContext = "LockGranted incoming";
|
||||
Logger* log = App_getLogger(app);
|
||||
AcknowledgmentStore* ackStore = App_getAckStore(app);
|
||||
AckManager* ackManager = App_getAckManager(app);
|
||||
|
||||
LockGrantedMsgEx* thisCast = (LockGrantedMsgEx*)this;
|
||||
bool gotLockWaiter;
|
||||
|
||||
#ifdef LOG_DEBUG_MESSAGES
|
||||
const char* peer;
|
||||
|
||||
peer = fromAddr ?
|
||||
SocketTk_ipaddrToStr(fromAddr->addr) : StringTk_strDup(Socket_getPeername(sock) );
|
||||
LOG_DEBUG_FORMATTED(log, Log_DEBUG, logContext, "Received a AckMsg from: %s", peer);
|
||||
|
||||
kfree(peer);
|
||||
#endif // LOG_DEBUG_MESSAGES
|
||||
|
||||
IGNORE_UNUSED_VARIABLE(log);
|
||||
IGNORE_UNUSED_VARIABLE(logContext);
|
||||
|
||||
gotLockWaiter = AcknowledgmentStore_receivedAck(
|
||||
ackStore, LockGrantedMsgEx_getLockAckID(thisCast) );
|
||||
|
||||
/* note: other than for standard acks, we send a ack repsonse to lock-grants only if someone was
|
||||
still registered to wait for the lock-grant. (we do this to make our handling of interrupts
|
||||
during lock waits easier, because we don't need lock canceling now.) */
|
||||
|
||||
if(gotLockWaiter)
|
||||
{ // lock waiter registered => send ack
|
||||
const char* ackID = LockGrantedMsgEx_getAckID(thisCast);
|
||||
NumNodeID granterNodeID = LockGrantedMsgEx_getGranterNodeID(thisCast);
|
||||
|
||||
MsgHelperAck_respondToAckRequest(app, LockGrantedMsgEx_getAckID(thisCast), fromAddr, sock,
|
||||
respBuf, bufLen);
|
||||
|
||||
AckManager_addAckToQueue(ackManager, granterNodeID, ackID);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef LOCKGRANTEDMSGEX_H_
|
||||
#define LOCKGRANTEDMSGEX_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
|
||||
|
||||
/**
|
||||
* This message is for deserialization (incoming) only, serialization is not implemented!
|
||||
*/
|
||||
|
||||
|
||||
struct LockGrantedMsgEx;
|
||||
typedef struct LockGrantedMsgEx LockGrantedMsgEx;
|
||||
|
||||
static inline void LockGrantedMsgEx_init(LockGrantedMsgEx* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool LockGrantedMsgEx_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
extern bool __LockGrantedMsgEx_processIncoming(NetMessage* this, struct App* app,
|
||||
fhgfs_sockaddr_in* fromAddr, struct Socket* sock, char* respBuf, size_t bufLen);
|
||||
|
||||
// getters & setters
|
||||
static inline const char* LockGrantedMsgEx_getLockAckID(LockGrantedMsgEx* this);
|
||||
static inline const char* LockGrantedMsgEx_getAckID(LockGrantedMsgEx* this);
|
||||
static inline NumNodeID LockGrantedMsgEx_getGranterNodeID(LockGrantedMsgEx* this);
|
||||
|
||||
|
||||
struct LockGrantedMsgEx
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
unsigned lockAckIDLen;
|
||||
const char* lockAckID;
|
||||
unsigned ackIDLen;
|
||||
const char* ackID;
|
||||
NumNodeID granterNodeID;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps LockGrantedMsgEx_Ops;
|
||||
|
||||
void LockGrantedMsgEx_init(LockGrantedMsgEx* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_LockGranted, &LockGrantedMsgEx_Ops);
|
||||
}
|
||||
|
||||
const char* LockGrantedMsgEx_getLockAckID(LockGrantedMsgEx* this)
|
||||
{
|
||||
return this->lockAckID;
|
||||
}
|
||||
|
||||
const char* LockGrantedMsgEx_getAckID(LockGrantedMsgEx* this)
|
||||
{
|
||||
return this->ackID;
|
||||
}
|
||||
|
||||
NumNodeID LockGrantedMsgEx_getGranterNodeID(LockGrantedMsgEx* this)
|
||||
{
|
||||
return this->granterNodeID;
|
||||
}
|
||||
|
||||
|
||||
#endif /* LOCKGRANTEDMSGEX_H_ */
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "CloseFileMsg.h"
|
||||
|
||||
|
||||
const struct NetMessageOps CloseFileMsg_Ops = {
|
||||
.serializePayload = CloseFileMsg_serializePayload,
|
||||
.deserializePayload = _NetMessage_deserializeDummy,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
.supportsSequenceNumbers = true,
|
||||
};
|
||||
|
||||
void CloseFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
CloseFileMsg* thisCast = (CloseFileMsg*)this;
|
||||
|
||||
// clientNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->clientNumID);
|
||||
|
||||
// fileHandleID
|
||||
Serialization_serializeStrAlign4(ctx, thisCast->fileHandleIDLen, thisCast->fileHandleID);
|
||||
|
||||
// entryInfo
|
||||
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
|
||||
|
||||
// maxUsedNodeIndex
|
||||
Serialization_serializeInt(ctx, thisCast->maxUsedNodeIndex);
|
||||
|
||||
if (this->msgHeader.msgFeatureFlags & CLOSEFILEMSG_FLAG_HAS_EVENT)
|
||||
FileEvent_serialize(ctx, thisCast->fileEvent);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
#ifndef CLOSEFILEMSG_H_
|
||||
#define CLOSEFILEMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/storage/EntryInfo.h>
|
||||
#include <common/storage/FileEvent.h>
|
||||
|
||||
|
||||
#define CLOSEFILEMSG_FLAG_EARLYRESPONSE 1 /* send response before chunk files close */
|
||||
#define CLOSEFILEMSG_FLAG_CANCELAPPENDLOCKS 2 /* cancel append locks of this file handle */
|
||||
#define CLOSEFILEMSG_FLAG_HAS_EVENT 8 /* contains file event logging information */
|
||||
|
||||
/**
|
||||
* This message supports sending (serialization) only, i.e. no deserialization implemented!!
|
||||
*/
|
||||
|
||||
struct CloseFileMsg;
|
||||
typedef struct CloseFileMsg CloseFileMsg;
|
||||
|
||||
static inline void CloseFileMsg_init(CloseFileMsg* this);
|
||||
static inline void CloseFileMsg_initFromSession(CloseFileMsg* this, NumNodeID clientNumID,
|
||||
const char* fileHandleID, const EntryInfo* entryInfo, int maxUsedNodeIndex,
|
||||
const struct FileEvent* fileEvent);
|
||||
|
||||
// virtual functions
|
||||
extern void CloseFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
|
||||
|
||||
struct CloseFileMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
NumNodeID clientNumID;
|
||||
|
||||
unsigned fileHandleIDLen;
|
||||
const char* fileHandleID;
|
||||
int maxUsedNodeIndex;
|
||||
|
||||
// for serialization
|
||||
const EntryInfo* entryInfoPtr; // not owned by this object
|
||||
const struct FileEvent* fileEvent;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps CloseFileMsg_Ops;
|
||||
|
||||
void CloseFileMsg_init(CloseFileMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_CloseFile, &CloseFileMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileHandleID just a reference, so do not free it as long as you use this object!
|
||||
* @param entryInfo just a reference, so do not free it as long as you use this object!
|
||||
*/
|
||||
void CloseFileMsg_initFromSession(CloseFileMsg* this, NumNodeID clientNumID,
|
||||
const char* fileHandleID, const EntryInfo* entryInfo, int maxUsedNodeIndex,
|
||||
const struct FileEvent* fileEvent)
|
||||
{
|
||||
CloseFileMsg_init(this);
|
||||
|
||||
this->clientNumID = clientNumID;
|
||||
|
||||
this->fileHandleID = fileHandleID;
|
||||
this->fileHandleIDLen = strlen(fileHandleID);
|
||||
|
||||
this->entryInfoPtr = entryInfo;
|
||||
|
||||
this->maxUsedNodeIndex = maxUsedNodeIndex;
|
||||
this->fileEvent = fileEvent;
|
||||
|
||||
if (fileEvent)
|
||||
this->netMessage.msgHeader.msgFeatureFlags |= CLOSEFILEMSG_FLAG_HAS_EVENT;
|
||||
}
|
||||
|
||||
#endif /*CLOSEFILEMSG_H_*/
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef CLOSEFILERESPMSG_H_
|
||||
#define CLOSEFILERESPMSG_H_
|
||||
|
||||
#include <common/net/message/SimpleIntMsg.h>
|
||||
|
||||
|
||||
struct CloseFileRespMsg;
|
||||
typedef struct CloseFileRespMsg CloseFileRespMsg;
|
||||
|
||||
static inline void CloseFileRespMsg_init(CloseFileRespMsg* this);
|
||||
|
||||
// getters & setters
|
||||
static inline int CloseFileRespMsg_getValue(CloseFileRespMsg* this);
|
||||
|
||||
struct CloseFileRespMsg
|
||||
{
|
||||
SimpleIntMsg simpleIntMsg;
|
||||
};
|
||||
|
||||
|
||||
void CloseFileRespMsg_init(CloseFileRespMsg* this)
|
||||
{
|
||||
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_CloseFileResp);
|
||||
}
|
||||
|
||||
int CloseFileRespMsg_getValue(CloseFileRespMsg* this)
|
||||
{
|
||||
return SimpleIntMsg_getValue( (SimpleIntMsg*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /*CLOSEFILERESPMSG_H_*/
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "OpenFileMsg.h"
|
||||
|
||||
|
||||
const struct NetMessageOps OpenFileMsg_Ops = {
|
||||
.serializePayload = OpenFileMsg_serializePayload,
|
||||
.deserializePayload = _NetMessage_deserializeDummy,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
.supportsSequenceNumbers = true,
|
||||
};
|
||||
|
||||
void OpenFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
OpenFileMsg* thisCast = (OpenFileMsg*)this;
|
||||
|
||||
// clientNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->clientNumID);
|
||||
|
||||
// accessFlags
|
||||
Serialization_serializeUInt(ctx, thisCast->accessFlags);
|
||||
|
||||
// entryInfo
|
||||
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
|
||||
|
||||
if (this->msgHeader.msgFeatureFlags & OPENFILEMSG_FLAG_HAS_EVENT)
|
||||
FileEvent_serialize(ctx, thisCast->fileEvent);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
#ifndef OPENFILEMSG_H_
|
||||
#define OPENFILEMSG_H_
|
||||
|
||||
#include <common/storage/EntryInfo.h>
|
||||
#include <common/storage/FileEvent.h>
|
||||
#include <common/net/message/NetMessage.h>
|
||||
|
||||
|
||||
#define OPENFILEMSG_FLAG_USE_QUOTA 1 /* if the message contains quota informations */
|
||||
#define OPENFILEMSG_FLAG_HAS_EVENT 2 /* contains file event logging information */
|
||||
#define OPENFILEMSG_FLAG_BYPASS_ACCESS_CHECK 4 /* bypass file access checks on metadata server */
|
||||
|
||||
struct OpenFileMsg;
|
||||
typedef struct OpenFileMsg OpenFileMsg;
|
||||
|
||||
static inline void OpenFileMsg_init(OpenFileMsg* this);
|
||||
static inline void OpenFileMsg_initFromSession(OpenFileMsg* this,
|
||||
NumNodeID clientNumID, const EntryInfo* entryInfo, unsigned accessFlags,
|
||||
const struct FileEvent* fileEvent);
|
||||
|
||||
// virtual functions
|
||||
extern void OpenFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
|
||||
|
||||
struct OpenFileMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
NumNodeID clientNumID;
|
||||
unsigned sessionIDLen;
|
||||
const EntryInfo* entryInfoPtr; // not owned by this object
|
||||
unsigned accessFlags;
|
||||
const struct FileEvent* fileEvent;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps OpenFileMsg_Ops;
|
||||
|
||||
void OpenFileMsg_init(OpenFileMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_OpenFile, &OpenFileMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sessionID just a reference, so do not free it as long as you use this object!
|
||||
* @param entryInfoPtr just a reference, so do not free it as long as you use this object!
|
||||
* @param accessFlags OPENFILE_ACCESS_... flags
|
||||
*/
|
||||
void OpenFileMsg_initFromSession(OpenFileMsg* this,
|
||||
NumNodeID clientNumID, const EntryInfo* entryInfo, unsigned accessFlags,
|
||||
const struct FileEvent* fileEvent)
|
||||
{
|
||||
OpenFileMsg_init(this);
|
||||
|
||||
this->clientNumID = clientNumID;
|
||||
|
||||
this->entryInfoPtr = entryInfo;
|
||||
|
||||
this->accessFlags = accessFlags;
|
||||
this->fileEvent = fileEvent;
|
||||
|
||||
if (fileEvent)
|
||||
this->netMessage.msgHeader.msgFeatureFlags |= OPENFILEMSG_FLAG_HAS_EVENT;
|
||||
}
|
||||
|
||||
#endif /*OPENFILEMSG_H_*/
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "OpenFileRespMsg.h"
|
||||
|
||||
|
||||
const struct NetMessageOps OpenFileRespMsg_Ops = {
|
||||
.serializePayload = _NetMessage_serializeDummy,
|
||||
.deserializePayload = OpenFileRespMsg_deserializePayload,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
bool OpenFileRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
|
||||
{
|
||||
OpenFileRespMsg* thisCast = (OpenFileRespMsg*)this;
|
||||
|
||||
// result
|
||||
if(!Serialization_deserializeInt(ctx, &thisCast->result) )
|
||||
return false;
|
||||
|
||||
// fileHandleID
|
||||
if(!Serialization_deserializeStrAlign4(ctx, &thisCast->fileHandleIDLen,
|
||||
&thisCast->fileHandleID) )
|
||||
return false;
|
||||
|
||||
// pathInfo
|
||||
if (!PathInfo_deserialize(ctx, &thisCast->pathInfo) )
|
||||
return false;
|
||||
|
||||
// stripePattern
|
||||
if(!StripePattern_deserializePatternPreprocess(ctx,
|
||||
&thisCast->patternStart, &thisCast->patternLength) )
|
||||
return false;
|
||||
|
||||
if (!Serialization_deserializeUInt(ctx, &thisCast->fileVersion))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
#ifndef OPENFILERESPMSG_H_
|
||||
#define OPENFILERESPMSG_H_
|
||||
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/storage/PathInfo.h>
|
||||
#include <common/storage/striping/StripePattern.h>
|
||||
#include <common/Common.h>
|
||||
|
||||
|
||||
struct OpenFileRespMsg;
|
||||
typedef struct OpenFileRespMsg OpenFileRespMsg;
|
||||
|
||||
static inline void OpenFileRespMsg_init(OpenFileRespMsg* this);
|
||||
|
||||
// virtual functions
|
||||
extern bool OpenFileRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
|
||||
|
||||
// inliners
|
||||
static inline StripePattern* OpenFileRespMsg_createPattern(OpenFileRespMsg* this);
|
||||
|
||||
// getters & setters
|
||||
static inline int OpenFileRespMsg_getResult(OpenFileRespMsg* this);
|
||||
static inline const char* OpenFileRespMsg_getFileHandleID(OpenFileRespMsg* this);
|
||||
static inline const PathInfo* OpenFileRespMsg_getPathInfo(OpenFileRespMsg* this);
|
||||
|
||||
struct OpenFileRespMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
int result;
|
||||
unsigned fileHandleIDLen;
|
||||
const char* fileHandleID;
|
||||
|
||||
PathInfo pathInfo;
|
||||
|
||||
uint32_t fileVersion;
|
||||
|
||||
// for serialization
|
||||
StripePattern* pattern; // not owned by this object!
|
||||
|
||||
// for deserialization
|
||||
const char* patternStart;
|
||||
uint32_t patternLength;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps OpenFileRespMsg_Ops;
|
||||
|
||||
void OpenFileRespMsg_init(OpenFileRespMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_OpenFileResp, &OpenFileRespMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return must be deleted by the caller; might be of type STRIPEPATTERN_Invalid
|
||||
*/
|
||||
StripePattern* OpenFileRespMsg_createPattern(OpenFileRespMsg* this)
|
||||
{
|
||||
return StripePattern_createFromBuf(this->patternStart, this->patternLength);
|
||||
}
|
||||
|
||||
int OpenFileRespMsg_getResult(OpenFileRespMsg* this)
|
||||
{
|
||||
return this->result;
|
||||
}
|
||||
|
||||
const char* OpenFileRespMsg_getFileHandleID(OpenFileRespMsg* this)
|
||||
{
|
||||
return this->fileHandleID;
|
||||
}
|
||||
|
||||
const PathInfo* OpenFileRespMsg_getPathInfo(OpenFileRespMsg* this)
|
||||
{
|
||||
return &this->pathInfo;
|
||||
}
|
||||
|
||||
#endif /*OPENFILERESPMSG_H_*/
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifdef BEEGFS_NVFS
|
||||
#include "ReadLocalFileRDMAMsg.h"
|
||||
|
||||
const struct NetMessageOps ReadLocalFileRDMAMsg_Ops = {
|
||||
.serializePayload = ReadLocalFileRDMAMsg_serializePayload,
|
||||
.deserializePayload = _NetMessage_deserializeDummy,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void ReadLocalFileRDMAMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
ReadLocalFileRDMAMsg* thisCast = (ReadLocalFileRDMAMsg*)this;
|
||||
|
||||
// offset
|
||||
Serialization_serializeInt64(ctx, thisCast->offset);
|
||||
|
||||
// count
|
||||
Serialization_serializeInt64(ctx, thisCast->count);
|
||||
|
||||
// accessFlags
|
||||
Serialization_serializeUInt(ctx, thisCast->accessFlags);
|
||||
|
||||
// fileHandleID
|
||||
Serialization_serializeStrAlign4(ctx, thisCast->fileHandleIDLen, thisCast->fileHandleID);
|
||||
|
||||
// clientNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->clientNumID);
|
||||
|
||||
// pathInfo
|
||||
PathInfo_serialize(ctx, thisCast->pathInfoPtr);
|
||||
|
||||
// targetID
|
||||
Serialization_serializeUShort(ctx, thisCast->targetID);
|
||||
|
||||
// RDMA info
|
||||
RdmaInfo_serialize(ctx, thisCast->rdmap);
|
||||
}
|
||||
#endif /* BEEGFS_NVFS */
|
||||
@@ -0,0 +1,71 @@
|
||||
#ifndef READLOCALFILERDMAMSG_H_
|
||||
#define READLOCALFILERDMAMSG_H_
|
||||
#ifdef BEEGFS_NVFS
|
||||
#include <common/net/message/NetMessage.h>
|
||||
#include <common/storage/PathInfo.h>
|
||||
#include <common/storage/RdmaInfo.h>
|
||||
#include "ReadLocalFileV2Msg.h"
|
||||
|
||||
|
||||
struct ReadLocalFileRDMAMsg;
|
||||
typedef struct ReadLocalFileRDMAMsg ReadLocalFileRDMAMsg;
|
||||
|
||||
static inline void ReadLocalFileRDMAMsg_init(ReadLocalFileRDMAMsg* this);
|
||||
static inline void ReadLocalFileRDMAMsg_initFromSession(ReadLocalFileRDMAMsg* this,
|
||||
NumNodeID clientNumID, const char* fileHandleID, uint16_t targetID, PathInfo* pathInfoPtr,
|
||||
unsigned accessFlags, int64_t offset, int64_t count, RdmaInfo *rdmap);
|
||||
|
||||
// virtual functions
|
||||
extern void ReadLocalFileRDMAMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
|
||||
|
||||
|
||||
struct ReadLocalFileRDMAMsg
|
||||
{
|
||||
NetMessage netMessage;
|
||||
|
||||
int64_t offset;
|
||||
int64_t count;
|
||||
unsigned accessFlags;
|
||||
NumNodeID clientNumID;
|
||||
const char* fileHandleID;
|
||||
unsigned fileHandleIDLen;
|
||||
PathInfo* pathInfoPtr;
|
||||
uint16_t targetID;
|
||||
RdmaInfo *rdmap;
|
||||
};
|
||||
|
||||
extern const struct NetMessageOps ReadLocalFileRDMAMsg_Ops;
|
||||
|
||||
void ReadLocalFileRDMAMsg_init(ReadLocalFileRDMAMsg* this)
|
||||
{
|
||||
NetMessage_init(&this->netMessage, NETMSGTYPE_ReadLocalFileRDMA, &ReadLocalFileRDMAMsg_Ops);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sessionID just a reference, so do not free it as long as you use this object!
|
||||
*/
|
||||
void ReadLocalFileRDMAMsg_initFromSession(ReadLocalFileRDMAMsg* this,
|
||||
NumNodeID clientNumID, const char* fileHandleID, uint16_t targetID, PathInfo* pathInfoPtr,
|
||||
unsigned accessFlags, int64_t offset, int64_t count, RdmaInfo *rdmap)
|
||||
{
|
||||
ReadLocalFileRDMAMsg_init(this);
|
||||
|
||||
this->clientNumID = clientNumID;
|
||||
|
||||
this->fileHandleID = fileHandleID;
|
||||
this->fileHandleIDLen = strlen(fileHandleID);
|
||||
|
||||
this->targetID = targetID;
|
||||
|
||||
this->pathInfoPtr = pathInfoPtr;
|
||||
|
||||
this->accessFlags = accessFlags;
|
||||
|
||||
this->offset = offset;
|
||||
this->count = count;
|
||||
|
||||
this->rdmap = rdmap;
|
||||
}
|
||||
|
||||
#endif /* BEEGFS_NVFS */
|
||||
#endif /*READLOCALFILERDMAMSG_H_*/
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "ReadLocalFileV2Msg.h"
|
||||
|
||||
|
||||
const struct NetMessageOps ReadLocalFileV2Msg_Ops = {
|
||||
.serializePayload = ReadLocalFileV2Msg_serializePayload,
|
||||
.deserializePayload = _NetMessage_deserializeDummy,
|
||||
.processIncoming = NetMessage_processIncoming,
|
||||
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
|
||||
};
|
||||
|
||||
void ReadLocalFileV2Msg_serializePayload(NetMessage* this, SerializeCtx* ctx)
|
||||
{
|
||||
ReadLocalFileV2Msg* thisCast = (ReadLocalFileV2Msg*)this;
|
||||
|
||||
// offset
|
||||
Serialization_serializeInt64(ctx, thisCast->offset);
|
||||
|
||||
// count
|
||||
Serialization_serializeInt64(ctx, thisCast->count);
|
||||
|
||||
// accessFlags
|
||||
Serialization_serializeUInt(ctx, thisCast->accessFlags);
|
||||
|
||||
// fileHandleID
|
||||
Serialization_serializeStrAlign4(ctx, thisCast->fileHandleIDLen, thisCast->fileHandleID);
|
||||
|
||||
// clientNumID
|
||||
NumNodeID_serialize(ctx, &thisCast->clientNumID);
|
||||
|
||||
// pathInfo
|
||||
PathInfo_serialize(ctx, thisCast->pathInfoPtr);
|
||||
|
||||
// targetID
|
||||
Serialization_serializeUShort(ctx, thisCast->targetID);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user