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)
 
virtual int StatFS (const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
 
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 StatLS (XrdOucEnv &env, const char *path, char *buff, int &blen)
 
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)
 

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 84 of file XrdCephOss.cc.

84  {
85  Configure(configfn, Eroute);
86 }
int Configure(const char *, XrdSysError &)
Definition: XrdCephOss.cc:94

References Configure().

+ Here is the call graph for this function:

◆ ~XrdCephOss()

XrdCephOss::~XrdCephOss ( )
virtual

Definition at line 88 of file XrdCephOss.cc.

88  {
90 }
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 157 of file XrdCephOss.cc.

157  {
158  return -ENOTSUP;
159 }

◆ Configure()

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

Definition at line 94 of file XrdCephOss.cc.

94  {
95  int NoGo = 0;
96  XrdOucEnv myEnv;
97  XrdOucStream Config(&Eroute, getenv("XRDINSTANCE"), &myEnv, "=====> ");
98  // If there is no config file, nothing to be done
99  if (configfn && *configfn) {
100  // Try to open the configuration file.
101  int cfgFD;
102  if ((cfgFD = open(configfn, O_RDONLY, 0)) < 0) {
103  Eroute.Emsg("Config", errno, "open config file", configfn);
104  return 1;
105  }
106  Config.Attach(cfgFD);
107  // Now start reading records until eof.
108  char *var;
109  while((var = Config.GetMyFirstWord())) {
110  if (!strncmp(var, "ceph.nbconnections", 18)) {
111  var = Config.GetWord();
112  if (var) {
113  unsigned long value = strtoul(var, 0, 10);
114  if (value > 0 and value <= 100) {
115  g_maxCephPoolIdx = value;
116  } else {
117  Eroute.Emsg("Config", "Invalid value for ceph.nbconnections in config file (must be between 1 and 100)", configfn, var);
118  return 1;
119  }
120  } else {
121  Eroute.Emsg("Config", "Missing value for ceph.nbconnections in config file", configfn);
122  return 1;
123  }
124  }
125  if (!strncmp(var, "ceph.namelib", 12)) {
126  var = Config.GetWord();
127  if (var) {
128  // Warn in case parameters were givne
129  char parms[1040];
130  if (!Config.GetRest(parms, sizeof(parms)) || parms[0]) {
131  Eroute.Emsg("Config", "namelib parameters will be ignored");
132  }
133  // Load name lib
134  XrdOucN2NLoader n2nLoader(&Eroute,configfn,NULL,NULL,NULL);
135  g_namelib = n2nLoader.Load(var, XrdVERSIONINFOVAR(XrdOssGetStorageSystem), NULL);
136  if (!g_namelib) {
137  Eroute.Emsg("Config", "Unable to load library given in ceph.namelib : %s", var);
138  }
139  } else {
140  Eroute.Emsg("Config", "Missing value for ceph.namelib in config file", configfn);
141  return 1;
142  }
143  }
144  }
145 
146  // Now check if any errors occurred during file i/o
147  int retc = Config.LastError();
148  if (retc) {
149  NoGo = Eroute.Emsg("Config", -retc, "read config file",
150  configfn);
151  }
152  Config.Close();
153  }
154  return NoGo;
155 }
XrdOucName2Name * g_namelib
unsigned int g_maxCephPoolIdx
XrdOss * XrdOssGetStorageSystem(XrdOss *native_oss, XrdSysLogger *lp, const char *config_fn, const char *parms)
Definition: XrdCephOss.cc:62
int open(const char *path, int oflag,...)
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(), g_maxCephPoolIdx, g_namelib, XrdOucN2NLoader::Load(), 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 161 of file XrdCephOss.cc.

162  {
163  return -ENOTSUP;
164 }

◆ 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 166 of file XrdCephOss.cc.

166 { 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 169 of file XrdCephOss.cc.

169  {
170  return 0;
171 }

◆ 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 249 of file XrdCephOss.cc.

249  {
250  return new XrdCephOssDir(this);
251 }

◆ 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 253 of file XrdCephOss.cc.

253  {
254  return new XrdCephOssFile(this);
255 }

◆ 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 174 of file XrdCephOss.cc.

174  {
175  return 0;
176 }

◆ 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 178 of file XrdCephOss.cc.

181  {
182  return -ENOTSUP;
183 }

◆ Stat()

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

Return state information on a file or directory.

Parameters
path- Pointer to the path in question.
buff- Pointer to the structure where info it to be returned.
opts- Options: XRDOSS_preop - this is a stat prior to open. XRDOSS_resonly - only look for resident files. XRDOSS_updtatm - update file access time.
envP- Pointer to environmental information.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOss.

Definition at line 185 of file XrdCephOss.cc.

188  {
189  try {
190  if (!strcmp(path, "/")) {
191  // special case of a stat made by the locate interface
192  // we intend to then list all files
193  memset(buff, 0, sizeof(*buff));
194  buff->st_mode = S_IFDIR | 0700;
195  return 0;
196  } else {
197  return ceph_posix_stat(env, path, buff);
198  }
199  } catch (std::exception &e) {
200  XrdCephEroute.Say("stat : invalid syntax in file parameters");
201  return -EINVAL;
202  }
203 }
XrdSysError XrdCephEroute(0)
Definition: XrdCephOss.cc:45
int ceph_posix_stat(XrdOucEnv *env, const char *pathname, struct stat *buf)
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(), XrdSysError::Say(), and XrdCephEroute.

+ 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 205 of file XrdCephOss.cc.

205  {
206  XrdOssVSInfo sP;
207  int rc = StatVS(&sP, 0, 0);
208  if (rc) {
209  return rc;
210  }
211  int percentUsedSpace = (sP.Usage*100)/sP.Total;
212  blen = snprintf(buff, blen, "%d %lld %d %d %lld %d",
213  1, sP.Free, percentUsedSpace, 0, 0LL, 0);
214  return XrdOssOK;
215 }
#define XrdOssOK
Definition: XrdOss.hh:50
virtual int StatVS(XrdOssVSInfo *sP, const char *sname=0, int updt=0)
Definition: XrdCephOss.cc:217
long long Usage
Definition: XrdOssVS.hh:94
long long Total
Definition: XrdOssVS.hh:90
long long Free
Definition: XrdOssVS.hh:91

References XrdOssVSInfo::Free, StatVS(), XrdOssVSInfo::Total, XrdOssVSInfo::Usage, 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 217 of file XrdCephOss.cc.

217  {
218  int rc = ceph_posix_statfs(&(sP->Total), &(sP->Free));
219  if (rc) {
220  return rc;
221  }
222  sP->Large = sP->Total;
223  sP->LFree = sP->Free;
224  sP->Usage = sP->Total-sP->Free;
225  sP->Extents = 1;
226  return XrdOssOK;
227 }
int ceph_posix_statfs(long long *totalSpace, long long *freeSpace)

References ceph_posix_statfs(), XrdOssVSInfo::Extents, XrdOssVSInfo::Free, XrdOssVSInfo::Large, XrdOssVSInfo::LFree, XrdOssVSInfo::Total, XrdOssVSInfo::Usage, 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 229 of file XrdCephOss.cc.

231  {
232  try {
233  return ceph_posix_truncate(env, path, size);
234  } catch (std::exception &e) {
235  XrdCephEroute.Say("truncate : invalid syntax in file parameters");
236  return -EINVAL;
237  }
238 }
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 240 of file XrdCephOss.cc.

240  {
241  try {
242  return ceph_posix_unlink(env, path);
243  } catch (std::exception &e) {
244  XrdCephEroute.Say("unlink : invalid syntax in file parameters");
245  return -EINVAL;
246  }
247 }
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:

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