New upstream version 8.1.0

This commit is contained in:
geos_one
2025-08-10 01:34:16 +02:00
commit c891bb7105
4398 changed files with 838833 additions and 0 deletions

View 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_*/

View 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_ */

View 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)

View 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

View 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();
}

View 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_*/

View 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_*/

View 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);
}

View 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_*/

View 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);
}

View 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_*/

View 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;
}

View 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_ */

View 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;
}

View 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_*/

View 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);
}

View 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_ */

View 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);
}

View 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_ */

View 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_ */

View File

@@ -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_ */

View File

@@ -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_ */

View File

@@ -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,
};

View File

@@ -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

View File

@@ -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_*/

View File

@@ -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;
}

View File

@@ -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_*/

View File

@@ -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;
}

View File

@@ -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_*/

View 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;
}

View 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_*/

View 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_*/

View File

@@ -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 */

View 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_ */

View File

@@ -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;
}

View File

@@ -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_ */

View File

@@ -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,
};

View File

@@ -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_ */

View File

@@ -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;
}

View File

@@ -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_ */

View File

@@ -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_ */

View File

@@ -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,
};

View File

@@ -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_ */

View 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 );
}
}

View 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_*/

View File

@@ -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;
}

View File

@@ -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_ */

View File

@@ -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;
}

View File

@@ -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_ */

View File

@@ -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;
}

View File

@@ -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_ */

View File

@@ -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);
}

View File

@@ -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*/

View File

@@ -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;
}

View File

@@ -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*/

View 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;
}

View File

@@ -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_ */

View File

@@ -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_ */

View File

@@ -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;
}

View File

@@ -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_ */

View File

@@ -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,
};

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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_*/

View File

@@ -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_*/

View File

@@ -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,
};

View File

@@ -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

View File

@@ -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,
};

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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_ */

View File

@@ -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_ */

View File

@@ -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);
}

View File

@@ -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_ */

View File

@@ -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_ */

View File

@@ -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);
}

View File

@@ -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_ */

View File

@@ -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_ */

View File

@@ -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;
}

View File

@@ -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_ */

View File

@@ -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);
}

View File

@@ -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_*/

View File

@@ -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_*/

View File

@@ -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);
}

View File

@@ -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_*/

View File

@@ -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;
}

View File

@@ -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_*/

View File

@@ -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 */

View File

@@ -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_*/

View File

@@ -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);
}

View File

@@ -0,0 +1,71 @@
#ifndef READLOCALFILEV2MSG_H_
#define READLOCALFILEV2MSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/PathInfo.h>
#define READLOCALFILEMSG_FLAG_SESSION_CHECK 1 /* if session check infos should be done */
#define READLOCALFILEMSG_FLAG_DISABLE_IO 2 /* disable read syscall for net bench */
#define READLOCALFILEMSG_FLAG_BUDDYMIRROR 4 /* given targetID is a buddymirrorgroup ID */
#define READLOCALFILEMSG_FLAG_BUDDYMIRROR_SECOND 8 /* secondary of group, otherwise primary */
struct ReadLocalFileV2Msg;
typedef struct ReadLocalFileV2Msg ReadLocalFileV2Msg;
static inline void ReadLocalFileV2Msg_init(ReadLocalFileV2Msg* this);
static inline void ReadLocalFileV2Msg_initFromSession(ReadLocalFileV2Msg* this,
NumNodeID clientNumID, const char* fileHandleID, uint16_t targetID, PathInfo* pathInfoPtr,
unsigned accessFlags, int64_t offset, int64_t count);
// virtual functions
extern void ReadLocalFileV2Msg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct ReadLocalFileV2Msg
{
NetMessage netMessage;
int64_t offset;
int64_t count;
unsigned accessFlags;
NumNodeID clientNumID;
const char* fileHandleID;
unsigned fileHandleIDLen;
PathInfo* pathInfoPtr;
uint16_t targetID;
};
extern const struct NetMessageOps ReadLocalFileV2Msg_Ops;
void ReadLocalFileV2Msg_init(ReadLocalFileV2Msg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_ReadLocalFileV2, &ReadLocalFileV2Msg_Ops);
}
/**
* @param sessionID just a reference, so do not free it as long as you use this object!
*/
void ReadLocalFileV2Msg_initFromSession(ReadLocalFileV2Msg* this,
NumNodeID clientNumID, const char* fileHandleID, uint16_t targetID, PathInfo* pathInfoPtr,
unsigned accessFlags, int64_t offset, int64_t count)
{
ReadLocalFileV2Msg_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;
}
#endif /*READLOCALFILEV2MSG_H_*/

View File

@@ -0,0 +1,44 @@
#include "WriteLocalFileMsg.h"
const struct NetMessageOps WriteLocalFileMsg_Ops = {
.serializePayload = WriteLocalFileMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
void WriteLocalFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
WriteLocalFileMsg* thisCast = (WriteLocalFileMsg*)this;
// offset
Serialization_serializeInt64(ctx, thisCast->offset);
// count
Serialization_serializeInt64(ctx, thisCast->count);
// accessFlags
Serialization_serializeUInt(ctx, thisCast->accessFlags);
if(NetMessage_isMsgHeaderFeatureFlagSet(this, WRITELOCALFILEMSG_FLAG_USE_QUOTA))
{
// userID
Serialization_serializeUInt(ctx, thisCast->userID);
// groupID
Serialization_serializeUInt(ctx, thisCast->groupID);
}
// fileHandleID
Serialization_serializeStrAlign4(ctx, thisCast->fileHandleIDLen, thisCast->fileHandleID);
// clientNumID
NumNodeID_serialize(ctx, &thisCast->clientNumID);
// pathInfo
PathInfo_serialize(ctx, thisCast->pathInfo);
// targetID
Serialization_serializeUShort(ctx, thisCast->targetID);
}

View File

@@ -0,0 +1,99 @@
#ifndef WRITELOCALFILEMSG_H_
#define WRITELOCALFILEMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/StorageErrors.h>
#include <common/storage/PathInfo.h>
#include <app/log/Logger.h>
#include <app/App.h>
#include <os/iov_iter.h>
#define WRITELOCALFILEMSG_FLAG_SESSION_CHECK 1 /* if session check should be done */
#define WRITELOCALFILEMSG_FLAG_USE_QUOTA 2 /* if msg contains quota info */
#define WRITELOCALFILEMSG_FLAG_DISABLE_IO 4 /* disable write syscall for net bench mode */
#define WRITELOCALFILEMSG_FLAG_BUDDYMIRROR 8 /* given targetID is a buddymirrorgroup ID */
#define WRITELOCALFILEMSG_FLAG_BUDDYMIRROR_SECOND 16 /* secondary of group, otherwise primary */
#define WRITELOCALFILEMSG_FLAG_BUDDYMIRROR_FORWARD 32 /* forward msg to secondary */
struct WriteLocalFileMsg;
typedef struct WriteLocalFileMsg WriteLocalFileMsg;
static inline void WriteLocalFileMsg_init(WriteLocalFileMsg* this);
static inline void WriteLocalFileMsg_initFromSession(WriteLocalFileMsg* this,
NumNodeID clientNumID, const char* fileHandleID, uint16_t targetID, PathInfo* pathInfo,
unsigned accessFlags, int64_t offset, int64_t count);
// virtual functions
extern void WriteLocalFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
// getters & setters
static inline void WriteLocalFileMsg_setUserdataForQuota(WriteLocalFileMsg* this, unsigned userID,
unsigned groupID);
/**
* Note: This message supports only serialization, deserialization is not implemented.
*/
struct WriteLocalFileMsg
{
NetMessage netMessage;
int64_t offset;
int64_t count;
unsigned accessFlags;
NumNodeID clientNumID;
const char* fileHandleID;
unsigned fileHandleIDLen;
uint16_t targetID;
PathInfo* pathInfo;
unsigned userID;
unsigned groupID;
};
extern const struct NetMessageOps WriteLocalFileMsg_Ops;
void WriteLocalFileMsg_init(WriteLocalFileMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_WriteLocalFile, &WriteLocalFileMsg_Ops);
}
/**
* @param fileHandleID just a reference, so do not free it as long as you use this object!
* @param pathInfo just a reference, so do not free it as long as you use this object!
*/
void WriteLocalFileMsg_initFromSession(WriteLocalFileMsg* this,
NumNodeID clientNumID, const char* fileHandleID, uint16_t targetID, PathInfo* pathInfo,
unsigned accessFlags,
int64_t offset, int64_t count)
{
WriteLocalFileMsg_init(this);
this->clientNumID = clientNumID;
this->fileHandleID = fileHandleID;
this->fileHandleIDLen = strlen(fileHandleID);
this->targetID = targetID;
this->pathInfo = pathInfo;
this->accessFlags = accessFlags;
this->offset = offset;
this->count = count;
}
void WriteLocalFileMsg_setUserdataForQuota(WriteLocalFileMsg* this, unsigned userID,
unsigned groupID)
{
NetMessage* thisCast = (NetMessage*) this;
NetMessage_addMsgHeaderFeatureFlag(thisCast, WRITELOCALFILEMSG_FLAG_USE_QUOTA);
this->userID = userID;
this->groupID = groupID;
}
#endif /*WRITELOCALFILEMSG_H_*/

View File

@@ -0,0 +1,49 @@
#ifdef BEEGFS_NVFS
#include "WriteLocalFileRDMAMsg.h"
#include "WriteLocalFileMsg.h"
const struct NetMessageOps WriteLocalFileRDMAMsg_Ops = {
.serializePayload = WriteLocalFileRDMAMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
void WriteLocalFileRDMAMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
WriteLocalFileRDMAMsg* thisCast = (WriteLocalFileRDMAMsg*)this;
// offset
Serialization_serializeInt64(ctx, thisCast->offset);
// count
Serialization_serializeInt64(ctx, thisCast->count);
// accessFlags
Serialization_serializeUInt(ctx, thisCast->accessFlags);
if(NetMessage_isMsgHeaderFeatureFlagSet(this, WRITELOCALFILEMSG_FLAG_USE_QUOTA))
{
// userID
Serialization_serializeUInt(ctx, thisCast->userID);
// groupID
Serialization_serializeUInt(ctx, thisCast->groupID);
}
// fileHandleID
Serialization_serializeStrAlign4(ctx, thisCast->fileHandleIDLen, thisCast->fileHandleID);
// clientNumID
NumNodeID_serialize(ctx, &thisCast->clientNumID);
// pathInfo
PathInfo_serialize(ctx, thisCast->pathInfo);
// targetID
Serialization_serializeUShort(ctx, thisCast->targetID);
// RDMA info
RdmaInfo_serialize(ctx, thisCast->rdmap);
}
#endif /* BEEGFS_NVFS */

View File

@@ -0,0 +1,104 @@
#ifndef WRITELOCALFILERDMAMSG_H_
#define WRITELOCALFILERDMAMSG_H_
#ifdef BEEGFS_NVFS
#include <common/net/message/NetMessage.h>
#include <common/storage/StorageErrors.h>
#include <common/storage/PathInfo.h>
#include <common/storage/RdmaInfo.h>
#include <app/log/Logger.h>
#include <app/App.h>
#include <os/iov_iter.h>
#define WRITELOCALFILERDMAMSG_FLAG_SESSION_CHECK 1 /* if session check should be done */
#define WRITELOCALFILERDMAMSG_FLAG_USE_QUOTA 2 /* if msg contains quota info */
#define WRITELOCALFILERDMAMSG_FLAG_DISABLE_IO 4 /* disable write syscall for net bench mode */
#define WRITELOCALFILERDMAMSG_FLAG_BUDDYMIRROR 8 /* given targetID is a buddymirrorgroup ID */
#define WRITELOCALFILERDMAMSG_FLAG_BUDDYMIRROR_SECOND 16 /* secondary of group, otherwise primary */
#define WRITELOCALFILERDMAMSG_FLAG_BUDDYMIRROR_FORWARD 32 /* forward msg to secondary */
struct WriteLocalFileRDMAMsg;
typedef struct WriteLocalFileRDMAMsg WriteLocalFileRDMAMsg;
static inline void WriteLocalFileRDMAMsg_init(WriteLocalFileRDMAMsg* this);
static inline void WriteLocalFileRDMAMsg_initFromSession(WriteLocalFileRDMAMsg* this,
NumNodeID clientNumID, const char* fileHandleID, uint16_t targetID, PathInfo* pathInfo,
unsigned accessFlags, int64_t offset, int64_t count, RdmaInfo *rdmap);
// virtual functions
extern void WriteLocalFileRDMAMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
// getters & setters
static inline void WriteLocalFileRDMAMsg_setUserdataForQuota(WriteLocalFileRDMAMsg* this, unsigned userID,
unsigned groupID);
/**
* Note: This message supports only serialization, deserialization is not implemented.
*/
struct WriteLocalFileRDMAMsg
{
NetMessage netMessage;
int64_t offset;
int64_t count;
unsigned accessFlags;
NumNodeID clientNumID;
const char* fileHandleID;
unsigned fileHandleIDLen;
uint16_t targetID;
PathInfo* pathInfo;
unsigned userID;
unsigned groupID;
RdmaInfo *rdmap;
};
extern const struct NetMessageOps WriteLocalFileRDMAMsg_Ops;
void WriteLocalFileRDMAMsg_init(WriteLocalFileRDMAMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_WriteLocalFileRDMA, &WriteLocalFileRDMAMsg_Ops);
}
/**
* @param fileHandleID just a reference, so do not free it as long as you use this object!
* @param pathInfo just a reference, so do not free it as long as you use this object!
*/
void WriteLocalFileRDMAMsg_initFromSession(WriteLocalFileRDMAMsg* this,
NumNodeID clientNumID, const char* fileHandleID, uint16_t targetID, PathInfo* pathInfo,
unsigned accessFlags, int64_t offset, int64_t count, RdmaInfo *rdmap)
{
WriteLocalFileRDMAMsg_init(this);
this->clientNumID = clientNumID;
this->fileHandleID = fileHandleID;
this->fileHandleIDLen = strlen(fileHandleID);
this->targetID = targetID;
this->pathInfo = pathInfo;
this->accessFlags = accessFlags;
this->offset = offset;
this->count = count;
this->rdmap = rdmap;
}
void WriteLocalFileRDMAMsg_setUserdataForQuota(WriteLocalFileRDMAMsg* this, unsigned userID,
unsigned groupID)
{
NetMessage* thisCast = (NetMessage*) this;
NetMessage_addMsgHeaderFeatureFlag(thisCast, WRITELOCALFILERDMAMSG_FLAG_USE_QUOTA);
this->userID = userID;
this->groupID = groupID;
}
#endif /* BEEGFS_NVFS */
#endif /*WRITELOCALFILERDMAMSG_H_*/

View File

@@ -0,0 +1,34 @@
#ifndef WRITELOCALFILERDMARESPMSG_H_
#define WRITELOCALFILERDMARESPMSG_H_
#ifdef BEEGFS_NVFS
#include <common/net/message/SimpleInt64Msg.h>
struct WriteLocalFileRDMARespMsg;
typedef struct WriteLocalFileRDMARespMsg WriteLocalFileRDMARespMsg;
static inline void WriteLocalFileRDMARespMsg_init(WriteLocalFileRDMARespMsg* this);
// getters & setters
static inline int64_t WriteLocalFileRDMARespMsg_getValue(WriteLocalFileRDMARespMsg* this);
struct WriteLocalFileRDMARespMsg
{
SimpleInt64Msg simpleInt64Msg;
};
void WriteLocalFileRDMARespMsg_init(WriteLocalFileRDMARespMsg* this)
{
SimpleInt64Msg_init( (SimpleInt64Msg*)this, NETMSGTYPE_WriteLocalFileRDMAResp);
}
int64_t WriteLocalFileRDMARespMsg_getValue(WriteLocalFileRDMARespMsg* this)
{
return SimpleInt64Msg_getValue( (SimpleInt64Msg*)this);
}
#endif /* BEEGFS_NVFS */
#endif /*WRITELOCALFILERDMARESPMSG_H_*/

View File

@@ -0,0 +1,32 @@
#ifndef WRITELOCALFILERESPMSG_H_
#define WRITELOCALFILERESPMSG_H_
#include <common/net/message/SimpleInt64Msg.h>
struct WriteLocalFileRespMsg;
typedef struct WriteLocalFileRespMsg WriteLocalFileRespMsg;
static inline void WriteLocalFileRespMsg_init(WriteLocalFileRespMsg* this);
// getters & setters
static inline int64_t WriteLocalFileRespMsg_getValue(WriteLocalFileRespMsg* this);
struct WriteLocalFileRespMsg
{
SimpleInt64Msg simpleInt64Msg;
};
void WriteLocalFileRespMsg_init(WriteLocalFileRespMsg* this)
{
SimpleInt64Msg_init( (SimpleInt64Msg*)this, NETMSGTYPE_WriteLocalFileResp);
}
int64_t WriteLocalFileRespMsg_getValue(WriteLocalFileRespMsg* this)
{
return SimpleInt64Msg_getValue( (SimpleInt64Msg*)this);
}
#endif /*WRITELOCALFILERESPMSG_H_*/

View File

@@ -0,0 +1,33 @@
#ifndef STATSTORAGEPATHMSG_H_
#define STATSTORAGEPATHMSG_H_
#include "../SimpleUInt16Msg.h"
struct StatStoragePathMsg;
typedef struct StatStoragePathMsg StatStoragePathMsg;
static inline void StatStoragePathMsg_init(StatStoragePathMsg* this);
static inline void StatStoragePathMsg_initFromTarget(StatStoragePathMsg* this,
uint16_t targetID);
struct StatStoragePathMsg
{
SimpleUInt16Msg simpleUInt16Msg;
};
void StatStoragePathMsg_init(StatStoragePathMsg* this)
{
SimpleUInt16Msg_init( (SimpleUInt16Msg*)this, NETMSGTYPE_StatStoragePath);
}
/**
* @param targetID only used for storage servers, ignored for other nodes (but may not be NULL!)
*/
void StatStoragePathMsg_initFromTarget(StatStoragePathMsg* this, uint16_t targetID)
{
SimpleUInt16Msg_initFromValue( (SimpleUInt16Msg*)this, NETMSGTYPE_StatStoragePath, targetID);
}
#endif /*STATSTORAGEPATHMSG_H_*/

View File

@@ -0,0 +1,36 @@
#include "StatStoragePathRespMsg.h"
const struct NetMessageOps StatStoragePathRespMsg_Ops = {
.serializePayload = _NetMessage_serializeDummy,
.deserializePayload = StatStoragePathRespMsg_deserializePayload,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
bool StatStoragePathRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
{
StatStoragePathRespMsg* thisCast = (StatStoragePathRespMsg*)this;
// result
if(!Serialization_deserializeInt(ctx, &thisCast->result) )
return false;
// sizeTotal
if(!Serialization_deserializeInt64(ctx, &thisCast->sizeTotal) )
return false;
// sizeFree
if(!Serialization_deserializeInt64(ctx, &thisCast->sizeFree) )
return false;
// inodesTotal
if(!Serialization_deserializeInt64(ctx, &thisCast->inodesTotal) )
return false;
// inodesFree
if(!Serialization_deserializeInt64(ctx, &thisCast->inodesFree) )
return false;
return true;
}

Some files were not shown because too many files have changed in this diff Show More