Commit 686383f5 authored by Christian Mohrbacher's avatar Christian Mohrbacher

updated to release 6.6

parent c3bde022
......@@ -55,6 +55,11 @@ KERNEL_FEATURE_DETECTION += $(shell \
${OFED_DETECTION_PATH}/rdma/ib_verbs.h \
&& echo "-DOFED_SPLIT_WR")
KERNEL_FEATURE_DETECTION += $(shell \
grep -qs -F "IB_PD_UNSAFE_GLOBAL_RKEY" \
${OFED_DETECTION_PATH}/rdma/ib_verbs.h \
&& echo "-DOFED_UNSAFE_GLOBAL_RKEY")
endif # BEEGFS_OPENTK_IBVERBS
# Find out whether the kernel has a scsi/fc_compat.h file, which defines
......@@ -247,6 +252,10 @@ $(call define_if_matches, KERNEL_HAS_IOV_DIO, \
-F "ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *iter);", fs.h)
$(call define_if_matches, KERNEL_HAS_XATTR_HANDLERS_INODE_ARG, \
-P "generic_getxattr.*struct inode", xattr.h)
KERNEL_FEATURE_DETECTION += $(shell \
grep -sPA1 "\(\*set\).const struct xattr_handler" $(KSRCDIR_PRUNED_HEAD)/include/linux/xattr.h \
| grep -qsP "^\s+struct inode" \
&& echo "-DKERNEL_HAS_XATTR_HANDLERS_INODE_ARG")
$(call define_if_matches, KERNEL_HAS_INODE_LOCK, "static inline void inode_lock", fs.h)
#<linuy-4.8
......@@ -358,3 +367,13 @@ $(call define_if_matches, KERNEL_HAS_COPY_FROM_ITER, "copy_from_iter", uio.h)
$(call define_if_matches, KERNEL_HAS_INIT_WORK_2, -F "INIT_WORK(_work, _func)", workqueue.h)
$(call define_if_matches, KERNEL_HAS_ALLOC_WORKQUEUE, "alloc_workqueue", workqueue.h)
$(call define_if_matches, KERNEL_HAS_WQ_RESCUER, "WQ_RESCUER", workqueue.h)
# inodeChangeRes was changed to setattr_prepare in vanilla 4.9
$(call define_if_matches, KERNEL_HAS_SETATTR_PREPARE, "int setattr_prepare", fs.h)
$(call define_if_matches, KERNEL_HAS_GENERIC_GETXATTR, "generic_getxattr", xattr.h)
KERNEL_FEATURE_DETECTION += $(shell \
grep -sA1 "(*rename) " $(KSRCDIR_PRUNED_HEAD)/include/linux/fs.h \
| grep -qsF "unsigned int" \
&& echo "-DKERNEL_HAS_RENAME_FLAGS")
......@@ -477,14 +477,17 @@ bool __App_initInodeOperations(App* this)
if (Config_getSysXAttrsEnabled(cfg) )
{
this->fileInodeOps->listxattr = FhgfsOps_listxattr;
this->dirInodeOps->listxattr = FhgfsOps_listxattr;
#ifdef KERNEL_HAS_GENERIC_GETXATTR
this->fileInodeOps->getxattr = generic_getxattr;
this->fileInodeOps->removexattr = FhgfsOps_removexattr;
this->fileInodeOps->setxattr = generic_setxattr;
this->dirInodeOps->listxattr = FhgfsOps_listxattr;
this->dirInodeOps->getxattr = generic_getxattr;
this->dirInodeOps->removexattr = FhgfsOps_removexattr;
this->dirInodeOps->setxattr = generic_setxattr;
#endif
if (Config_getSysACLsEnabled(cfg) )
{
......
......@@ -53,6 +53,11 @@
#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
......
......@@ -17,7 +17,11 @@ bool IBVBuffer_init(IBVBuffer* buffer, IBVCommContext* ctx, size_t bufLen)
for(i = 0; i < count; i++)
{
#ifndef OFED_UNSAFE_GLOBAL_RKEY
buffer->lists[i].lkey = ctx->dmaMR->lkey;
#else
buffer->lists[i].lkey = ctx->pd->local_dma_lkey;
#endif
buffer->lists[i].length = bufLen;
buffer->buffers[i] = ib_dma_alloc_coherent(ctx->pd->device, bufLen, &buffer->lists[i].addr,
GFP_KERNEL);
......
......@@ -500,7 +500,11 @@ bool __IBVSocket_createCommContext(IBVSocket* _this, struct rdma_cm_id* cm_id,
// protection domain...
#ifndef OFED_UNSAFE_GLOBAL_RKEY
commContext->pd = ib_alloc_pd(cm_id->device);
#else
commContext->pd = ib_alloc_pd(cm_id->device, IB_PD_UNSAFE_GLOBAL_RKEY);
#endif
if(IS_ERR(commContext->pd) )
{
ibv_print_info("Couldn't allocate PD. ErrCode: %ld\n", PTR_ERR(commContext->pd) );
......@@ -515,6 +519,7 @@ bool __IBVSocket_createCommContext(IBVSocket* _this, struct rdma_cm_id* cm_id,
// "The consumer is not allowed to assign remote-write (or remote-atomic) to
// a memory region that has not been assigned local-write.")
#ifndef OFED_UNSAFE_GLOBAL_RKEY
commContext->dmaMR = ib_get_dma_mr(commContext->pd,
IB_ACCESS_LOCAL_WRITE| IB_ACCESS_REMOTE_READ| IB_ACCESS_REMOTE_WRITE);
if(IS_ERR(commContext->dmaMR) )
......@@ -524,6 +529,7 @@ bool __IBVSocket_createCommContext(IBVSocket* _this, struct rdma_cm_id* cm_id,
commContext->dmaMR = NULL;
goto err_cleanup;
}
#endif
// alloc and register buffers...
......@@ -713,8 +719,10 @@ void __IBVSocket_cleanupCommContext(struct rdma_cm_id* cm_id, IBVCommContext* co
SAFE_KFREE(commContext->recvBufs);
SAFE_KFREE(commContext->sendBufs);
#ifndef OFED_UNSAFE_GLOBAL_RKEY
if(commContext->dmaMR)
ib_dereg_mr(commContext->dmaMR);
#endif
if(commContext->pd)
ib_dealloc_pd(commContext->pd);
......@@ -732,7 +740,11 @@ void __IBVSocket_initCommDest(IBVCommContext* commContext, IBVCommDest* outDest)
{
memcpy(outDest->verificationStr, IBVSOCKET_PRIVATEDATA_STR, IBVSOCKET_PRIVATEDATA_STR_LEN);
outDest->protocolVersion = cpu_to_le64(IBVSOCKET_PRIVATEDATA_PROTOCOL_VER);
#ifndef OFED_UNSAFE_GLOBAL_RKEY
outDest->rkey = cpu_to_le32(commContext->dmaMR->rkey);
#else
outDest->rkey = cpu_to_le32(commContext->pd->unsafe_global_rkey);
#endif
outDest->vaddr = cpu_to_le64(commContext->checkConBuffer.lists[0].addr);
outDest->recvBufNum = cpu_to_le32(commContext->commCfg.bufNum);
outDest->recvBufSize = cpu_to_le32(commContext->commCfg.bufSize);
......
......@@ -154,7 +154,9 @@ struct IBVIncompleteSend
struct IBVCommContext
{
struct ib_pd* pd; // protection domain
#ifndef OFED_UNSAFE_GLOBAL_RKEY
struct ib_mr* dmaMR; // dma mem region keys
#endif
atomic_t recvCompEventCount; // incremented on incoming event notification
wait_queue_head_t recvCompWaitQ; // for recvCompEvents
......
......@@ -30,6 +30,7 @@
// storage feature flags
#define STORAGE_FEATURE_DUMMY 0
#define STORAGE_FEATURE_GETTARGETCONSISTENCYSTATES 1 // Supports GetTargetConsistencyStatesMsg
// client feature flags
......
......@@ -372,16 +372,24 @@ ssize_t FhgfsOps_getxattr(struct inode* inode, const char* name, void* value, si
int FhgfsOps_removexattr(struct dentry* dentry, const char* name)
{
App* app = FhgfsOps_getApp(dentry->d_sb);
FhgfsOpsHelper_logOpDebug(app, dentry, NULL, __func__, "(name: %s)", name);
(void) app;
return FhgfsOps_removexattrInode(dentry->d_inode, name);
}
int FhgfsOps_removexattrInode(struct inode* inode, const char* name)
{
App* app = FhgfsOps_getApp(inode->i_sb);
FhgfsOpsErr remotingRes;
FhgfsInode* fhgfsInode = BEEGFS_INODE(dentry->d_inode);
FhgfsInode* fhgfsInode = BEEGFS_INODE(inode);
int refreshRes = maybeRefreshInode(dentry->d_inode, true, false);
int refreshRes = maybeRefreshInode(inode, true, false);
if (refreshRes)
return refreshRes;
FhgfsOpsHelper_logOpDebug(app, dentry, NULL, __func__, "(name: %s)", name);
FhgfsInode_entryInfoReadLock(fhgfsInode);
remotingRes = FhgfsOpsRemoting_removeXAttr(app, FhgfsInode_getEntryInfo(fhgfsInode), name);
......@@ -637,7 +645,7 @@ int FhgfsOps_setattr(struct dentry* dentry, struct iattr* iattr)
const char* logContext = "FhgfsOps_setattr";
int retVal = 0;
int inodeChangeRes;
int setAttrPrepRes;
SettableFileAttribs fhgfsAttr;
int validFhgfsAttribs;
FhgfsOpsErr setAttrRes = FhgfsOpsErr_SUCCESS;
......@@ -650,23 +658,29 @@ int FhgfsOps_setattr(struct dentry* dentry, struct iattr* iattr)
(iattr->ia_valid & ATTR_SIZE) ? "(with trunc)" : "");
}
inodeChangeRes = inode_change_ok(inode, iattr);
if(inodeChangeRes < 0)
return inodeChangeRes;
#ifdef KERNEL_HAS_ATTR_OPEN
/* we do trunc during open message on meta server, so we don't want this redundant trunc
(and ctime/mtime update) from the kernel */
if(iattr->ia_valid & ATTR_OPEN)
{
if (iattr->ia_valid & ATTR_SIZE)
{ // the file was already remotely truncate by open, now also truncate it locally
FhgfsOps_vmtruncate(inode, iattr->ia_size);
}
#ifdef KERNEL_HAS_SETATTR_PREPARE
setAttrPrepRes = setattr_prepare(dentry, iattr);
if(setAttrPrepRes < 0)
return setAttrPrepRes;
#else
setAttrPrepRes = inode_change_ok(inode, iattr);
if(setAttrPrepRes < 0)
return setAttrPrepRes;
#endif
return 0;
#ifdef KERNEL_HAS_ATTR_OPEN
/* we do trunc during open message on meta server, so we don't want this redundant trunc
(and ctime/mtime update) from the kernel */
if(iattr->ia_valid & ATTR_OPEN)
{
if (iattr->ia_valid & ATTR_SIZE)
{ // the file was already remotely truncate by open, now also truncate it locally
FhgfsOps_vmtruncate(inode, iattr->ia_size);
}
#endif
return 0;
}
#endif
if(iattr->ia_valid & ATTR_SIZE)
{ // make sure we only update size of regular files
......@@ -1811,7 +1825,11 @@ void FhgfsOps_put_link(struct dentry* dentry, struct nameidata* nd, void* p)
int FhgfsOps_rename(struct inode* inodeDirFrom, struct dentry* dentryFrom,
struct inode* inodeDirTo, struct dentry* dentryTo)
struct inode* inodeDirTo, struct dentry* dentryTo
#ifdef KERNEL_HAS_RENAME_FLAGS
, unsigned flags
#endif
)
{
struct super_block* sb = dentryFrom->d_sb;
App* app = FhgfsOps_getApp(sb);
......@@ -1837,6 +1855,11 @@ int FhgfsOps_rename(struct inode* inodeDirFrom, struct dentry* dentryFrom,
const char* newName = dentryTo->d_name.name;
unsigned newLen = dentryTo->d_name.len;
#ifdef KERNEL_HAS_RENAME_FLAGS
if (flags != 0)
return -EINVAL;
#endif
if(unlikely(Logger_getLogLevel(log) >= Log_DEBUG) )
FhgfsOpsHelper_logOpMsg(Log_SPAM, app, dentryFrom, dentryFrom->d_inode, logContext,
"From: %s; To: %s", oldName, newName);
......
......@@ -45,6 +45,7 @@ extern int FhgfsOps_setxattr(struct inode* inode, const char* name, const void*
size_t size, int flags);
#endif // KERNEL_HAS_DENTRY_XATTR_HANDLER
extern int FhgfsOps_removexattr(struct dentry* dentry, const char* name);
extern int FhgfsOps_removexattrInode(struct inode* inode, const char* name);
#ifdef KERNEL_HAS_POSIX_GET_ACL
......@@ -98,8 +99,13 @@ extern void* FhgfsOps_follow_link(struct dentry* dentry, struct nameidata* nd);
extern void FhgfsOps_put_link(struct dentry* dentry, struct nameidata* nd, void* p);
#endif
#ifdef KERNEL_HAS_RENAME_FLAGS
extern int FhgfsOps_rename(struct inode* inodeDirFrom, struct dentry* dentryFrom,
struct inode* inodeDirTo, struct dentry* dentryTo, unsigned flags);
#else
extern int FhgfsOps_rename(struct inode* inodeDirFrom, struct dentry* dentryFrom,
struct inode* inodeDirTo, struct dentry* dentryTo);
#endif
extern int FhgfsOps_vmtruncate(struct inode* inode, loff_t offset);
......
......@@ -239,11 +239,22 @@ int FhgfsXAttr_setUser(struct inode* inode, const char* name, const void* value,
strcpy(prefixedName, FHGFS_XATTR_USER_PREFIX);
strcpy(prefixedName + sizeof(FHGFS_XATTR_USER_PREFIX) - 1, name); // sizeof-1 to remove the '\0'
if (value)
{
#ifdef KERNEL_HAS_DENTRY_XATTR_HANDLER
res = FhgfsOps_setxattr(dentry, prefixedName, value, size, flags);
#else
res = FhgfsOps_setxattr(inode, prefixedName, value, size, flags);
#endif // KERNEL_HAS_DENTRY_XATTR_HANDLER
}
else
{
#ifdef KERNEL_HAS_DENTRY_XATTR_HANDLER
res = FhgfsOps_setxattr(dentry, prefixedName, value, size, flags);
res = FhgfsOps_removexattr(dentry, prefixedName);
#else
res = FhgfsOps_setxattr(inode, prefixedName, value, size, flags);
res = FhgfsOps_removexattrInode(inode, prefixedName);
#endif // KERNEL_HAS_DENTRY_XATTR_HANDLER
}
kfree(prefixedName);
return res;
......@@ -331,11 +342,22 @@ int FhgfsXAttr_setSecurity(struct inode* inode, const char* name, const void* va
strcpy(prefixedName, FHGFS_XATTR_SECURITY_PREFIX);
strcpy(prefixedName + sizeof(FHGFS_XATTR_SECURITY_PREFIX) - 1, name); // sizeof-1 to remove '\0'
if (value)
{
#ifdef KERNEL_HAS_DENTRY_XATTR_HANDLER
res = FhgfsOps_setxattr(dentry, prefixedName, value, size, flags);
res = FhgfsOps_setxattr(dentry, prefixedName, value, size, flags);
#else
res = FhgfsOps_setxattr(inode, prefixedName, value, size, flags);
res = FhgfsOps_setxattr(inode, prefixedName, value, size, flags);
#endif
}
else
{
#ifdef KERNEL_HAS_DENTRY_XATTR_HANDLER
res = FhgfsOps_removexattr(dentry, prefixedName);
#else
res = FhgfsOps_removexattrInode(inode, prefixedName);
#endif // KERNEL_HAS_DENTRY_XATTR_HANDLER
}
kfree(prefixedName);
return res;
......
......@@ -56,6 +56,9 @@
#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
......
#ifndef COMMON_GETTARGETCONSISTENCYSTATESMSG_H
#define COMMON_GETTARGETCONSISTENCYSTATESMSG_H
class GetTargetConsistencyStatesMsg : public NetMessageSerdes<GetTargetConsistencyStatesMsg>
{
public:
GetTargetConsistencyStatesMsg(const UInt16Vector& targetIDs)
: BaseType(NETMSGTYPE_GetTargetConsistencyStates),
targetIDs(targetIDs)
{ }
GetTargetConsistencyStatesMsg() : BaseType(NETMSGTYPE_GetTargetConsistencyStates)
{ }
protected:
UInt16Vector targetIDs;
public:
template<typename This, typename Ctx>
static void serialize(This obj, Ctx& ctx)
{
ctx % obj->targetIDs;
}
};
#endif /* COMMON_GETTARGETCONSISTENCYSTATESMSG_H */
#ifndef COMMON_GETTARGETCONSISTENCYSTATERESPSMSG_H
#define COMMON_GETTARGETCONSISTENCYSTATERESPSMSG_H
class GetTargetConsistencyStatesRespMsg : public NetMessageSerdes<GetTargetConsistencyStatesRespMsg>
{
public:
GetTargetConsistencyStatesRespMsg(const TargetConsistencyStateVec& states)
: BaseType(NETMSGTYPE_GetTargetConsistencyStatesResp),
states(states)
{ }
GetTargetConsistencyStatesRespMsg() : BaseType(NETMSGTYPE_GetTargetConsistencyStatesResp)
{ }
protected:
TargetConsistencyStateVec states;
public:
template<typename This, typename Ctx>
static void serialize(This obj, Ctx& ctx)
{
ctx % obj->states;
}
const TargetConsistencyStateVec& getStates() const { return states; }
};
#endif /* COMMON_GETTARGETCONSISTENCYSTATERESPSMSG_H */
......@@ -30,6 +30,7 @@
// storage feature flags
#define STORAGE_FEATURE_DUMMY 0
#define STORAGE_FEATURE_GETTARGETCONSISTENCYSTATES 1 // Supports GetTargetConsistencyStatesMsg
// client feature flags
......
......@@ -19,6 +19,14 @@ enum TargetConsistencyState
TargetConsistencyState_BAD
};
template<>
struct SerializeAs<TargetConsistencyState>
{
typedef int32_t type;
};
typedef std::vector<TargetConsistencyState> TargetConsistencyStateVec;
/**
* A combined target state is a pair of TargetReachabilityState and TargetConsistencyState.
*/
......
......@@ -8,7 +8,7 @@ import java.io.FileNotFoundException;
/**
* Wrapper class for the calls to the beegfs ioctl library.
*/
class JBeeGFS {
public class JBeeGFS {
static {
System.loadLibrary("jbeegfs");
}
......
......@@ -259,7 +259,7 @@ tuneUsePerUserMsgQueues = false
# typically are significantly faster.
# Note: This setting can only be configured at first startup and cannot be
# changed afterwards.
# Default: false
# Default: true
#
......
......@@ -286,6 +286,7 @@ class MirroredMessage : public BaseT
// set flag here instead of at the beginning because &message == this is often used
message.addFlag(NetMessageHeader::Flag_BuddyMirrorSecond);
message.addFlag(this->getFlags() & NetMessageHeader::Flag_IsSelectiveAck);
message.addFlag(this->getFlags() & NetMessageHeader::Flag_HasSequenceNumber);
FhgfsOpsErr commRes = MessagingTk::requestResponseNode(&rrNode, &rrArgs);
......
......@@ -48,8 +48,17 @@ class SessionFileStore
{
bool result = true;
for (auto it = sessions.begin(); it != sessions.end(); ++it)
result &= it->second->getReferencedObject()->relinkInode(store);
for (auto it = sessions.begin(); it != sessions.end(); )
{
const bool relinkRes = it->second->getReferencedObject()->relinkInode(store);
if (!relinkRes)
sessions.erase(it++);
else
++it;
result &= relinkRes;
}
return result;
}
......
......@@ -359,17 +359,14 @@ bool SessionStore::deserializeFromBuf(const char* buf, size_t bufLen, MetaStore&
deserialize(des);
if (!des.good())
{
LOG(ERR, "Unable to deserialize session store from buffer.");
return false;
}
const bool relinkRes = relinkInodes(metaStore);
if (!relinkRes)
{
LOG(ERR, "Unable to relink inodes.");
if (!des.good() || !relinkRes)
return false;
}
deserializeLockStates(des, metaStore);
if (!des.good())
......
......@@ -72,8 +72,25 @@ class SessionStore
{
bool result = true;
for (auto it = sessions.begin(); it != sessions.end(); ++it)
result &= it->second->getReferencedObject()->relinkInodes(store);
for (auto it = sessions.begin(); it != sessions.end(); )
{
const bool relinkRes = it->second->getReferencedObject()->relinkInodes(store);
if (!relinkRes)
{
// Relinking failed on at least one SessionFile in this Session -> remove if empty
if (it->second->getReferencedObject()->getFiles()->getSize() == 0)
sessions.erase(it++);
else
++it;
}
else
{
++it;
}
result &= relinkRes;
}
return result;
}
......
......@@ -68,6 +68,12 @@ FhgfsOpsErr IncompleteInode::clearUnsetXAttrs()
{
if (xattrsSet.count(*it))
continue;
// do not sync the system namespaces.
// * security. cannot be synced at all, since userspace can't write to it
// * trusted. is unused by us and thus not interesting
// * system. contains only acls, which we don't use to represent metadata
if (it->compare(0, 5, "user.") != 0)
continue;
int removeRes = ::fremovexattr(fd, it->c_str());
if (removeRes != 0)
......
......@@ -3,35 +3,51 @@
#
# Use "make help" to find out about configuration options.
CAN_PACKAGE := yes
include $(or $(root-dir),../..)/build/Makefile
LIB = libbeegfs-opentk.so
LIB_NO_IB = libbeegfs-opentk-disabledIB.so
LIB_IB = libbeegfs-opentk-enabledIB.so
LIB = beegfs-opentk
LIB_NO_IB=$(LIB)-disabledIB
LIB_IB=$(LIB)-enabledIB
# Include System Feature Auto-Detectors
include SystemFeatureDetection.mk
CXXFLAGS += $(SYSTEM_FEATURE_DETECTION) -I ../include -fPIC
CXXFLAGS_DEBUG += -DBEEGFS_OPENTK_LOG_CONN_ERRORS
PREFIX ?= /opt/beegfs
ETC_DIR ?= /etc
SRC_PATH=$(DESTDIR)/$(PREFIX)/src/beegfs_opentk_lib
SOURCES = $(shell find ../source -name '*.cpp')
CXX ?= g++
CXXFLAGS = -std=gnu++0x -D_FILE_OFFSET_BITS=64 -I../source -I../include \
-Wall -fmessage-length=0 -fno-strict-aliasing -Wunused-variable \
-fPIC -Wextra -Wno-unused-parameter -pthread -ggdb3 $(SYSTEM_FEATURE_DETECTION) \
$(USER_CXXFLAGS)
CXXFLAGS_RELEASE = -O3 -Wuninitialized
CXXFLAGS_DEBUG = -O1 -ggdb3 -D_FORTIFY_SOURCE=2 \
-DBEEGFS_DEBUG -DBEEGFS_OPENTK_LOG_CONN_ERRORS
LDFLAGS = -shared -pthread -rdynamic $(USER_LDFLAGS)
LDFLAGS_RELASE = -O3
LDFLAGS_DEBUG = -O0
$(call build-static-library,\
beegfs-opentk,\
$(SOURCES))
SOURCES = $(shell find ../source -name '*.cpp')
$(call build-shared-library,\
beegfs-opentk,\
$(SOURCES))
OBJECTS = $(SOURCES:.cpp=.o)
CLEANUP_OBJECTS = $(shell find ../source -name '*.o')
PREFIX ?= /opt/beegfs
ETC_DIR ?= /etc
DEPENDENCY_FILES = $(SOURCES:.cpp=.d)
SRC_PATH=$(DESTDIR)/$(PREFIX)/src/beegfs_opentk_lib
ifeq ($(BEEGFS_DEBUG),)
CXXFLAGS += $(CXXFLAGS_RELEASE)
LDFLAGS += $(LDFLAGS_RELASE)
else
CXXFLAGS += $(CXXFLAGS_DEBUG)
LDFLAGS += $(LDFLAGS_DEBUG)
endif
# if path to strip command was not given, use default
# (alternative strip is important when cross-compiling)
ifeq ($(STRIP),)
STRIP=strip
endif
# OFED
ifeq ($(BEEGFS_OPENTK_IBVERBS),1)
......@@ -48,29 +64,50 @@ LDFLAGS += -L$(OFED_LIB_PATH)
endif
all: $(SOURCES) lib$(LIB).a
all-deeper: $(SOURCES) lib$(LIB).a
# clean up old stuff first
$(MAKE) clean
$(MAKE) FHGFS_OPENTK_IBVERBS=0
strip:
cp lib$(LIB).a lib$(LIB)-unstripped.a
${STRIP} --strip-debug lib$(LIB).a
lib$(LIB).a: $(OBJECTS)
$(CXX) $(OBJECTS) $(LDFLAGS) -o lib$(LIB).so
ar -r lib$(LIB).a $(OBJECTS)
# build without and with IB support
package_lib:
package_lib:
# clean up old stuff first
$(MAKE) clean
# with IB first
$(MAKE) BEEGFS_OPENTK_IBVERBS=1
mv $(LIB) $(LIB_IB).save
mv lib$(LIB).so lib$(LIB_IB).so.clean_save
$(MAKE) clean
mv lib$(LIB_IB).so.clean_save lib$(LIB_IB).so # clean would have deleted the .so
cp -a lib$(LIB_IB).so lib$(LIB_IB)-unstripped.so
${STRIP} --strip-debug lib$(LIB_IB).so
# now without IB
$(MAKE) BEEGFS_OPENTK_IBVERBS=0
mv lib$(LIB).so lib$(LIB_NO_IB).so
cp -a lib$(LIB_NO_IB).so lib$(LIB_NO_IB)-unstripped.so
${STRIP} --strip-debug lib$(LIB_NO_IB).so
mv $(LIB) $(LIB_NO_IB)
mv $(LIB_IB).save $(LIB_IB)
$(STRIP) --strip-debug $(LIB_NO_IB)
$(STRIP) --strip-debug $(LIB_IB)
%.o: %.cpp Makefile
$V$(CXX) $(CXXFLAGS) -c $< -E -MMD -MP -MF$(@:.o=.d) -MT$@ -o/dev/null
$V$(DISTCC) $(CXX) $(CXXFLAGS) -o$@ -c $<
install: package_lib
install -D -m 644 $(LIB_NO_IB) $(DESTDIR)/$(PREFIX)/lib/$(LIB_NO_IB)
install -D -m 644 $(LIB_IB) $(DESTDIR)/$(PREFIX)/lib/$(LIB_IB)
install -D -m 644 lib$(LIB_NO_IB).so $(DESTDIR)/$(PREFIX)/lib/lib$(LIB_NO_IB).so
install -D -m 644 lib$(LIB_IB).so $(DESTDIR)/$(PREFIX)/lib/lib$(LIB_IB).so
package_install: install
@# PREFIX is something like /usr or /usr/local or /opt/beegfs
......@@ -97,19 +134,51 @@ package_install: install
find ../source -mount -name '*.cpp' -type f | \
xargs -I '{}' cp --parents '{}' $(SRC_PATH)/build
CLEANUP_FILES += $(LIB) $(LIB_NO_IB) $(LIB_IB)
define HELP_ARGS_SPECIFIC
@echo ' BEEGFS_OPENTK_IBVERBS=1 Defining this enables ibverbs support'
@echo ' OFED_INCLUDE_PATH=<path> Path to OpenFabrics Enterpise Distribution'
@echo ' include directory'
@echo ' Note: This directory contains e.g. "rdma/rdma_cma.h"'
@echo ' (If this is undefined then standard system include'
@echo ' paths will be used.)'
@echo ' OFED_LIB_PATH=<path> Path to OpenFabrics Enterpise Distribution lib directory'
@echo ' Note: This directory contains librdmacm and libibverbs'
@echo ' PREFIX=/some/path Installation root directory (default: /opt/beegfs)'
@echo ' ETC_DIR Prefix for configuration files (default: /etc)'
@echo ' DESTDIR=/some/path Mainly for package building, used as primary path prefix then'
endef
clean:
rm -rf $(CLEANUP_OBJECTS) $(DEPENDENCY_FILES) lib$(LIB).so \
lib$(LIB_NO_IB).so lib$(LIB_IB).so lib$(LIB).a \
lib$(LIB_NO_IB)-unstripped.so lib$(LIB_IB)-unstripped.so lib$(LIB)-unstripped.a
rpm:
./make-rpm
deb:
./make-deb
help:
@echo 'Optional Arguments:'
@echo ' BEEGFS_OPENTK_IBVERBS=1:'
@echo ' Defining this enables ibverbs support.'
@echo ' OFED_INCLUDE_PATH=<path>:'
@echo ' Path to OpenFabrics Enterpise Distribution include directory.'
@echo ' Note: This directory contains e.g. "rdma/rdma_cma.h". (If this is'
@echo ' undefined then standard system include paths will be used.)'
@echo ' OFED_LIB_PATH=<path>:'
@echo ' Path to OpenFabrics Enterpise Distribution lib directory.'
@echo ' Note: This directory contains librdmacm and libibverbs.'
@echo ' BEEGFS_DEBUG=1:'