Skip to content

Commit

Permalink
XrdCeph: Second version of the CEPH xrootd plugin
Browse files Browse the repository at this point in the history
It now handles userIds and pools via the syntax [[userId@]pool/]path for the fileName.
It also includes a second plugin dedicated to xattr management
  • Loading branch information
Sebastien Ponce authored and ljanyst committed Feb 23, 2015
1 parent f4cfccd commit 9febe8a
Show file tree
Hide file tree
Showing 11 changed files with 560 additions and 116 deletions.
33 changes: 29 additions & 4 deletions src/XrdCeph.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ include( XRootDCommon )
set( XRD_CEPH_VERSION 1.0.0 )
set( XRD_CEPH_SOVERSION 1 )

#-------------------------------------------------------------------------------
# The XrdClient lib
#-------------------------------------------------------------------------------
set( XRD_CEPH_XATTR_VERSION 1.0.0 )
set( XRD_CEPH_XATTR_SOVERSION 1 )

find_package(ceph REQUIRED)
include_directories( ${RADOS_INCLUDE_DIR} )

#-------------------------------------------------------------------------------
# The XrdCeph lib
#-------------------------------------------------------------------------------
add_library(
XrdCeph
SHARED
Expand All @@ -34,9 +37,31 @@ set_target_properties(
INTERFACE_LINK_LIBRARIES ""
LINK_INTERFACE_LIBRARIES "" )

#-------------------------------------------------------------------------------
# The XrdCephXattr lib
#-------------------------------------------------------------------------------
add_library(
XrdCephXattr
SHARED
XrdCeph/CephXAttr.cc XrdCeph/CephXAttr.hh )

target_link_libraries(
XrdCeph
XrdCephXattr
XrdUtils
${RADOS_LIBS} )

set_target_properties(
XrdCephXattr
PROPERTIES
VERSION ${XRD_CEPH_XATTR_VERSION}
SOVERSION ${XRD_CEPH_XATTR_SOVERSION}
INTERFACE_LINK_LIBRARIES ""
LINK_INTERFACE_LIBRARIES "" )

#-------------------------------------------------------------------------------
# Install
#-------------------------------------------------------------------------------
install(
TARGETS XrdCeph
TARGETS XrdCeph XrdCephXattr
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
27 changes: 6 additions & 21 deletions src/XrdCeph/CephOss.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,12 @@ extern "C"
const char* config_fn,
const char* parms)
{
return new CephOss(parms);
ceph_posix_set_defaults(parms);
return new CephOss();
}
}

const char* CephOss::getPoolFromEnv(XrdOucEnv *env) {
if (0 != env) {
char* value = env->Get("pool");
if (0 != value) {
return value;
}
}
return (char*)m_defaultPool.c_str();
}

CephOss::CephOss(const char* defaultPool) {
if (0 == defaultPool) {
m_defaultPool = "default";
} else {
m_defaultPool = defaultPool;
}
}
CephOss::CephOss() {}

CephOss::~CephOss() {
ceph_posix_disconnect_all();
Expand Down Expand Up @@ -75,7 +60,7 @@ int CephOss::Stat(const char* path,
struct stat* buff,
int opts,
XrdOucEnv* env) {
return ceph_posix_stat(getPoolFromEnv(env), path, buff);
return ceph_posix_stat(env, path, buff);
}

int CephOss::StatFS(const char *path, char *buff, int &blen, XrdOucEnv *eP) {
Expand Down Expand Up @@ -105,11 +90,11 @@ int CephOss::StatVS(XrdOssVSInfo *sP, const char *sname, int updt) {
int CephOss::Truncate (const char* path,
unsigned long long size,
XrdOucEnv* env) {
return ceph_posix_truncate(getPoolFromEnv(env), path, size);
return ceph_posix_truncate(env, path, size);
}

int CephOss::Unlink(const char *path, int Opts, XrdOucEnv *env) {
return ceph_posix_unlink(getPoolFromEnv(env), path);
return ceph_posix_unlink(env, path);
}

XrdOssDF* CephOss::newDir(const char *tident) {
Expand Down
32 changes: 23 additions & 9 deletions src/XrdCeph/CephOss.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,31 @@
#include <string>
#include <XrdOss/XrdOss.hh>

//------------------------------------------------------------------------------
//! This class implements XrdOss interface for usage with a CEPH storage.
//! It should be loaded via the ofs.osslib directive.
//!
//! This plugin is able to use any pool of ceph with any userId.
//! There are several ways to provide the pool and userId to be used for a given
//! operation. Here is the ordered list of possibilities.
//! First one defined wins :
//! - the path can be prepended with userId and pool. Syntax is :
//! [[userId@]pool:]<actual path>
//! - the XrdOucEnv parameter, when existing, can have 'cephUserId' and/or
//! 'cephPool' entries
//! - the ofs.osslib directive can provide an argument with format :
//! [userID@]pool
//! - default are 'admin' and 'default' for userId and pool respectively
//!
//! Note that the definition of a default via the ofs.osslib directive may
//! clash with one used in a ofs.xattrlib directive. In case both directives
//! have a default and they are different, the behavior is not defined.
//! In case one of the two only has a default, it will be applied for both plugins.
//------------------------------------------------------------------------------

class CephOss : public XrdOss {
public:
CephOss(const char* defaultPool);
CephOss();
virtual ~CephOss();

virtual int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0);
Expand All @@ -23,14 +45,6 @@ public:
virtual XrdOssDF *newDir(const char *tident);
virtual XrdOssDF *newFile(const char *tident);

/// get the pool to be used from the environment
const char* getPoolFromEnv(XrdOucEnv* env);

private:

/// default pool to be used when an object is opened without a pool
std::string m_defaultPool;

};

#endif /* __CEPH_OSS_HH__ */
5 changes: 1 addition & 4 deletions src/XrdCeph/CephOssDir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
CephOssDir::CephOssDir(CephOss *cephOss) : m_dirp(0), m_cephOss(cephOss) {}

int CephOssDir::Opendir(const char *path, XrdOucEnv &env) {
if (strlen(path) != 1 || path[0] != '/') {
return -ENOENT;
}
m_dirp = ceph_posix_opendir(m_cephOss->getPoolFromEnv(&env));
m_dirp = ceph_posix_opendir(&env, path);
if (0 == m_dirp) {
return -errno;
}
Expand Down
24 changes: 24 additions & 0 deletions src/XrdCeph/CephOssDir.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@
#include <XrdOss/XrdOss.hh>
#include "CephOss.hh"

//------------------------------------------------------------------------------
//! This class implements XrdOssDF interface for usage with a CEPH storage.
//! It has a very restricted usage as the only valid path for opendir is '/'.
//! The reason is that ceph is an object store where you can only list all
//! objects, and that has no notion of hierarchy
//!
//! This plugin is able to use any pool of ceph with any userId.
//! There are several ways to provide the pool and userId to be used for a given
//! operation. Here is the ordered list of possibilities.
//! First one defined wins :
//! - the path can be prepended with userId and pool. Syntax is :
//! [[userId@]pool:]<actual path>
//! - the XrdOucEnv parameter, when existing, can have 'cephUserId' and/or
//! 'cephPool' entries
//! - the ofs.osslib directive can provide an argument with format :
//! [userID@]pool
//! - default are 'admin' and 'default' for userId and pool respectively
//!
//! Note that the definition of a default via the ofs.osslib directive may
//! clash with one used in a ofs.xattrlib directive. In case both directives
//! have a default and they are different, the behavior is not defined.
//! In case one of the two only has a default, it will be applied for both plugins.
//------------------------------------------------------------------------------

class CephOssDir : public XrdOssDF {

public:
Expand Down
2 changes: 1 addition & 1 deletion src/XrdCeph/CephOssFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
CephOssFile::CephOssFile(CephOss *cephOss) : m_fd(-1), m_cephOss(cephOss) {}

int CephOssFile::Open(const char *path, int flags, mode_t mode, XrdOucEnv &env) {
m_fd = ceph_posix_open(m_cephOss->getPoolFromEnv(&env), path, flags, mode);
m_fd = ceph_posix_open(&env, path, flags, mode);
return XrdOssOK;
}

Expand Down
21 changes: 21 additions & 0 deletions src/XrdCeph/CephOssFile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
#include <XrdOss/XrdOss.hh>
#include "CephOss.hh"

//------------------------------------------------------------------------------
//! This class implements XrdOssDF interface for usage with a CEPH storage.
//!
//! This plugin is able to use any pool of ceph with any userId.
//! There are several ways to provide the pool and userId to be used for a given
//! operation. Here is the ordered list of possibilities.
//! First one defined wins :
//! - the path can be prepended with userId and pool. Syntax is :
//! [[userId@]pool:]<actual path>
//! - the XrdOucEnv parameter, when existing, can have 'cephUserId' and/or
//! 'cephPool' entries
//! - the ofs.osslib directive can provide an argument with format :
//! [userID@]pool
//! - default are 'admin' and 'default' for userId and pool respectively
//!
//! Note that the definition of a default via the ofs.osslib directive may
//! clash with one used in a ofs.xattrlib directive. In case both directives
//! have a default and they are different, the behavior is not defined.
//! In case one of the two only has a default, it will be applied for both plugins.
//------------------------------------------------------------------------------

class CephOssFile : public XrdOssDF {

public:
Expand Down
55 changes: 55 additions & 0 deletions src/XrdCeph/CephXAttr.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include <XrdVersion.hh>
#include <XrdCeph/ceph_posix.h>
#include "CephXAttr.hh"

extern "C"
{
XrdSysXAttr*
XrdSysGetXAttrObject(XrdSysError *errP,
const char *config_fn,
const char *parms)
{
ceph_posix_set_defaults(parms);
return new CephXAttr();
}
}

CephXAttr::CephXAttr() {}

CephXAttr::~CephXAttr() {}

int CephXAttr::Del(const char *Aname, const char *Path, int fd) {
return ceph_posix_removexattr(0, Path, Aname);
}

void CephXAttr::Free(AList *aPL) {
ceph_posix_freexattrlist(aPL);
}

int CephXAttr::Get(const char *Aname, void *Aval, int Avsz,
const char *Path, int fd) {
if (fd >= 0) {
return ceph_posix_fgetxattr(fd, Aname, Aval, Avsz);
} else {
return ceph_posix_getxattr(0, Path, Aname, Aval, Avsz);
}
}

int CephXAttr::List(AList **aPL, const char *Path, int fd, int getSz) {
if (fd > 0) {
return ceph_posix_flistxattrs(fd, aPL, getSz);
} else {
return ceph_posix_listxattrs(0, Path, aPL, getSz);
}
}

int CephXAttr::Set(const char *Aname, const void *Aval, int Avsz,
const char *Path, int fd, int isNew) {
if (fd >= 0) {
return ceph_posix_fsetxattr(fd, Aname, Aval, Avsz, 0);
} else {
return ceph_posix_setxattr(0, Path, Aname, Aval, Avsz, 0);
}
}

XrdVERSIONINFO(XrdSysGetXAttrObject, CephXattr);

0 comments on commit 9febe8a

Please sign in to comment.