XRootD
XrdOssCsi Class Reference

#include <XrdOssCsi.hh>

+ Inheritance diagram for XrdOssCsi:
+ Collaboration diagram for XrdOssCsi:

Public Member Functions

 XrdOssCsi (XrdOss *successor)
 
virtual ~XrdOssCsi ()
 
virtual int Chmod (const char *path, mode_t mode, XrdOucEnv *envP=0)
 
virtual int Create (const char *tident, const char *path, mode_t access_mode, XrdOucEnv &env, int Opts=0)
 
virtual uint64_t Features ()
 
int Init (XrdSysLogger *, const char *, const char *, XrdOucEnv *)
 
virtual int Init (XrdSysLogger *lp, const char *cfn)
 
virtual int Init (XrdSysLogger *lp, const char *cfn, XrdOucEnv *envP)
 
virtual int Mkdir (const char *path, mode_t mode, int mkpath=0, XrdOucEnv *envP=0)
 
virtual XrdOssDFnewDir (const char *tident)
 
virtual XrdOssDFnewFile (const char *tident)
 
virtual int Reloc (const char *tident, const char *path, const char *cgName, const char *anchor=0)
 
virtual int Remdir (const char *path, int Opts=0, XrdOucEnv *eP=0)
 
virtual int Rename (const char *oldname, const char *newname, XrdOucEnv *old_env=0, XrdOucEnv *new_env=0)
 
virtual int Stat (const char *path, struct stat *buff, int opts=0, XrdOucEnv *EnvP=0)
 
virtual int StatPF (const char *path, struct stat *buff)
 
virtual int StatPF (const char *path, struct stat *buff, int opts)
 
virtual int StatXA (const char *path, char *buff, int &blen, XrdOucEnv *envP=0)
 
virtual int Truncate (const char *path, unsigned long long size, XrdOucEnv *envP=0)
 
virtual int Unlink (const char *path, int Opts=0, XrdOucEnv *eP=0)
 
- Public Member Functions inherited from XrdOssHandler
 XrdOssHandler (XrdOss *successor)
 
virtual ~XrdOssHandler ()
 
virtual void Connect (XrdOucEnv &env)
 
virtual void Disc (XrdOucEnv &env)
 
virtual void EnvInfo (XrdOucEnv *envP)
 
virtual int FSctl (int cmd, int alen, const char *args, char **resp=0)
 
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 StatFS (const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
 
virtual int StatLS (XrdOucEnv &env, const char *cgrp, char *buff, int &blen)
 
virtual int Stats (char *bp, int bl)
 
virtual int StatVS (XrdOssVSInfo *sP, const char *sname=0, int updt=0)
 
virtual int StatXP (const char *path, unsigned long long &attr, XrdOucEnv *eP=0)
 
- Public Member Functions inherited from XrdOss
 XrdOss ()
 Constructor and Destructor. More...
 
virtual ~XrdOss ()
 

Static Public Member Functions

static std::unique_ptr< XrdOucEnvtagOpenEnv (const XrdOssCsiConfig &, XrdOucEnv &)
 

Static Public Attributes

static XrdSchedulerSched_
 
- 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
 

Additional Inherited Members

- Protected Attributes inherited from XrdOssHandler
XrdOsssuccessor_
 

Detailed Description

Definition at line 180 of file XrdOssCsi.hh.

Constructor & Destructor Documentation

◆ XrdOssCsi()

XrdOssCsi::XrdOssCsi ( XrdOss successor)
inline

Definition at line 211 of file XrdOssCsi.hh.

211 : XrdOssHandler(successor) { }
XrdOssHandler(XrdOss *successor)

◆ ~XrdOssCsi()

virtual XrdOssCsi::~XrdOssCsi ( )
inlinevirtual

Definition at line 212 of file XrdOssCsi.hh.

212 { }

Member Function Documentation

◆ Chmod()

int XrdOssCsi::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).

Reimplemented from XrdOssHandler.

Definition at line 391 of file XrdOssCsi.cc.

392 {
393  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
394  return successor_->Chmod(path, mode, envP);
395 }
bool isTagFile(const char *path)
XrdOss * successor_
virtual int Chmod(const char *path, mode_t mode, XrdOucEnv *envP=0)=0
XrdOucEnv * envP
Definition: XrdPss.cc:109

References XrdOss::Chmod(), XrdProxy::envP, TagPath::isTagFile(), XrdOssHandler::successor_, and XrdOssCsiConfig::tagParam_.

+ Here is the call graph for this function:

◆ Create()

int XrdOssCsi::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).

Reimplemented from XrdOssHandler.

Definition at line 317 of file XrdOssCsi.cc.

319 {
320  // tident starting with '*' is a special case to bypass OssCsi
321  if (tident && *tident == '*')
322  {
323  return successor_->Create(tident, path, access_mode, env, Opts);
324  }
325 
326  if (config_.tagParam_.isTagFile(path)) return -EACCES;
327 
328  // get mapinfo entries for file
329  std::shared_ptr<XrdOssCsiFile::puMapItem_t> pmi;
330  {
331  const std::string tpath = config_.tagParam_.makeTagFilename(path);
332  XrdOssCsiFile::mapTake(tpath, pmi);
333  }
334 
335  XrdSysMutexHelper lck(pmi->mtx);
336  if (pmi->unlinked)
337  {
338  XrdOssCsiFile::mapRelease(pmi,&lck);
339  return Create(tident, path, access_mode, env, Opts);
340  }
341 
342  const bool isTrunc = ((Opts>>8)&O_TRUNC) ? true : false;
343  const bool isExcl = ((Opts&XRDOSS_new) || ((Opts>>8)&O_EXCL)) ? true : false;
344 
345  if (isTrunc && pmi->pages)
346  {
347  // truncate of already open file at open() not supported
348  XrdOssCsiFile::mapRelease(pmi, &lck);
349  return -EDEADLK;
350  }
351 
352  // create file: require it not to exist (unless we're truncating) so that
353  // we can tell if we have a zero length file without stat in more cases
354 
355  const int exflags = isTrunc ? 0 : ((O_EXCL<<8)|XRDOSS_new);
356 
357  int ret = successor_->Create(tident, path, access_mode, env, Opts | exflags);
358  if (ret == XrdOssOK || ret == -EEXIST)
359  {
360  // success from trunc/exclusive create means the file must now be zero length
361  bool zlen = (ret == XrdOssOK) ? true : false;
362  struct stat sbuf;
363  if (!zlen && successor_->Stat(path, &sbuf, 0, &env) == XrdOssOK)
364  {
365  // had to check file size
366  if (sbuf.st_size == 0)
367  {
368  zlen = true;
369  }
370  }
371 
372  // If datafile is zero length try to make empty tag file
373  if (zlen)
374  {
375  const std::string tpath = config_.tagParam_.makeTagFilename(path);
376  const int flags = O_RDWR|O_CREAT|O_TRUNC;
377  const int cropts = XRDOSS_mkpath;
378 
379  std::unique_ptr<XrdOucEnv> tagEnv = tagOpenEnv(config_, env);
380 
381  ret = successor_->Create(tident, tpath.c_str(), 0666, *tagEnv, (flags<<8)|cropts);
382  }
383  }
384 
385  XrdOssCsiFile::mapRelease(pmi, &lck);
386 
387  // may not need to return EEXIST
388  return (ret==-EEXIST && !isExcl) ? XrdOssOK : ret;
389 }
#define tident
#define XrdOssOK
Definition: XrdOss.hh:50
#define XRDOSS_new
Definition: XrdOss.hh:467
#define XRDOSS_mkpath
Definition: XrdOss.hh:466
#define stat(a, b)
Definition: XrdPosix.hh:101
std::string makeTagFilename(const char *path)
static void mapTake(const std::string &, std::shared_ptr< puMapItem_t > &, bool create=true)
static int mapRelease(std::shared_ptr< puMapItem_t > &, XrdSysMutexHelper *plck=NULL)
static std::unique_ptr< XrdOucEnv > tagOpenEnv(const XrdOssCsiConfig &, XrdOucEnv &)
Definition: XrdOssCsi.cc:470
virtual int Create(const char *tident, const char *path, mode_t access_mode, XrdOucEnv &env, int Opts=0)
Definition: XrdOssCsi.cc:317
virtual int Create(const char *tid, const char *path, mode_t mode, XrdOucEnv &env, int opts=0)=0
virtual int Stat(const char *path, struct stat *buff, int opts=0, XrdOucEnv *envP=0)=0
int Opts
Definition: XrdMpxStats.cc:58

References XrdOss::Create(), TagPath::isTagFile(), TagPath::makeTagFilename(), XrdOssCsiFile::mapRelease(), XrdOssCsiFile::mapTake(), XrdMpx::Opts, stat, XrdOss::Stat(), XrdOssHandler::successor_, tagOpenEnv(), XrdOssCsiConfig::tagParam_, tident, XRDOSS_mkpath, XRDOSS_new, and XrdOssOK.

+ Here is the call graph for this function:

◆ Features()

virtual uint64_t XrdOssCsi::Features ( )
inlinevirtual

Return storage system features.

Returns
Storage system features (see XRDOSS_HASxxx flags).

Reimplemented from XrdOssHandler.

Definition at line 190 of file XrdOssCsi.hh.

#define XRDOSS_HASFSCS
Definition: XrdOss.hh:476
#define XRDOSS_HASPGRW
Definition: XrdOss.hh:475
virtual uint64_t Features()
Definition: XrdOss.cc:60

References XrdOss::Features(), XrdOssHandler::successor_, XRDOSS_HASFSCS, and XRDOSS_HASPGRW.

+ Here is the call graph for this function:

◆ Init() [1/3]

int XrdOssCsi::Init ( XrdSysLogger lP,
const char *  cP,
const char *  params,
XrdOucEnv env 
)

Definition at line 116 of file XrdOssCsi.cc.

117 {
118  OssCsiEroute.logger(lP);
119 
120  int cret = config_.Init(OssCsiEroute, cP, params, env);
121  if (cret != XrdOssOK)
122  {
123  return cret;
124  }
125 
126  if ( ! env ||
127  ! (Sched_ = (XrdScheduler*) env->GetPtr("XrdScheduler*")))
128  {
129  Sched_ = new XrdScheduler;
130  Sched_->Start();
131  }
132 
133  return XrdOssOK;
134 }
XrdOucTrace OssCsiTrace & OssCsiEroute
Definition: XrdOssCsi.cc:53
int Init(XrdSysError &, const char *, const char *, XrdOucEnv *)
static XrdScheduler * Sched_
Definition: XrdOssCsi.hh:216
void * GetPtr(const char *varname)
Definition: XrdOucEnv.cc:263

References XrdOucEnv::GetPtr(), XrdOssCsiConfig::Init(), OssCsiEroute, Sched_, XrdScheduler::Start(), and XrdOssOK.

+ Here is the call graph for this function:

◆ Init() [2/3]

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

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 186 of file XrdOssCsi.hh.

186 { return Init(lp, cfn, 0, 0); }
virtual int Init(XrdSysLogger *lp, const char *cfn)
Definition: XrdOssCsi.hh:186

References Init().

Referenced by Init(), and XrdOssAddStorageSystem2().

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

◆ Init() [3/3]

virtual int XrdOssCsi::Init ( XrdSysLogger lp,
const char *  cfn,
XrdOucEnv envP 
)
inlinevirtual

Initialize the storage system V2.

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

Reimplemented from XrdOss.

Definition at line 187 of file XrdOssCsi.hh.

187 { return Init(lp, cfn, 0, envP); }

References XrdProxy::envP, and Init().

Referenced by Init().

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

◆ Mkdir()

int XrdOssCsi::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).

Reimplemented from XrdOssHandler.

Definition at line 311 of file XrdOssCsi.cc.

312 {
313  if (config_.tagParam_.isTagFile(path)) return -EACCES;
314  return successor_->Mkdir(path, mode, mkpath, envP);
315 }
virtual int Mkdir(const char *path, mode_t mode, int mkpath=0, XrdOucEnv *envP=0)=0

References XrdProxy::envP, TagPath::isTagFile(), XrdOss::Mkdir(), XrdOssHandler::successor_, and XrdOssCsiConfig::tagParam_.

+ Here is the call graph for this function:

◆ newDir()

XrdOssDF * XrdOssCsi::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 94 of file XrdOssCsi.cc.

95 {
96  // tident starting with '*' is a special case to bypass OssCsi
97  if (tident && *tident == '*')
98  {
99  return successor_->newDir(tident);
100  }
101 
102  return (XrdOssDF *)new XrdOssCsiDir(successor_, tident, config_);
103 }
virtual XrdOssDF * newDir(const char *tident)=0

References XrdOss::newDir(), XrdOssHandler::successor_, and tident.

+ Here is the call graph for this function:

◆ newFile()

XrdOssDF * XrdOssCsi::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 105 of file XrdOssCsi.cc.

106 {
107  // tident starting with '*' is a special case to bypass OssCsi
108  if (tident && *tident == '*')
109  {
110  return successor_->newFile(tident);
111  }
112 
113  return (XrdOssDF *)new XrdOssCsiFile(successor_, tident, config_);
114 }
virtual XrdOssDF * newFile(const char *tident)=0

References XrdOss::newFile(), XrdOssHandler::successor_, and tident.

Referenced by StatPF(), and Truncate().

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

◆ Reloc()

int XrdOssCsi::Reloc ( const char *  tident,
const char *  path,
const char *  cgName,
const char *  anchor = 0 
)
virtual

Relocate/Copy the file at ‘path’ to a new location.

Parameters
tident- -> trace identifier for this operation.
path- -> fully qualified name of the file to relocate.
cgName- -> target space name[:path]
anchor- Processing directions (see XrdOssReloc.cc example).
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssHandler.

Definition at line 304 of file XrdOssCsi.cc.

306 {
307  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
308  return successor_->Reloc(tident, path, cgName, anchor);
309 }
virtual int Reloc(const char *tident, const char *path, const char *cgName, const char *anchor=0)
Definition: XrdOss.cc:76

References TagPath::isTagFile(), XrdOss::Reloc(), XrdOssHandler::successor_, XrdOssCsiConfig::tagParam_, and tident.

+ Here is the call graph for this function:

◆ Remdir()

int XrdOssCsi::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).

Reimplemented from XrdOssHandler.

Definition at line 397 of file XrdOssCsi.cc.

398 {
399  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
400  const int ret = successor_->Remdir(path, Opts, eP);
401  if (ret != XrdOssOK || !config_.tagParam_.hasPrefix()) return ret;
402 
403  // try to remove the corresponding directory under the tagfile directory.
404  // ignore errors
405 
406  const std::string tpath = config_.tagParam_.makeBaseDirname(path);
407  (void) successor_->Remdir(tpath.c_str(), Opts, eP);
408  return XrdOssOK;
409 }
std::string makeBaseDirname(const char *path)
bool hasPrefix()
virtual int Remdir(const char *path, int Opts=0, XrdOucEnv *envP=0)=0

References TagPath::hasPrefix(), TagPath::isTagFile(), TagPath::makeBaseDirname(), XrdMpx::Opts, XrdOss::Remdir(), XrdOssHandler::successor_, XrdOssCsiConfig::tagParam_, and XrdOssOK.

+ Here is the call graph for this function:

◆ Rename()

int XrdOssCsi::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).

Reimplemented from XrdOssHandler.

Definition at line 169 of file XrdOssCsi.cc.

171 {
172  if (config_.tagParam_.isTagFile(oldname) || config_.tagParam_.isTagFile(newname)) return -ENOENT;
173 
174  const std::string inew = config_.tagParam_.makeTagFilename(newname);
175  const std::string iold = config_.tagParam_.makeTagFilename(oldname);
176 
177  // get mapinfo entries for both old and possibly existing newfile
178  std::shared_ptr<XrdOssCsiFile::puMapItem_t> newpmi,pmi;
179  XrdOssCsiFile::mapTake(inew, newpmi);
180  XrdOssCsiFile::mapTake(iold , pmi);
181 
182  // rename to self, do nothing
183  if (newpmi == pmi)
184  {
187  return 0;
188  }
189 
190  // take in consistent order
191  XrdSysMutexHelper lck(NULL), lck2(NULL);
192  // using the pointer here to get a total order, which is not
193  // guaranteed for operator<() so use std::less
194  if (std::less{}(pmi,newpmi))
195  {
196  lck.Lock(&newpmi->mtx);
197  lck2.Lock(&pmi->mtx);
198  }
199  else
200  {
201  lck2.Lock(&pmi->mtx);
202  lck.Lock(&newpmi->mtx);
203  }
204 
205  if (pmi->unlinked || newpmi->unlinked)
206  {
207  // something overwrote the source or target file since we checked
208  XrdOssCsiFile::mapRelease(pmi,&lck2);
209  XrdOssCsiFile::mapRelease(newpmi,&lck);
210  return Rename(oldname, newname, old_env, new_env);
211  }
212 
213  const int sret = successor_->Rename(oldname, newname, old_env, new_env);
214  if (sret<0)
215  {
216  XrdOssCsiFile::mapRelease(pmi,&lck2);
217  XrdOssCsiFile::mapRelease(newpmi,&lck);
218  return sret;
219  }
220 
221  int mkdret = XrdOssOK;
222  {
223  std::string base = inew;
224  const size_t idx = base.rfind("/");
225  base = base.substr(0,idx);
226  if (!base.empty())
227  {
228  const int AMode = S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH; // 775
229  mkdret = successor_->Mkdir(base.c_str(), AMode, 1, new_env);
230  }
231  }
232 
233  if (mkdret != XrdOssOK && mkdret != -EEXIST)
234  {
235  (void) successor_->Rename(newname, oldname, new_env, old_env);
236  XrdOssCsiFile::mapRelease(pmi,&lck2);
237  XrdOssCsiFile::mapRelease(newpmi,&lck);
238  return mkdret;
239  }
240 
241  const int iret = successor_->Rename(iold.c_str(), inew.c_str(), old_env, new_env);
242  if (iret<0)
243  {
244  if (iret == -ENOENT)
245  {
246  // old tag did not exist, make sure there is no new tag
247  (void) successor_->Unlink(inew.c_str(), 0, new_env);
248  }
249  else
250  {
251  (void) successor_->Rename(newname, oldname, new_env, old_env);
252  XrdOssCsiFile::mapRelease(pmi,&lck2);
253  XrdOssCsiFile::mapRelease(newpmi,&lck);
254  return iret;
255  }
256  }
257 
258  if (newpmi)
259  {
260  newpmi->unlinked = true;
261  }
262 
263  {
265  auto mapidx_new = XrdOssCsiFile::pumap_.find(inew);
266  if (mapidx_new != XrdOssCsiFile::pumap_.end()) XrdOssCsiFile::pumap_.erase(mapidx_new);
267 
268  auto mapidx = XrdOssCsiFile::pumap_.find(iold);
269  assert(mapidx != XrdOssCsiFile::pumap_.end());
270 
271  XrdOssCsiFile::pumap_.erase(mapidx);
272  XrdOssCsiFile::pumap_.insert(std::make_pair(inew, pmi));
273  pmi->dpath = newname;
274  pmi->tpath = inew;
275  }
276 
277  XrdOssCsiFile::mapRelease(pmi,&lck2);
278  XrdOssCsiFile::mapRelease(newpmi,&lck);
279 
280  return XrdOssOK;
281 }
static XrdSysMutex pumtx_
Definition: XrdOssCsi.hh:159
static std::unordered_map< std::string, std::shared_ptr< puMapItem_t > > pumap_
Definition: XrdOssCsi.hh:160
virtual int Rename(const char *oldname, const char *newname, XrdOucEnv *old_env=0, XrdOucEnv *new_env=0)
Definition: XrdOssCsi.cc:169
virtual int Rename(const char *oPath, const char *nPath, XrdOucEnv *oEnvP=0, XrdOucEnv *nEnvP=0)=0
virtual int Unlink(const char *path, int Opts=0, XrdOucEnv *envP=0)=0

References TagPath::isTagFile(), XrdSysMutexHelper::Lock(), TagPath::makeTagFilename(), XrdOssCsiFile::mapRelease(), XrdOssCsiFile::mapTake(), XrdOss::Mkdir(), XrdOssCsiFile::pumap_, XrdOssCsiFile::pumtx_, XrdOss::Rename(), XrdOssHandler::successor_, XrdOssCsiConfig::tagParam_, XrdOss::Unlink(), and XrdOssOK.

+ Here is the call graph for this function:

◆ Stat()

int XrdOssCsi::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).

Reimplemented from XrdOssHandler.

Definition at line 411 of file XrdOssCsi.cc.

413 {
414  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
415  return successor_->Stat(path, buff, opts, EnvP);
416 }
struct myOpts opts

References TagPath::isTagFile(), opts, XrdOss::Stat(), XrdOssHandler::successor_, and XrdOssCsiConfig::tagParam_.

+ Here is the call graph for this function:

◆ StatPF() [1/2]

virtual int XrdOssCsi::StatPF ( const char *  path,
struct stat buff 
)
inlinevirtual

Reimplemented from XrdOssHandler.

Definition at line 207 of file XrdOssCsi.hh.

207 { return StatPF(path, buff, 0);}
virtual int StatPF(const char *path, struct stat *buff, int opts)
Definition: XrdOssCsi.cc:418

References StatPF().

Referenced by StatPF().

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

◆ StatPF() [2/2]

int XrdOssCsi::StatPF ( const char *  path,
struct stat buff,
int  opts 
)
virtual

Reimplemented from XrdOssHandler.

Definition at line 418 of file XrdOssCsi.cc.

419 {
420  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
421  if (!(opts & XrdOss::PF_dStat)) return successor_->StatPF(path, buff, opts);
422 
423  buff->st_rdev = 0;
424  const int pfret = successor_->StatPF(path, buff, opts);
425  if (pfret != XrdOssOK)
426  {
427  return pfret;
428  }
429 
430  std::unique_ptr<XrdOssCsiFile> fp((XrdOssCsiFile*)newFile("xrdt"));
431  XrdOucEnv myEnv;
432  const int oret = fp->Open(path, O_RDONLY, 0, myEnv);
433  if (oret != XrdOssOK)
434  {
435  return oret;
436  }
437  const int vs = fp->VerificationStatus();
438 
439  long long retsz=0;
440  fp->Close(&retsz);
441 
442  buff->st_rdev &= ~(XrdOss::PF_csVer | XrdOss::PF_csVun);
443  buff->st_rdev |= static_cast<dev_t>(vs);
444  return XrdOssOK;
445 }
virtual XrdOssDF * newFile(const char *tident)
Definition: XrdOssCsi.cc:105
static const int PF_dStat
Definition: XrdOss.hh:773
static const int PF_csVer
verified file checksums present
Definition: XrdOss.hh:778
virtual int StatPF(const char *path, struct stat *buff, int opts)
Definition: XrdOss.cc:107
static const int PF_csVun
unverified file checksums present
Definition: XrdOss.hh:779

References TagPath::isTagFile(), newFile(), opts, XrdOss::PF_csVer, XrdOss::PF_csVun, XrdOss::PF_dStat, XrdOss::StatPF(), XrdOssHandler::successor_, XrdOssCsiConfig::tagParam_, and XrdOssOK.

+ Here is the call graph for this function:

◆ StatXA()

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

Return logical extended attributes associated with a path.

Parameters
path- Path in whose information is wanted.
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
"oss.cgroup=<name>&oss.type={'f'|'d'|'o'}&oss.used=<totbytes> &oss.mt=<mtime>&oss.ct=<ctime>&oss.at=<atime>&oss.u=*&oss.g=* &oss.fs={'w'|'r'}" Upon failure -errno or -osserr (see XrdOssError.hh) returned.

Reimplemented from XrdOssHandler.

Definition at line 447 of file XrdOssCsi.cc.

449 {
450  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
451  return successor_->StatXA(path, buff, blen, envP);
452 }
virtual int StatXA(const char *path, char *buff, int &blen, XrdOucEnv *envP=0)
Definition: XrdOss.cc:127

References XrdProxy::envP, TagPath::isTagFile(), XrdOss::StatXA(), XrdOssHandler::successor_, and XrdOssCsiConfig::tagParam_.

+ Here is the call graph for this function:

◆ tagOpenEnv()

std::unique_ptr< XrdOucEnv > XrdOssCsi::tagOpenEnv ( const XrdOssCsiConfig config,
XrdOucEnv env 
)
static

Definition at line 470 of file XrdOssCsi.cc.

471 {
472  // for tagfile open, start with copy of datafile environment
473  int infolen;
474  const char *info = env.Env(infolen);
475  std::unique_ptr<XrdOucEnv> newEnv(new XrdOucEnv(info, infolen, env.secEnv()));
476 
477  // give space name for tag files
478  newEnv->Put("oss.cgroup", config.xrdtSpaceName().c_str());
479 
480  char *tmp;
481  long long cgSize=0;
482  if ((tmp = env.Get("oss.asize")) && XrdOuca2x::a2sz(OssCsiEroute,"invalid asize",tmp,&cgSize,0))
483  {
484  cgSize=0;
485  }
486 
487  if (cgSize>0)
488  {
489  char size_str[32];
490  sprintf(size_str, "%lld", 20+4*((cgSize+XrdSys::PageSize-1)/XrdSys::PageSize));
491  newEnv->Put("oss.asize", size_str);
492  }
493  else
494  {
495  newEnv->Put("oss.asize", "0");
496  }
497 
498  return newEnv;
499 }
std::string xrdtSpaceName() const
char * Get(const char *varname)
Definition: XrdOucEnv.hh:69
const XrdSecEntity * secEnv() const
Definition: XrdOucEnv.hh:107
char * Env(int &envlen)
Definition: XrdOucEnv.hh:48
static int a2sz(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
Definition: XrdOuca2x.cc:257
static const int PageSize

References XrdOuca2x::a2sz(), XrdOucEnv::Env(), XrdOucEnv::Get(), OssCsiEroute, XrdSys::PageSize, XrdOucEnv::secEnv(), and XrdOssCsiConfig::xrdtSpaceName().

Referenced by Create().

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

◆ Truncate()

int XrdOssCsi::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).

Reimplemented from XrdOssHandler.

Definition at line 283 of file XrdOssCsi.cc.

284 {
285  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
286 
287  std::unique_ptr<XrdOssDF> fp(newFile("xrdt"));
288  XrdOucEnv myEnv;
289  int ret = fp->Open(path, O_RDWR, 0, envP ? *envP : myEnv);
290  if (ret != XrdOssOK)
291  {
292  return ret;
293  }
294  ret = fp->Ftruncate(size);
295  if (ret != XrdOssOK)
296  {
297  return ret;
298  }
299  long long retsz=0;
300  fp->Close(&retsz);
301  return XrdOssOK;
302 }

References XrdProxy::envP, TagPath::isTagFile(), newFile(), XrdOssCsiConfig::tagParam_, and XrdOssOK.

+ Here is the call graph for this function:

◆ Unlink()

int XrdOssCsi::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).

Reimplemented from XrdOssHandler.

Definition at line 136 of file XrdOssCsi.cc.

137 {
138  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
139 
140  // get mapinfo entries for file
141  std::shared_ptr<XrdOssCsiFile::puMapItem_t> pmi;
142  {
143  const std::string tpath = config_.tagParam_.makeTagFilename(path);
144  XrdOssCsiFile::mapTake(tpath, pmi);
145  }
146 
147  int utret = 0;
148 
149  XrdSysMutexHelper lck(pmi->mtx);
150  pmi->dpath = path;
151  if (!pmi->unlinked)
152  {
153  const int uret = successor_->Unlink(path, Opts, eP);
154  if (uret != XrdOssOK)
155  {
156  XrdOssCsiFile::mapRelease(pmi,&lck);
157  return uret;
158  }
159 
160  utret = successor_->Unlink(pmi->tpath.c_str(), Opts, eP);
161  }
162 
163  pmi->unlinked = true;
164  XrdOssCsiFile::mapRelease(pmi,&lck);
165 
166  return (utret == -ENOENT) ? 0 : utret;
167 }

References TagPath::isTagFile(), TagPath::makeTagFilename(), XrdOssCsiFile::mapRelease(), XrdOssCsiFile::mapTake(), XrdMpx::Opts, XrdOssHandler::successor_, XrdOssCsiConfig::tagParam_, XrdOss::Unlink(), and XrdOssOK.

+ Here is the call graph for this function:

Member Data Documentation

◆ Sched_

XrdScheduler * XrdOssCsi::Sched_
static

Definition at line 216 of file XrdOssCsi.hh.

Referenced by XrdOssCsiFileAio::Init(), and Init().


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