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 388 of file XrdOssCsi.cc.

389 {
390  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
391  return successor_->Chmod(path, mode, envP);
392 }
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 314 of file XrdOssCsi.cc.

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

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

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 308 of file XrdOssCsi.cc.

309 {
310  if (config_.tagParam_.isTagFile(path)) return -EACCES;
311  return successor_->Mkdir(path, mode, mkpath, envP);
312 }
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 93 of file XrdOssCsi.cc.

94 {
95  // tident starting with '*' is a special case to bypass OssCsi
96  if (tident && *tident == '*')
97  {
98  return successor_->newDir(tident);
99  }
100 
101  return (XrdOssDF *)new XrdOssCsiDir(successor_, tident, config_);
102 }
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 104 of file XrdOssCsi.cc.

105 {
106  // tident starting with '*' is a special case to bypass OssCsi
107  if (tident && *tident == '*')
108  {
109  return successor_->newFile(tident);
110  }
111 
112  return (XrdOssDF *)new XrdOssCsiFile(successor_, tident, config_);
113 }
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 301 of file XrdOssCsi.cc.

303 {
304  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
305  return successor_->Reloc(tident, path, cgName, anchor);
306 }
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 394 of file XrdOssCsi.cc.

395 {
396  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
397  const int ret = successor_->Remdir(path, Opts, eP);
398  if (ret != XrdOssOK || !config_.tagParam_.hasPrefix()) return ret;
399 
400  // try to remove the corresponding directory under the tagfile directory.
401  // ignore errors
402 
403  const std::string tpath = config_.tagParam_.makeBaseDirname(path);
404  (void) successor_->Remdir(tpath.c_str(), Opts, eP);
405  return XrdOssOK;
406 }
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 168 of file XrdOssCsi.cc.

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

410 {
411  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
412  return successor_->Stat(path, buff, opts, EnvP);
413 }
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:415

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 415 of file XrdOssCsi.cc.

416 {
417  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
418  if (!(opts & XrdOss::PF_dStat)) return successor_->StatPF(path, buff, opts);
419 
420  buff->st_rdev = 0;
421  const int pfret = successor_->StatPF(path, buff, opts);
422  if (pfret != XrdOssOK)
423  {
424  return pfret;
425  }
426 
427  std::unique_ptr<XrdOssCsiFile> fp((XrdOssCsiFile*)newFile("xrdt"));
428  XrdOucEnv myEnv;
429  const int oret = fp->Open(path, O_RDONLY, 0, myEnv);
430  if (oret != XrdOssOK)
431  {
432  return oret;
433  }
434  const int vs = fp->VerificationStatus();
435 
436  long long retsz=0;
437  fp->Close(&retsz);
438 
439  buff->st_rdev &= ~(XrdOss::PF_csVer | XrdOss::PF_csVun);
440  buff->st_rdev |= static_cast<dev_t>(vs);
441  return XrdOssOK;
442 }
virtual XrdOssDF * newFile(const char *tident)
Definition: XrdOssCsi.cc:104
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 444 of file XrdOssCsi.cc.

446 {
447  if (config_.tagParam_.isTagFile(path)) return -ENOENT;
448  return successor_->StatXA(path, buff, blen, envP);
449 }
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 467 of file XrdOssCsi.cc.

468 {
469  // for tagfile open, start with copy of datafile environment
470  int infolen;
471  const char *info = env.Env(infolen);
472  std::unique_ptr<XrdOucEnv> newEnv(new XrdOucEnv(info, infolen, env.secEnv()));
473 
474  // give space name for tag files
475  newEnv->Put("oss.cgroup", config.xrdtSpaceName().c_str());
476 
477  char *tmp;
478  long long cgSize=0;
479  if ((tmp = env.Get("oss.asize")) && XrdOuca2x::a2sz(OssCsiEroute,"invalid asize",tmp,&cgSize,0))
480  {
481  cgSize=0;
482  }
483 
484  if (cgSize>0)
485  {
486  char size_str[32];
487  sprintf(size_str, "%lld", 20+4*((cgSize+XrdSys::PageSize-1)/XrdSys::PageSize));
488  newEnv->Put("oss.asize", size_str);
489  }
490  else
491  {
492  newEnv->Put("oss.asize", "0");
493  }
494 
495  return newEnv;
496 }
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 280 of file XrdOssCsi.cc.

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

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 135 of file XrdOssCsi.cc.

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

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: