Loading...
Searching...
No Matches
XrdCephOss.cc File Reference
`#include <chrono>`
`#include <stdio.h>`
`#include <string>`
`#include <fcntl.h>`
`#include <limits.h>`
`#include "XrdVersion.hh"`
`#include "XrdCeph/XrdCephOss.hh"`
`#include "XrdCeph/XrdCephOssDir.hh"`
`#include "XrdCeph/XrdCephOssFile.hh"`
`#include "XrdCeph/XrdCephPosix.hh"`
`#include "XrdCeph/XrdCephOssBufferedFile.hh"`
`#include "XrdCeph/XrdCephOssReadVFile.hh"`
`#include "XrdOuc/XrdOucEnv.hh"`
`#include "XrdSys/XrdSysError.hh"`
`#include "XrdSys/XrdSysPlatform.hh"`
`#include "XrdOuc/XrdOucTrace.hh"`
`#include "XrdOuc/XrdOucStream.hh"`
`#include "XrdOuc/XrdOucName2Name.hh"`
`#include "XrdOuc/XrdOucN2NLoader.hh"`
Include dependency graph for XrdCephOss.cc:

Go to the source code of this file.

## Functions

std::string | extractPool (std::string possPool)
| Extract a pool name (string before the first colon ':') from an object ID.
int | formatStatLSResponse (char *buff, int &blen, const char *cgroup, long long totalSpace, long long usedSpace, long long freeSpace, long long quota, long long maxFreeChunk)
ssize_t | getNumericAttr (const char *const path, const char *attrName, const int maxAttrLen)
| Retrieve an integer-value extended attribute.
static void | logwrapper (char *format, va_list argp)
void | m_translateFileName (std::string &physName, std::string logName)
| converts a logical filename to physical one if needed
static std::string | ts ()
| timestamp output for logging messages
XrdOss * | XrdOssGetStorageSystem (XrdOss *native_oss, XrdSysLogger *lp, const char *config_fn, const char *parms)
| XrdVERSIONINFO (XrdOssGetStorageSystem, XrdCephOss)

## Variables

unsigned int | g_cephAioWaitThresh
char | g_logstring [1024]
unsigned int | g_maxCephPoolIdx
XrdOucName2Name * | g_namelib
XrdSysError | XrdCephEroute (0)

## Function Documentation

## extractPool()

std::string extractPool | ( | std::string | possPool | ) |

Extract a pool name (string before the first colon ':') from an object ID.

Parameters

  (in) | possPool the object ID

Returns
  pool name or unchanged object ID

Implementation: Ian Johnson STFC RAL, ian.j.nosp@m.ohns.nosp@m.on@st.nosp@m.fc.a.nosp@m.c.uk, 2022

Definition at line 421 of file XrdCephOss.cc.

{
std::string pool;
auto colonPos = possPool.find_first_of(':');
if (colonPos > 0) {
pool = possPool.substr(0, colonPos);
} else {
pool = possPool;
}
return pool;
}

Referenced by XrdCephOss::StatLS().

Here is the caller graph for this function:

## formatStatLSResponse()

int formatStatLSResponse | ( | char * | buff,
|  | int & | blen,
|  | const char * | cgroup,
|  | long long | totalSpace,
|  | long long | usedSpace,
|  | long long | freeSpace,
|  | long long | quota,
|  | long long | maxFreeChunk )

Definition at line 556 of file XrdCephOss.cc.

{
return snprintf(buff, blen, "oss.cgroup=%s&oss.space=%lld&oss.free=%lld&oss.maxf=%lld&oss.used=%lld&oss.quota=%lld",
cgroup, totalSpace, freeSpace, maxFreeChunk, usedSpace, quota);
}

Referenced by XrdCephOss::StatLS().

Here is the caller graph for this function:

## getNumericAttr()

ssize_t getNumericAttr | ( | const char *const | path,
|  | const char * | attrName,
|  | const int | maxAttrLen )

Retrieve an integer-value extended attribute.

Get an integer numeric value from an extended attribute attached to an object

Parameters

  path | the object ID containing the attribute
  attrName | the name of the attribute to retrieve
  maxAttrLen | the largest number of characters to handle

Returns
  value of the attibute, -EINVAL if not valid integer, or -ENOMEM

Implementation: Ian Johnson, ian.j.nosp@m.ohns.nosp@m.on@st.nosp@m.fc.a.nosp@m.c.uk, 2022

Definition at line 104 of file XrdCephOss.cc.

{
ssize_t retval;
char *attrValue = (char*)malloc(maxAttrLen+1);
if (NULL == attrValue) {
return -ENOMEM;
}
ssize_t attrLen = ceph_posix_getxattr((XrdOucEnv*)NULL, path, attrName, attrValue, maxAttrLen);
if (attrLen <= 0) {
retval = -EINVAL;
} else {
attrValue[attrLen] = '\0';
char *endPointer = (char *)NULL;
retval = strtoll(attrValue, &endPointer, 10);
}
if (NULL != attrValue) {
free(attrValue);
}
return retval;
}
ceph_posix_getxattr
ssize_t ceph_posix_getxattr(XrdOucEnv *env, const char *path, const char *name, void *value, size_t size)
Definition XrdCephPosix.cc:1316
XrdOucEnv
Definition XrdOucEnv.hh:42

References ceph_posix_getxattr().

Referenced by XrdCephOss::StatLS().

Here is the call graph for this function:
Here is the caller graph for this function:

## logwrapper()

void logwrapper | ( | char * | format,
|  | va_list | argp )

static

Definition at line 62 of file XrdCephOss.cc.

{
vsnprintf(g_logstring, 1024, format, argp);
XrdCephEroute.Say(ts().c_str(), g_logstring);
}
ts
static std::string ts()
timestamp output for logging messages
Definition XrdCephOss.cc:53
g_logstring
char g_logstring[1024]
Definition XrdCephOss.cc:61
XrdCephEroute
XrdSysError XrdCephEroute(0)
Definition XrdCephOss.cc:50

References g_logstring, ts(), and XrdCephEroute.

Referenced by bulkAioRead::bulkAioRead(), ceph_nonstriper_readv(), ceph_posix_nonstriper_pread(), and XrdOssGetStorageSystem().

Here is the call graph for this function:
Here is the caller graph for this function:

## m_translateFileName()

void m_translateFileName | ( | std::string & | physName,
|  | std::string | logName )

converts a logical filename to physical one if needed

Definition at line 74 of file XrdCephOss.cc.

{
if (0 != g_namelib) {
char physCName[MAXPATHLEN+1];
int retc = g_namelib->lfn2pfn(logName.c_str(), physCName, sizeof(physCName));
if (retc) {
XrdCephEroute.Say(__FUNCTION__, " - failed to translate '", logName.c_str(), "' using namelib plugin, using it as is");
physName = logName;
} else {
XrdCephEroute.Say(__FUNCTION__, " - translated '", logName.c_str(), "' to '", physCName, "'");
physName = physCName;
}
} else {
physName = logName;
}
}
g_namelib
XrdOucName2Name * g_namelib
Definition XrdCephPosix.cc:98

References g_namelib, and XrdCephEroute.

Referenced by XrdCephOss::Stat(), and XrdCephOss::StatLS().

Here is the caller graph for this function:

## ts()

std::string ts | ( |  | ) |

static

timestamp output for logging messages

Definition at line 53 of file XrdCephOss.cc.

{
std::time_t t = std::time(nullptr);
char mbstr[50];
std::strftime(mbstr, sizeof(mbstr), "%y%m%d %H:%M:%S ", std::localtime(&t));
return std::string(mbstr);
}

Referenced by XrdOssCsiPages::XrdOssCsiPages(), XrdCl::StatInfo::~StatInfo(), logwrapper(), XrdOucString::matches(), XrdCl::HttpFilePlugIn::Open(), XrdCephOssReadVFile::ReadV(), XrdScheduler::Reaper(), XrdCl::Log::Say(), XrdSutParseTime(), and xrootdfs_utimens().

Here is the caller graph for this function:

## XrdOssGetStorageSystem()

XrdOss * XrdOssGetStorageSystem | ( | XrdOss * | native_oss,
|  | XrdSysLogger * | lp,
|  | const char * | config_fn,
|  | const char * | parms )

Definition at line 134 of file XrdCephOss.cc.

{
// Do the herald thing
XrdCephEroute.SetPrefix("ceph_");
XrdCephEroute.logger(lp);
XrdCephEroute.Say("++++++ CERN/IT-DSS XrdCeph");
// set parameters
try {
ceph_posix_set_defaults(parms);
} catch (std::exception &e) {
XrdCephEroute.Say("CephOss loading failed with exception. Check the syntax of parameters : ", parms);
return 0;
}
// deal with logging
ceph_posix_set_logfunc(logwrapper);
return new XrdCephOss(config_fn, XrdCephEroute);
}
logwrapper
static void logwrapper(char *format, va_list argp)
Definition XrdCephOss.cc:62
ceph_posix_set_logfunc
void ceph_posix_set_logfunc(void(*logfunc)(char *, va_list argp))
Definition XrdCephPosix.cc:644
ceph_posix_set_defaults
void ceph_posix_set_defaults(const char *value)
Definition XrdCephPosix.cc:397
XrdCephOss
Definition XrdCephOss.hh:55

References ceph_posix_set_defaults(), ceph_posix_set_logfunc(), logwrapper(), and XrdCephEroute.

Referenced by XrdCephOss::Configure(), and XrdVERSIONINFO().

Here is the call graph for this function:
Here is the caller graph for this function:

## XrdVERSIONINFO()

XrdVERSIONINFO | ( | XrdOssGetStorageSystem | ,
|  | XrdCephOss | )

References XrdOssGetStorageSystem().

Here is the call graph for this function:

## Variable Documentation

## g_cephAioWaitThresh

unsigned int g_cephAioWaitThresh

extern

If aio read operation takes longer than this value, a warning will be issued

Definition at line 91 of file XrdCephPosix.cc.

Referenced by ceph_nonstriper_readv(), ceph_posix_nonstriper_pread(), and XrdCephOss::Configure().

## g_logstring

char g_logstring[1024]

Definition at line 61 of file XrdCephOss.cc.

Referenced by logwrapper().

## g_maxCephPoolIdx

unsigned int g_maxCephPoolIdx

extern

size of the Striper/IoCtx pool, defaults to 1 may be overwritten in the configuration file (See XrdCephOss::configure)

Definition at line 95 of file XrdCephPosix.cc.

Referenced by ceph_posix_disconnect_all(), XrdCephOss::Configure(), and getCephPoolIdxAndIncrease().

## g_namelib

XrdOucName2Name* g_namelib

extern

pointer to library providing Name2Name interface. 0 be default populated in case of ceph.namelib entry in the config file used in XrdCephPosix

pointer to library providing Name2Name interface. 0 be default populated in case of ceph.namelib entry in the config file in XrdCephOss

Definition at line 98 of file XrdCephPosix.cc.

Referenced by XrdCephOss::Configure(), m_translateFileName(), and translateFileName().

## XrdCephEroute

XrdOucTrace XrdCephTrace & XrdCephEroute | ( | 0 |  | ) |

Definition at line 50 of file XrdCephOss.cc.

Referenced by XrdCephOssReadVFile::XrdCephOssReadVFile(), logwrapper(), m_translateFileName(), XrdCephOssFile::Open(), XrdCephOssDir::Opendir(), XrdCephOssFile::Read(), XrdCephOssFile::ReadV(), XrdCephOss::Stat(), XrdCephOss::StatFS(), XrdCephOss::StatLS(), XrdCephOss::StatVS(), XrdCephOss::Truncate(), XrdCephOss::Unlink(), and XrdOssGetStorageSystem().