XRootD
XrdCephOss Class Reference

#include <XrdCephOss.hh>

+ Inheritance diagram for XrdCephOss:
+ Collaboration diagram for XrdCephOss:

Public Member Functions

 XrdCephOss (const char *, XrdSysError &)
 
virtual ~XrdCephOss ()
 
virtual int Chmod (const char *, mode_t mode, XrdOucEnv *eP=0)
 
int Configure (const char *, XrdSysError &)
 
virtual int Create (const char *, const char *, mode_t, XrdOucEnv &, int opts=0)
 
virtual int Init (XrdSysLogger *, const char *)
 
virtual int Mkdir (const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0)
 
virtual XrdOssDFnewDir (const char *tident)
 
virtual XrdOssDFnewFile (const char *tident)
 
virtual int Remdir (const char *, int Opts=0, XrdOucEnv *eP=0)
 
virtual int Rename (const char *, const char *, XrdOucEnv *eP1=0, XrdOucEnv *eP2=0)
 
virtual int Stat (const char *, struct stat *, int opts=0, XrdOucEnv *eP=0)
 Return status information for an object ID. More...
 
virtual int StatFS (const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
 
virtual int StatLS (XrdOucEnv &env, const char *path, char *buff, int &blen)
 Report on disk space use in this pool. More...
 
virtual int StatVS (XrdOssVSInfo *sP, const char *sname=0, int updt=0)
 
virtual int Truncate (const char *, unsigned long long, XrdOucEnv *eP=0)
 
virtual int Unlink (const char *path, int Opts=0, XrdOucEnv *eP=0)
 
- Public Member Functions inherited from XrdOss
 XrdOss ()
 Constructor and Destructor. More...
 
virtual ~XrdOss ()
 
virtual void Connect (XrdOucEnv &env)
 
virtual void Disc (XrdOucEnv &env)
 
virtual void EnvInfo (XrdOucEnv *envP)
 
virtual uint64_t Features ()
 
virtual int FSctl (int cmd, int alen, const char *args, char **resp=0)
 
virtual int Init (XrdSysLogger *lp, const char *cfn, XrdOucEnv *envP)
 
virtual int Lfn2Pfn (const char *Path, char *buff, int blen)
 
virtual const char * Lfn2Pfn (const char *Path, char *buff, int blen, int &rc)
 
virtual int Reloc (const char *tident, const char *path, const char *cgName, const char *anchor=0)
 
virtual int StatPF (const char *path, struct stat *buff)
 
virtual int StatPF (const char *path, struct stat *buff, int opts)
 
virtual int Stats (char *buff, int blen)
 
virtual int StatXA (const char *path, char *buff, int &blen, XrdOucEnv *envP=0)
 
virtual int StatXP (const char *path, unsigned long long &attr, XrdOucEnv *envP=0)
 

Public Attributes

int m_useDefaultPreadAlg = 0
 
int m_useDefaultReadvAlg = 0
 

Additional Inherited Members

- Static Public Attributes inherited from XrdOss
static const int PF_csVer = 0x00000001
 verified file checksums present More...
 
static const int PF_csVun = 0x00000002
 unverified file checksums present More...
 
static const int PF_dInfo = 0x00000001
 
static const int PF_dNums = 0x00000002
 
static const int PF_dStat = 0x00000008
 
static const int PF_isLFN = 0x00000004
 

Detailed Description

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.

Definition at line 55 of file XrdCephOss.hh.

Constructor & Destructor Documentation

◆ XrdCephOss()

XrdCephOss::XrdCephOss ( const char *  configfn,
XrdSysError Eroute 
)

Definition at line 156 of file XrdCephOss.cc.

156  {
157  Configure(configfn, Eroute);
158 }
int Configure(const char *, XrdSysError &)
Definition: XrdCephOss.cc:168

References Configure().

+ Here is the call graph for this function:

◆ ~XrdCephOss()

XrdCephOss::~XrdCephOss ( )
virtual

Definition at line 160 of file XrdCephOss.cc.

160  {
162 }
void ceph_posix_disconnect_all()

References ceph_posix_disconnect_all().

+ Here is the call graph for this function:

Member Function Documentation

◆ Chmod()

int XrdCephOss::Chmod ( const char *  path,
mode_t  mode,
XrdOucEnv envP = 0 
)
virtual

Change file mode settings.

Parameters
path- Pointer to the path of the file in question.
mode- The new file mode setting.
envP- Pointer to environmental information.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOss.

Definition at line 381 of file XrdCephOss.cc.

381  {
382  return -ENOTSUP;
383 }

◆ Configure()

int XrdCephOss::Configure ( const char *  configfn,
XrdSysError Eroute 
)

Definition at line 168 of file XrdCephOss.cc.

168  {
169  int NoGo = 0;
170  XrdOucEnv myEnv;
171  XrdOucStream Config(&Eroute, getenv("XRDINSTANCE"), &myEnv, "=====> ");
172  //disable posc
173  XrdOucEnv::Export("XRDXROOTD_NOPOSC", "1");
174  // If there is no config file, nothing to be done
175  if (configfn && *configfn) {
176  // Try to open the configuration file.
177  int cfgFD;
178  if ((cfgFD = open(configfn, O_RDONLY, 0)) < 0) {
179  Eroute.Emsg("Config", errno, "open config file", configfn);
180  return 1;
181  }
182  Config.Attach(cfgFD);
183  // Now start reading records until eof.
184  char *var;
185  while((var = Config.GetMyFirstWord())) {
186  if (!strncmp(var, "ceph.nbconnections", 18)) {
187  var = Config.GetWord();
188  if (var) {
189  unsigned long value = strtoul(var, 0, 10);
190  if (value > 0 and value <= 100) {
191  g_maxCephPoolIdx = value;
192  } else {
193  Eroute.Emsg("Config", "Invalid value for ceph.nbconnections in config file (must be between 1 and 100)", configfn, var);
194  return 1;
195  }
196  } else {
197  Eroute.Emsg("Config", "Missing value for ceph.nbconnections in config file", configfn);
198  return 1;
199  }
200  }
201  if (!strncmp(var, "ceph.namelib", 12)) {
202  var = Config.GetWord();
203  if (var) {
204  std::string libname = var;
205  // Warn in case parameters were givne
206  char parms[1040];
207  bool hasParms{false};
208  if (!Config.GetRest(parms, sizeof(parms)) || parms[0]) {
209  hasParms = true;
210  }
211  // Load name lib
212  XrdOucN2NLoader n2nLoader(&Eroute,configfn,(hasParms?parms:""),NULL,NULL);
213  g_namelib = n2nLoader.Load(libname.c_str(), XrdVERSIONINFOVAR(XrdOssGetStorageSystem), NULL);
214  if (!g_namelib) {
215  Eroute.Emsg("Config", "Unable to load library given in ceph.namelib : %s", var);
216  }
217  } else {
218  Eroute.Emsg("Config", "Missing value for ceph.namelib in config file ", configfn);
219  return 1;
220  }
221  }
222 
223  int pread_flag_set = !strncmp(var, "ceph.usedefaultpreadalg", 24);
224  int readv_flag_set = !strncmp(var, "ceph.usedefaultreadvalg", 24);
225  if (pread_flag_set or readv_flag_set) {
226  var = Config.GetWord();
227  if (var) {
228  char* endptr;
229  long value = strtol(var, &endptr, 10);
230  if ((value == 0 || value == 1) && (var != endptr)) {
231  if (pread_flag_set) {
232  m_useDefaultPreadAlg = value;
233  } else if(readv_flag_set) {
234  m_useDefaultReadvAlg = value;
235  } else {
236  Eroute.Emsg("Config", "Bug encountered during parsing", var);
237  }
238  } else {
239  Eroute.Emsg("Config", "Invalid value for ceph.usedefault* in config file -- must be 0 or 1, got", var);
240  return 1;
241  }
242  } else {
243  Eroute.Emsg("Config", "Missing value for ceph.usedefault* in config file");
244  return 1;
245  }
246  }
247 
248  if (!strncmp(var, "ceph.aiowaitthresh", 19)) {
249  var = Config.GetWord();
250  if (var) {
251  unsigned long value = strtoul(var, 0, 10);
252  if ((value > 0) && (value < INT_MAX)){
253  g_cephAioWaitThresh = value;
254  } else {
255  Eroute.Emsg("Config", "Invalid value for ceph.aiowaitthresh:", var);
256  }
257  } else {
258  Eroute.Emsg("Config", "Missing value for ceph.aiowaitthresh in config file");
259  return 1;
260  }
261  }
262 
263  if (!strncmp(var, "ceph.usebuffer", 14)) { // allowable values: 0, 1
264  var = Config.GetWord();
265  if (var) {
266  unsigned long value = strtoul(var, 0, 10);
267  if (value <= 1) {
268  m_configBufferEnable = value;
269  Eroute.Emsg("Config", "ceph.usebuffer",std::to_string(m_configBufferEnable).c_str());
270  } else {
271  Eroute.Emsg("Config", "Invalid value for ceph.usebuffer in config file (must be 0 or 1)", configfn, var);
272  return 1;
273  }
274  } else {
275  Eroute.Emsg("Config", "Missing value for ceph.usebuffer in config file", configfn);
276  return 1;
277  }
278  } // usebuffer
279  if (!strncmp(var, "ceph.buffersize", 15)) { // size in bytes
280  var = Config.GetWord();
281  if (var) {
282  unsigned long value = strtoul(var, 0, 10);
283  if (value > 0 and value <= 1000000000L) {
284  m_configBufferSize = value;
285  Eroute.Emsg("Config", "ceph.buffersize", std::to_string(m_configBufferSize).c_str() );
286  } else {
287  Eroute.Emsg("Config", "Invalid value for ceph.buffersize in config file; enter in bytes (no units)", configfn, var);
288  return 1;
289  }
290  } else {
291  Eroute.Emsg("Config", "Missing value for ceph.buffersize in config file", configfn);
292  return 1;
293  }
294  } // buffersize
295  if (!strncmp(var, "ceph.buffermaxpersimul", 22)) { // size in bytes
296  var = Config.GetWord();
297  if (var) {
298  unsigned long value = strtoul(var, 0, 10);
299  if (value > 0 and value <= 1000000000L) {
300  m_configMaxSimulBufferCount = value;
301  Eroute.Emsg("Config", "ceph.buffermaxpersimul", std::to_string(m_configMaxSimulBufferCount).c_str() );
302  } else {
303  Eroute.Emsg("Config", "Invalid value for ceph.buffermaxpersimul in config file; enter in bytes (no units)", configfn, var);
304  return 1;
305  }
306  } else {
307  Eroute.Emsg("Config", "Missing value for ceph.buffermaxpersimul in config file", configfn);
308  return 1;
309  }
310  } // buffersize
311 
312  if (!strncmp(var, "ceph.usereadv", 13)) { // allowable values: 0, 1
313  var = Config.GetWord();
314  if (var) {
315  unsigned long value = strtoul(var, 0, 10);
316  if (value <= 1) {
317  m_configReadVEnable = value;
318  Eroute.Emsg("Config", "ceph.usereadvalg",std::to_string(m_configBufferEnable).c_str());
319  } else {
320  Eroute.Emsg("Config", "Invalid value for ceph.usereadv in config file (must be 0 or 1)", configfn, var);
321  return 1;
322  }
323  } else {
324  Eroute.Emsg("Config", "Missing value for ceph.usereadv in config file", configfn);
325  return 1;
326  }
327  } // usereadv
328  if (!strncmp(var, "ceph.readvalgname", 17)) {
329  var = Config.GetWord();
330  // Eroute.Emsg("Config", "readvalgname readvalgname readvalgname readvalgname", var);
331  if (var) {
332  // Warn in case parameters were givne
333  char parms[1040];
334  if (!Config.GetRest(parms, sizeof(parms)) || parms[0]) {
335  Eroute.Emsg("Config", "readvalgname parameters will be ignored");
336  }
337  m_configReadVAlgName = var;
338  } else {
339  Eroute.Emsg("Config", "Missing value for ceph.readvalgname in config file", configfn);
340  return 1;
341  }
342  }
343  if (!strncmp(var, "ceph.bufferiomode", 17)) {
344  var = Config.GetWord();
345  if (var) {
346  // Warn in case parameters were givne
347  char parms[1040];
348  if (!Config.GetRest(parms, sizeof(parms)) || parms[0]) {
349  Eroute.Emsg("Config", "readvalgname parameters will be ignored");
350  }
351  m_configBufferIOmode = var; // allowed values would be aio, io
352  } else {
353  Eroute.Emsg("Config", "Missing value for ceph.bufferiomode in config file", configfn);
354  return 1;
355  }
356  }
357 
358  if (!strcmp(var, "ceph.reportingpools")) {
359  var = Config.GetWord();
360  if (var) {
361  m_configPoolnames = var;
362  } else {
363  Eroute.Emsg("Config", "Missing value for ceph.reportingpools in config file", configfn);
364  return 1;
365  }
366  }
367  } // while
368 
369  // Now check if any errors occurred during file i/o
370 
371  int retc = Config.LastError();
372  if (retc) {
373  NoGo = Eroute.Emsg("Config", -retc, "read config file",
374  configfn);
375  }
376  Config.Close();
377  }
378  return NoGo;
379 }
XrdOucName2Name * g_namelib
Definition: XrdCephPosix.cc:98
unsigned int g_maxCephPoolIdx
Definition: XrdCephPosix.cc:95
XrdOss * XrdOssGetStorageSystem(XrdOss *native_oss, XrdSysLogger *lp, const char *config_fn, const char *parms)
Definition: XrdCephOss.cc:134
unsigned int g_cephAioWaitThresh
Definition: XrdCephPosix.cc:91
int open(const char *path, int oflag,...)
int m_useDefaultPreadAlg
Definition: XrdCephOss.hh:78
int m_useDefaultReadvAlg
Definition: XrdCephOss.hh:80
static int Export(const char *Var, const char *Val)
Definition: XrdOucEnv.cc:188
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95
XrdCmsConfig Config

References XrdCms::Config, XrdSysError::Emsg(), XrdOucEnv::Export(), g_cephAioWaitThresh, g_maxCephPoolIdx, g_namelib, XrdOucN2NLoader::Load(), m_useDefaultPreadAlg, m_useDefaultReadvAlg, open(), and XrdOssGetStorageSystem().

Referenced by XrdCephOss().

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

◆ Create()

int XrdCephOss::Create ( const char *  tid,
const char *  path,
mode_t  mode,
XrdOucEnv env,
int  opts = 0 
)
virtual

Create file.

Parameters
tid- Pointer to the trace identifier.
path- Pointer to the path of the file to create.
mode- The new file mode setting.
env- Reference to environmental information.
opts- Create options: XRDOSS_mkpath - create dir path if it does not exist. XRDOSS_new - the file must not already exist. oflags<<8 - open flags shifted 8 bits to the left/
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOss.

Definition at line 385 of file XrdCephOss.cc.

386  {
387  return -ENOTSUP;
388 }

◆ Init()

int XrdCephOss::Init ( XrdSysLogger lp,
const char *  cfn 
)
virtual

Initialize the storage system V1 (deprecated).

Parameters
lp- Pointer to the message logging object.
cfn- Pointer to the configuration file.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOss.

Definition at line 390 of file XrdCephOss.cc.

390 { return 0; }

◆ Mkdir()

int XrdCephOss::Mkdir ( const char *  path,
mode_t  mode,
int  mkpath = 0,
XrdOucEnv envP = 0 
)
virtual

Create a directory.

Parameters
path- Pointer to the path of the directory to be created.
mode- The directory mode setting.
mkpath- When true the path is created if it does not exist.
envP- Pointer to environmental information.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOss.

Definition at line 393 of file XrdCephOss.cc.

393  {
394  return 0;
395 }

◆ newDir()

XrdOssDF * XrdCephOss::newDir ( const char *  tident)
virtual

Obtain a new director object to be used for future directory requests.

Parameters
tident- The trace identifier.
Returns
pointer- Pointer to an XrdOssDF object.
nil - Insufficient memory to allocate an object.

Implements XrdOss.

Definition at line 658 of file XrdCephOss.cc.

658  {
659  return new XrdCephOssDir(this);
660 }

◆ newFile()

XrdOssDF * XrdCephOss::newFile ( const char *  tident)
virtual

Obtain a new file object to be used for a future file requests.

Parameters
tident- The trace identifier.
Returns
pointer- Pointer to an XrdOssDF object.
nil - Insufficient memory to allocate an object.

Implements XrdOss.

Definition at line 662 of file XrdCephOss.cc.

662  {
663 
664  // Depending on the configuration settings stack up the underlying
665  // XrdCephOssFile instance with decorator objects for readV and Buffering requests
666 
667  XrdCephOssFile* xrdCephOssDF = new XrdCephOssFile(this);
668 
669  if (m_configReadVEnable) {
670  xrdCephOssDF = new XrdCephOssReadVFile(this,xrdCephOssDF,m_configReadVAlgName);
671  }
672 
673  if (m_configBufferEnable) {
674  xrdCephOssDF = new XrdCephOssBufferedFile(this,xrdCephOssDF, m_configBufferSize,
675  m_configBufferIOmode, m_configMaxSimulBufferCount);
676  }
677 
678 
679  return xrdCephOssDF;
680 }

◆ Remdir()

int XrdCephOss::Remdir ( const char *  path,
int  Opts = 0,
XrdOucEnv envP = 0 
)
virtual

Remove a directory.

Parameters
path- Pointer to the path of the directory to be removed.
Opts- The processing options: XRDOSS_Online - only remove online copy XRDOSS_isPFN - path is already translated.
envP- Pointer to environmental information.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOss.

Definition at line 398 of file XrdCephOss.cc.

398  {
399  return 0;
400 }

◆ Rename()

int XrdCephOss::Rename ( const char *  oPath,
const char *  nPath,
XrdOucEnv oEnvP = 0,
XrdOucEnv nEnvP = 0 
)
virtual

Rename a file or directory.

Parameters
oPath- Pointer to the path to be renamed.
nPath- Pointer to the path oPath is to have.
oEnvP- Environmental information for oPath.
nEnvP- Environmental information for nPath.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOss.

Definition at line 402 of file XrdCephOss.cc.

405  {
406  return -ENOTSUP;
407 }

◆ Stat()

int XrdCephOss::Stat ( const char *  path,
struct stat buff,
int  opts = 0,
XrdOucEnv env = 0 
)
virtual

Return status information for an object ID.

Populate a struct stat* with information on an object ID. Determine whether the request relates to a pool name for disk space reporting via StatLS. If not, handle an object path or the notional root element "/"

Parameters
(in)path the object ID
(out)buff receive the status information
(in)opts not used
(in)env not used

Implementation of enhancements: Jyothish Thomas STFC RAL, jyoth.nosp@m.ish..nosp@m.thoma.nosp@m.s@st.nosp@m.fc.ac.nosp@m..uk, 2022 Ian Johnson STFC RAL, ian.j.nosp@m.ohns.nosp@m.on@st.nosp@m.fc.a.nosp@m.c.uk, 2022, 2023

Implements XrdOss.

Definition at line 454 of file XrdCephOss.cc.

457  {
458 
459  XrdCephEroute.Say(__FUNCTION__, " path = ", path);
460 
461  std::string spath {path};
462  m_translateFileName(spath,path);
463 
464  if (spath.back() == '/') { // Request to stat the root
465 
466 
467 #ifdef STAT_TRACE
468  XrdCephEroute.Say(__FUNCTION__, " - fake a return for stat'ing root element '/'");
469 #endif
470 
471 
472  // special case of a stat made by the locate interface
473  // we intend to then list all files
474 
475  memset(buff, 0, sizeof(*buff));
476 
477  buff->st_mode = S_IFDIR|S_IRWXU;
478  buff->st_dev = 1;
479  buff->st_ino = 1;
480 
481  return XrdOssOK;
482 
483  }
484 
485  if (spath.find_first_of(":") == spath.length()-1) { // Request to stat just the pool name
486 
487 #ifdef STAT_TRACE
488  XrdCephEroute.Say(__FUNCTION__, "Found request to stat pool name");
489 #endif
490 
491  spath.pop_back(); // remove colon from pool name
492  if (m_configPoolnames.find(spath) != std::string::npos) { // Support 'locate' for spaceinfo
493 #ifdef STAT_TRACE
494  XrdCephEroute.Say(__FUNCTION__, " - preparing spaceinfo report for '", path, "'");
495 #endif
496  return XrdOssOK; // Only requires a status code, do not need to fill contents in struct stat
497  } else {
498  XrdCephEroute.Say(__FUNCTION__, " - cannot find pool '", path, "' in ceph.reportingpools");
499  return -EINVAL;
500  }
501 
502 
503  } else if (ceph_posix_stat(env, path, buff) == 0) { // Found object ID
504 
505 #ifdef STAT_TRACE
506  XrdCephEroute.Say(__FUNCTION__, " - found object ", spath.c_str(), " via ceph_posix_stat");
507 #endif
508  return XrdOssOK;
509 
510  } else {
511 
512 #ifdef STAT_TRACE
513  XrdCephEroute.Say(__FUNCTION__, " - cannot find object '", spath.c_str(), "'");
514 #endif
515  return -ENOENT;
516 
517  }
518 
519 
520 }
void m_translateFileName(std::string &physName, std::string logName)
converts a logical filename to physical one if needed
Definition: XrdCephOss.cc:74
XrdSysError XrdCephEroute(0)
Definition: XrdCephOss.cc:50
int ceph_posix_stat(XrdOucEnv *env, const char *pathname, struct stat *buf)
#define XrdOssOK
Definition: XrdOss.hh: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 ceph_posix_stat(), m_translateFileName(), XrdSysError::Say(), XrdCephEroute, and XrdOssOK.

+ Here is the call graph for this function:

◆ StatFS()

int XrdCephOss::StatFS ( const char *  path,
char *  buff,
int &  blen,
XrdOucEnv envP = 0 
)
virtual

Return filesystem physical space information associated with a path.

Parameters
path- Path in the partition in question.
buff- Pointer to the buffer to hold the information.
blen- Length of the buffer. This is updated with the actual number of bytes placed in the buffer as in snprintf().
envP- Pointer to environmental information.
Returns
"<wval> <fsp> <utl> <sval> <fsp> <utl>" where: <wval> is "0" if XRDEXP_NOTRW specified, otherwise "1" <fsp> is free space in megabytes. <utl> is percentage utilization (i.e. allocated space) <sval> is "1' if XRDEXP_STAGE specified, otherwise "0" Upon failure -errno or -osserr (see XrdOssError.hh) returned.

Reimplemented from XrdOss.

Definition at line 524 of file XrdCephOss.cc.

524  {
525 
526 #ifdef STAT_TRACE
527  XrdCephEroute.Say(__FUNCTION__, " path = ", path);
528 #endif
529  XrdOssVSInfo sP;
530  int rc = StatVS(&sP, 0, 0);
531  if (rc) {
532  return rc;
533  }
534  int percentUsedSpace = (sP.Usage*100)/sP.Total;
535  blen = snprintf(buff, blen, "%d %lld %d %d %lld %d",
536  1, sP.Free, percentUsedSpace, 0, 0LL, 0);
537  return XrdOssOK;
538 }
virtual int StatVS(XrdOssVSInfo *sP, const char *sname=0, int updt=0)
Definition: XrdCephOss.cc:540
long long Usage
Definition: XrdOssVS.hh:94
long long Total
Definition: XrdOssVS.hh:90
long long Free
Definition: XrdOssVS.hh:91

References XrdOssVSInfo::Free, XrdSysError::Say(), StatVS(), XrdOssVSInfo::Total, XrdOssVSInfo::Usage, XrdCephEroute, and XrdOssOK.

+ Here is the call graph for this function:

◆ StatLS()

int XrdCephOss::StatLS ( XrdOucEnv env,
const char *  charPath,
char *  buff,
int &  blen 
)
virtual

Report on disk space use in this pool.

Handle a request for the amount of space used in a Ceph pool

Parameters
(in)env not used
(in)path name of the pool
(out)buff location for string containing OSS key-value pairs for disk space used, free, etc
(out)blen set to length of buff

Implementation: Jyothish Thomas STFC RAL, jyoth.nosp@m.ish..nosp@m.thoma.nosp@m.s@st.nosp@m.fc.ac.nosp@m..uk, 2022 Ian Johnson STFC RAL, ian.j.nosp@m.ohns.nosp@m.on@st.nosp@m.fc.a.nosp@m.c.uk, 2022, 2023

Reimplemented from XrdOss.

Definition at line 581 of file XrdCephOss.cc.

582 {
583  XrdCephEroute.Say(__FUNCTION__, " incoming path = ", charPath);
584 
585  std::string path(charPath);
586  path = extractPool(path);
587  std::string spath {path};
588 
589  m_translateFileName(spath,path);
590 
591 //
592 // Following test is now redundant as we take the substring up to colonPos
593 //
594 
595  if (spath.back() == ':') {
596  spath.pop_back();
597  }
598  if (m_configPoolnames.find(spath) == std::string::npos) {
599  XrdCephEroute.Say("Can't report on ", spath.c_str());
600  return -EINVAL;
601  }
602 
603  long long usedSpace, totalSpace, freeSpace;
604 
605  if (ceph_posix_stat_pool(spath.c_str(), &usedSpace) != 0) {
606  XrdCephEroute.Say("Failed to get used space in pool ", spath.c_str());
607  return -EINVAL;
608  }
609 
610  // Construct the object path
611  std::string spaceInfoPath = spath + ":" + (const char *)"__spaceinfo__";
612  totalSpace = getNumericAttr(spaceInfoPath.c_str(), "total_space", 24);
613  if (totalSpace < 0) {
614  XrdCephEroute.Say("Could not get 'total_space' attribute from ", spaceInfoPath.c_str());
615  return -EINVAL;
616  }
617 
618 //
619 // Figure for 'usedSpace' already accounts for Erasure Coding overhead
620 //
621 
622 
623  freeSpace = totalSpace - usedSpace;
624  blen = formatStatLSResponse(buff, blen,
625  spath.c_str(), /* "oss.cgroup" */
626  totalSpace, /* "oss.space" */
627  usedSpace, /* "oss.used" */
628  freeSpace, /* "oss.free" */
629  totalSpace, /* "oss.quota" */
630  freeSpace /* "oss.maxf" */);
631 #ifdef STAT_TRACE
632  XrdCephEroute.Say(__FUNCTION__, "space info = \n", buff);
633 #endif
634  return XrdOssOK;
635 
636 }
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: XrdCephOss.cc:556
ssize_t getNumericAttr(const char *const path, const char *attrName, const int maxAttrLen)
Retrieve an integer-value extended attribute.
Definition: XrdCephOss.cc:104
std::string extractPool(std::string possPool)
Extract a pool name (string before the first colon ':') from an object ID.
Definition: XrdCephOss.cc:421
int ceph_posix_stat_pool(char const *poolName, long long *usedSpace)
Return the amount of space used in a pool.

References ceph_posix_stat_pool(), extractPool(), formatStatLSResponse(), getNumericAttr(), m_translateFileName(), XrdSysError::Say(), XrdCephEroute, and XrdOssOK.

+ Here is the call graph for this function:

◆ StatVS()

int XrdCephOss::StatVS ( XrdOssVSInfo vsP,
const char *  sname = 0,
int  updt = 0 
)
virtual

Return space information for a space name.

Parameters
vsP- Pointer to the XrdOssVSInfo object to hold results. It should be fully initialized (i.e. a new copy).
sname- Pointer to the space name. If the name starts with a plus (e.g. "+public"), partition information is returned, should it exist. If nil, space information for all spaces is returned. See, XrdOssVS.hh for more info.
updt- When true, a space update occurrs prior to a query.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOss.

Definition at line 540 of file XrdCephOss.cc.

540  {
541 
542 #ifdef STAT_TRACE
543  XrdCephEroute.Say(__FUNCTION__, " path = ", sname);
544 #endif
545  int rc = ceph_posix_statfs(&(sP->Total), &(sP->Free));
546  if (rc) {
547  return rc;
548  }
549  sP->Large = sP->Total;
550  sP->LFree = sP->Free;
551  sP->Usage = sP->Total-sP->Free;
552  sP->Extents = 1;
553  return XrdOssOK;
554 }
int ceph_posix_statfs(long long *totalSpace, long long *freeSpace)

References ceph_posix_statfs(), XrdOssVSInfo::Extents, XrdOssVSInfo::Free, XrdOssVSInfo::Large, XrdOssVSInfo::LFree, XrdSysError::Say(), XrdOssVSInfo::Total, XrdOssVSInfo::Usage, XrdCephEroute, and XrdOssOK.

Referenced by StatFS().

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

◆ Truncate()

int XrdCephOss::Truncate ( const char *  path,
unsigned long long  fsize,
XrdOucEnv envP = 0 
)
virtual

Truncate a file.

Parameters
path- Pointer to the path of the file to be truncated.
fsize- The size that the file is to have.
envP- Pointer to environmental information.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOss.

Definition at line 638 of file XrdCephOss.cc.

640  {
641  try {
642  return ceph_posix_truncate(env, path, size);
643  } catch (std::exception &e) {
644  XrdCephEroute.Say("truncate : invalid syntax in file parameters");
645  return -EINVAL;
646  }
647 }
int ceph_posix_truncate(XrdOucEnv *env, const char *pathname, unsigned long long size)

References ceph_posix_truncate(), XrdSysError::Say(), and XrdCephEroute.

+ Here is the call graph for this function:

◆ Unlink()

int XrdCephOss::Unlink ( const char *  path,
int  Opts = 0,
XrdOucEnv envP = 0 
)
virtual

Remove a file.

Parameters
path- Pointer to the path of the file to be removed.
Opts- Options: XRDOSS_isMIG - this is a migratable path. XRDOSS_isPFN - do not apply name2name to path. XRDOSS_Online - remove only the online copy.
envP- Pointer to environmental information.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOss.

Definition at line 649 of file XrdCephOss.cc.

649  {
650  try {
651  return ceph_posix_unlink(env, path);
652  } catch (std::exception &e) {
653  XrdCephEroute.Say("unlink : invalid syntax in file parameters");
654  return -EINVAL;
655  }
656 }
int ceph_posix_unlink(XrdOucEnv *env, const char *pathname)

References ceph_posix_unlink(), XrdSysError::Say(), and XrdCephEroute.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_useDefaultPreadAlg

int XrdCephOss::m_useDefaultPreadAlg = 0

◆ m_useDefaultReadvAlg

int XrdCephOss::m_useDefaultReadvAlg = 0

Definition at line 80 of file XrdCephOss.hh.

Referenced by Configure(), and XrdCephOssFile::ReadV().


The documentation for this class was generated from the following files: