XRootD
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. More...
 
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. More...
 
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 More...
 
static std::string ts ()
 timestamp output for logging messages More...
 
XrdOssXrdOssGetStorageSystem (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
 
XrdOucName2Nameg_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.

421  {
422 
423  std::string pool;
424  auto colonPos = possPool.find_first_of(':');
425 
426  if (colonPos > 0) {
427  pool = possPool.substr(0, colonPos);
428  } else {
429  pool = possPool;
430  }
431  return pool;
432 }

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.

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

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
paththe object ID containing the attribute
attrNamethe name of the attribute to retrieve
maxAttrLenthe 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.

105 {
106 
107  ssize_t retval;
108  char *attrValue = (char*)malloc(maxAttrLen+1);
109  if (NULL == attrValue) {
110  return -ENOMEM;
111  }
112 
113  ssize_t attrLen = ceph_posix_getxattr((XrdOucEnv*)NULL, path, attrName, attrValue, maxAttrLen);
114 
115  if (attrLen <= 0) {
116  retval = -EINVAL;
117  } else {
118  attrValue[attrLen] = '\0';
119  char *endPointer = (char *)NULL;
120  retval = strtoll(attrValue, &endPointer, 10);
121  }
122 
123  if (NULL != attrValue) {
124  free(attrValue);
125  }
126 
127  return retval;
128 
129 }
ssize_t ceph_posix_getxattr(XrdOucEnv *env, const char *path, const char *name, void *value, size_t size)

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

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

Definition at line 62 of file XrdCephOss.cc.

62  {
63  vsnprintf(g_logstring, 1024, format, argp);
64  XrdCephEroute.Say(ts().c_str(), g_logstring);
65 }
static std::string ts()
timestamp output for logging messages
Definition: XrdCephOss.cc:53
char g_logstring[1024]
Definition: XrdCephOss.cc:61
XrdSysError XrdCephEroute(0)
Definition: XrdCephOss.cc:50
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
Definition: XrdSysError.cc:141

References g_logstring, XrdSysError::Say(), ts(), and XrdCephEroute.

Referenced by bulkAioRead::bulkAioRead(), 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.

74  {
75  if (0 != g_namelib) {
76  char physCName[MAXPATHLEN+1];
77  int retc = g_namelib->lfn2pfn(logName.c_str(), physCName, sizeof(physCName));
78  if (retc) {
79  XrdCephEroute.Say(__FUNCTION__, " - failed to translate '", logName.c_str(), "' using namelib plugin, using it as is");
80  physName = logName;
81  } else {
82  XrdCephEroute.Say(__FUNCTION__, " - translated '", logName.c_str(), "' to '", physCName, "'");
83  physName = physCName;
84  }
85  } else {
86  physName = logName;
87  }
88 }
XrdOucName2Name * g_namelib
Definition: XrdCephPosix.cc:98
virtual int lfn2pfn(const char *lfn, char *buff, int blen)=0

References g_namelib, XrdOucName2Name::lfn2pfn(), XrdSysError::Say(), and XrdCephEroute.

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

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

◆ ts()

static std::string ts ( )
static

timestamp output for logging messages

Definition at line 53 of file XrdCephOss.cc.

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

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

+ 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.

138  {
139  // Do the herald thing
140  XrdCephEroute.SetPrefix("ceph_");
141  XrdCephEroute.logger(lp);
142  XrdCephEroute.Say("++++++ CERN/IT-DSS XrdCeph");
143  // set parameters
144  try {
146  } catch (std::exception &e) {
147  XrdCephEroute.Say("CephOss loading failed with exception. Check the syntax of parameters : ", parms);
148  return 0;
149  }
150  // deal with logging
152  return new XrdCephOss(config_fn, XrdCephEroute);
153  }
static void logwrapper(char *format, va_list argp)
Definition: XrdCephOss.cc:62
void ceph_posix_set_logfunc(void(*logfunc)(char *, va_list argp))
void ceph_posix_set_defaults(const char *value)
XrdSysLogger * logger(XrdSysLogger *lp=0)
Definition: XrdSysError.hh:141
const char * SetPrefix(const char *prefix)
Definition: XrdSysError.hh:160

References ceph_posix_set_defaults(), ceph_posix_set_logfunc(), XrdSysError::logger(), logwrapper(), XrdSysError::Say(), XrdSysError::SetPrefix(), and XrdCephEroute.

Referenced by XrdCephOss::Configure().

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

◆ XrdVERSIONINFO()

XrdVERSIONINFO ( XrdOssGetStorageSystem  ,
XrdCephOss   
)

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