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,62 @@
#include "LookupIntentMsg.h"
const struct NetMessageOps LookupIntentMsg_Ops = {
.serializePayload = LookupIntentMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
.supportsSequenceNumbers = true,
};
void LookupIntentMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
LookupIntentMsg* thisCast = (LookupIntentMsg*)this;
// intentFlags
Serialization_serializeInt(ctx, thisCast->intentFlags);
// parentInfo
EntryInfo_serialize(ctx, thisCast->parentInfoPtr);
// entryName
Serialization_serializeStrAlign4(ctx, thisCast->entryNameLen, thisCast->entryName);
if (thisCast->intentFlags & LOOKUPINTENTMSG_FLAG_REVALIDATE)
{
//metadata version
Serialization_serializeUInt(ctx, thisCast->metaVersion);
// entryInfo
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
}
if(thisCast->intentFlags & LOOKUPINTENTMSG_FLAG_OPEN)
{
// accessFlags
Serialization_serializeUInt(ctx, thisCast->accessFlags);
// clientNumID
NumNodeID_serialize(ctx, &thisCast->clientNumID);
}
if(thisCast->intentFlags & LOOKUPINTENTMSG_FLAG_CREATE)
{
// userID
Serialization_serializeUInt(ctx, thisCast->userID);
// groupID
Serialization_serializeUInt(ctx, thisCast->groupID);
// mode
Serialization_serializeInt(ctx, thisCast->mode);
// umask
Serialization_serializeInt(ctx, thisCast->umask);
// preferredTargets
Serialization_serializeUInt16List(ctx, thisCast->preferredTargets);
if (this->msgHeader.msgFeatureFlags & LOOKUPINTENTMSG_FLAG_HAS_EVENT)
FileEvent_serialize(ctx, thisCast->fileEvent);
}
}

View File

@@ -0,0 +1,168 @@
#ifndef LOOKUPINTENTMSG_H_
#define LOOKUPINTENTMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/EntryInfo.h>
#include <common/storage/FileEvent.h>
/**
* This message supports only serialization; deserialization is not implemented!
*/
/* intentFlags as payload
Keep these flags in sync with the userspace msg flags:
fhgfs_common/source/common/net/message/storage/LookupIntentMsg.h */
#define LOOKUPINTENTMSG_FLAG_REVALIDATE 1 /* revalidate entry, cancel if invalid */
#define LOOKUPINTENTMSG_FLAG_CREATE 2 /* create file */
#define LOOKUPINTENTMSG_FLAG_CREATEEXCLUSIVE 4 /* exclusive file creation */
#define LOOKUPINTENTMSG_FLAG_OPEN 8 /* open file */
#define LOOKUPINTENTMSG_FLAG_STAT 16 /* stat file */
// feature flags as header flags
#define LOOKUPINTENTMSG_FLAG_USE_QUOTA 1 /* if the message contains quota information */
#define LOOKUPINTENTMSG_FLAG_BUDDYMIRROR 2
#define LOOKUPINTENTMSG_FLAG_BUDDYMIRROR_SECOND 4
#define LOOKUPINTENTMSG_FLAG_HAS_EVENT 8 /* contains file event logging information */
struct LookupIntentMsg;
typedef struct LookupIntentMsg LookupIntentMsg;
static inline void LookupIntentMsg_init(LookupIntentMsg* this);
static inline void LookupIntentMsg_initFromName(LookupIntentMsg* this, const EntryInfo* parentInfo,
const char* entryName);
static inline void LookupIntentMsg_initFromEntryInfo(LookupIntentMsg* this,
const EntryInfo* parentInfo, const char* entryName, const EntryInfo* entryInfo, uint32_t metaVersion);
// virtual functions
extern void LookupIntentMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
// inliners
static inline void LookupIntentMsg_addIntentCreate(LookupIntentMsg* this,
unsigned userID, unsigned groupID, int mode, int umask, UInt16List* preferredTargets,
const struct FileEvent* fileEvent);
static inline void LookupIntentMsg_addIntentCreateExclusive(LookupIntentMsg* this);
static inline void LookupIntentMsg_addIntentOpen(LookupIntentMsg* this, NumNodeID clientNumID,
unsigned accessFlags);
static inline void LookupIntentMsg_addIntentStat(LookupIntentMsg* this);
struct LookupIntentMsg
{
NetMessage netMessage;
int intentFlags; // combination of LOOKUPINTENTMSG_FLAG_...
const char* entryName; // (lookup data), set for all but revalidate
unsigned entryNameLen; // (lookup data), set for all but revalidate
const EntryInfo* entryInfoPtr; // (revalidation data)
unsigned userID; // (file creation data)
unsigned groupID; // (file creation data)
int mode; // file creation mode permission bits (file creation data)
int umask; // umask of the context (file creation data)
const struct FileEvent* fileEvent;
NumNodeID clientNumID; // (file open data)
unsigned accessFlags; // OPENFILE_ACCESS_... flags (file open data)
// for serialization
const EntryInfo* parentInfoPtr; // not owned by this object (lookup/open/creation data)
UInt16List* preferredTargets; // not owned by this object! (file creation data)
uint32_t metaVersion;
};
extern const struct NetMessageOps LookupIntentMsg_Ops;
void LookupIntentMsg_init(LookupIntentMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_LookupIntent, &LookupIntentMsg_Ops);
this->fileEvent = NULL;
}
/**
* This just prepares the basic lookup. Use the additional addIntent...() methods to do
* more than just the lookup.
*
* @param parentEntryID just a reference, so do not free it as long as you use this object!
* @param entryName just a reference, so do not free it as long as you use this object!
*/
void LookupIntentMsg_initFromName(LookupIntentMsg* this, const EntryInfo* parentInfo,
const char* entryName)
{
LookupIntentMsg_init(this);
this->intentFlags = 0;
this->parentInfoPtr = parentInfo;
this->entryName = entryName;
this->entryNameLen = strlen(entryName);
}
/**
* Initialize from entryInfo - supposed to be used for revalidate intent
*/
void LookupIntentMsg_initFromEntryInfo(LookupIntentMsg* this, const EntryInfo* parentInfo,
const char* entryName, const EntryInfo* entryInfo, uint32_t metaVersion)
{
LookupIntentMsg_init(this);
this->intentFlags = LOOKUPINTENTMSG_FLAG_REVALIDATE;
this->parentInfoPtr = parentInfo;
this->entryName = entryName;
this->entryNameLen = strlen(entryName);
this->entryInfoPtr = entryInfo;
this->metaVersion = metaVersion;
}
void LookupIntentMsg_addIntentCreate(LookupIntentMsg* this,
unsigned userID, unsigned groupID, int mode, int umask, UInt16List* preferredTargets,
const struct FileEvent* fileEvent)
{
this->intentFlags |= LOOKUPINTENTMSG_FLAG_CREATE;
this->userID = userID;
this->groupID = groupID;
this->mode = mode;
this->umask = umask;
this->preferredTargets = preferredTargets;
this->fileEvent = fileEvent;
if (fileEvent)
this->netMessage.msgHeader.msgFeatureFlags |= LOOKUPINTENTMSG_FLAG_HAS_EVENT;
}
void LookupIntentMsg_addIntentCreateExclusive(LookupIntentMsg* this)
{
this->intentFlags |= LOOKUPINTENTMSG_FLAG_CREATEEXCLUSIVE;
}
/**
* @param accessFlags OPENFILE_ACCESS_... flags
*/
void LookupIntentMsg_addIntentOpen(LookupIntentMsg* this, NumNodeID clientNumID,
unsigned accessFlags)
{
this->intentFlags |= LOOKUPINTENTMSG_FLAG_OPEN;
this->clientNumID = clientNumID;
this->accessFlags = accessFlags;
}
void LookupIntentMsg_addIntentStat(LookupIntentMsg* this)
{
this->intentFlags |= LOOKUPINTENTMSG_FLAG_STAT;
}
#endif /* LOOKUPINTENTMSG_H_ */

View File

@@ -0,0 +1,90 @@
#include "LookupIntentRespMsg.h"
const struct NetMessageOps LookupIntentRespMsg_Ops = {
.serializePayload = _NetMessage_serializeDummy,
.deserializePayload = LookupIntentRespMsg_deserializePayload,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
bool LookupIntentRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
{
LookupIntentRespMsg* thisCast = (LookupIntentRespMsg*)this;
// pre-initialize
thisCast->lookupResult = FhgfsOpsErr_INTERNAL;
thisCast->createResult = FhgfsOpsErr_INTERNAL;
// responseFlags
if(!Serialization_deserializeInt(ctx, &thisCast->responseFlags) )
return false;
// lookupResult
if(!Serialization_deserializeUInt(ctx, &thisCast->lookupResult) )
return false;
if(thisCast->responseFlags & LOOKUPINTENTRESPMSG_FLAG_STAT)
{
// statResult
if(!Serialization_deserializeInt(ctx, &thisCast->statResult) )
return false;
// StatData
if(!StatData_deserialize(ctx, &thisCast->statData) )
return false;
}
if(thisCast->responseFlags & LOOKUPINTENTRESPMSG_FLAG_REVALIDATE)
{
// revalidateResult
if(!Serialization_deserializeInt(ctx, &thisCast->revalidateResult) )
return false;
}
if(thisCast->responseFlags & LOOKUPINTENTRESPMSG_FLAG_CREATE)
{
// createResult
if(!Serialization_deserializeInt(ctx, &thisCast->createResult) )
return false;
}
if(thisCast->responseFlags & LOOKUPINTENTRESPMSG_FLAG_OPEN)
{
// openResult
if(!Serialization_deserializeInt(ctx, &thisCast->openResult) )
return false;
// fileHandleID
if(!Serialization_deserializeStrAlign4(ctx,
&thisCast->fileHandleIDLen, &thisCast->fileHandleID) )
return false;
// stripePattern
if(!StripePattern_deserializePatternPreprocess(ctx,
&thisCast->patternStart, &thisCast->patternLength) )
return false;
// PathInfo
if(!PathInfo_deserialize(ctx, &thisCast->pathInfo) )
return false;
}
// only try to decode the EntryInfo if either of those was successful
if ( (thisCast->lookupResult == FhgfsOpsErr_SUCCESS) ||
(thisCast->createResult == FhgfsOpsErr_SUCCESS) )
{ // entryInfo
if (unlikely(!EntryInfo_deserialize(ctx, &thisCast->entryInfo) ) )
{
printk_fhgfs(KERN_INFO,
"EntryInfo deserialization failed. LookupResult: %d; CreateResult %d\n",
thisCast->lookupResult, thisCast->createResult);
return false;
}
}
return true;
}

View File

@@ -0,0 +1,69 @@
#ifndef LOOKUPINTENTRESPMSG_H_
#define LOOKUPINTENTRESPMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/StorageErrors.h>
#include <common/storage/striping/StripePattern.h>
#include <common/storage/StatData.h>
#include <common/storage/StorageDefinitions.h>
#include <common/storage/PathInfo.h>
#include <common/storage/EntryInfo.h>
/**
* This message supports only deserialization; serialization is not implemented!
*/
/* Keep these flags in sync with the userspace msg flags:
fhgfs_common/source/common/net/message/storage/LookupIntentRespMsg.h */
#define LOOKUPINTENTRESPMSG_FLAG_REVALIDATE 1 /* revalidate entry, cancel if invalid */
#define LOOKUPINTENTRESPMSG_FLAG_CREATE 2 /* create file response */
#define LOOKUPINTENTRESPMSG_FLAG_OPEN 4 /* open file response */
#define LOOKUPINTENTRESPMSG_FLAG_STAT 8 /* stat file response */
struct LookupIntentRespMsg;
typedef struct LookupIntentRespMsg LookupIntentRespMsg;
static inline void LookupIntentRespMsg_init(LookupIntentRespMsg* this);
// virtual functions
extern bool LookupIntentRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
struct LookupIntentRespMsg
{
NetMessage netMessage;
int responseFlags; // combination of LOOKUPINTENTRESPMSG_FLAG_...
int lookupResult;
EntryInfo entryInfo; // only deserialized if either lookup or create was successful
int statResult;
StatData statData;
int revalidateResult; // FhgfsOpsErr_SUCCESS if still valid, any other value otherwise
int createResult; // FhgfsOpsErr_...
int openResult;
unsigned fileHandleIDLen;
const char* fileHandleID;
// for deserialization
const char* patternStart; // (open file data)
uint32_t patternLength; // (open file data)
PathInfo pathInfo;
};
extern const struct NetMessageOps LookupIntentRespMsg_Ops;
void LookupIntentRespMsg_init(LookupIntentRespMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_LookupIntentResp, &LookupIntentRespMsg_Ops);
}
#endif /* LOOKUPINTENTRESPMSG_H_ */