XRootD
XrdBwmFile Class Reference

#include <XrdBwm.hh>

+ Inheritance diagram for XrdBwmFile:
+ Collaboration diagram for XrdBwmFile:

Public Member Functions

 XrdBwmFile (const char *user, int monid)
 
virtual ~XrdBwmFile ()
 
int close ()
 
virtual int fctl (const int cmd, const char *args, XrdOucErrInfo &eInfo)=0
 
int fctl (const int cmd, const char *args, XrdOucErrInfo &out_error)
 
virtual int fctl (const int cmd, int alen, const char *args, const XrdSecEntity *client=0)
 
const char * FName ()
 
int getCXinfo (char cxtype[4], int &cxrsz)
 
int getMmap (void **Addr, off_t &Size)
 
int open (const char *fileName, XrdSfsFileOpenMode openMode, mode_t createMode, const XrdSecEntity *client, const char *opaque=0)
 
int read (XrdSfsAio *aioparm)
 
XrdSfsXferSize read (XrdSfsFileOffset fileOffset, char *buffer, XrdSfsXferSize buffer_size)
 
int read (XrdSfsFileOffset fileOffset, XrdSfsXferSize amount)
 
int stat (struct stat *buf)
 
int sync ()
 
int sync (XrdSfsAio *aiop)
 
int truncate (XrdSfsFileOffset fileOffset)
 
int write (XrdSfsAio *aioparm)
 
XrdSfsXferSize write (XrdSfsFileOffset fileOffset, const char *buffer, XrdSfsXferSize buffer_size)
 
- Public Member Functions inherited from XrdSfsFile
 XrdSfsFile (const char *user=0, int MonID=0)
 
 XrdSfsFile (XrdOucErrInfo &eInfo)
 
 XrdSfsFile (XrdSfsFile &wrapF)
 
virtual ~XrdSfsFile ()
 Destructor. More...
 
virtual int checkpoint (cpAct act, struct iov *range=0, int n=0)
 
virtual int fctl (const int cmd, int alen, const char *args, const XrdSecEntity *client=0)
 
virtual int pgRead (XrdSfsAio *aioparm, uint64_t opts=0)
 
virtual XrdSfsXferSize pgRead (XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize rdlen, uint32_t *csvec, uint64_t opts=0)
 
virtual int pgWrite (XrdSfsAio *aioparm, uint64_t opts=0)
 
virtual XrdSfsXferSize pgWrite (XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize wrlen, uint32_t *csvec, uint64_t opts=0)
 
virtual XrdSfsXferSize readv (XrdOucIOVec *readV, int rdvCnt)
 
virtual int SendData (XrdSfsDio *sfDio, XrdSfsFileOffset offset, XrdSfsXferSize size)
 
virtual void setXio (XrdSfsXio *xioP)
 
virtual XrdSfsXferSize writev (XrdOucIOVec *writeV, int wdvCnt)
 

Protected Attributes

const char * tident
 

Additional Inherited Members

- Public Types inherited from XrdSfsFile
enum  cpAct {
  cpCreate =0 ,
  cpDelete ,
  cpRestore ,
  cpQuery ,
  cpTrunc ,
  cpWrite
}
 
- Public Attributes inherited from XrdSfsFile
XrdOucErrInfoerror
 
- Static Public Attributes inherited from XrdSfsFile
static const uint64_t Verify = 0x8000000000000000ULL
 Options for pgRead() and pgWrite() as noted below. More...
 

Detailed Description

Definition at line 82 of file XrdBwm.hh.

Constructor & Destructor Documentation

◆ XrdBwmFile()

XrdBwmFile::XrdBwmFile ( const char *  user,
int  monid 
)

Definition at line 135 of file XrdBwm.cc.

135  : XrdSfsFile(user, monid)
136 {
137  oh = XrdBwm::dummyHandle;
138  tident = (user ? user : "");
139 }
const char * tident
Definition: XrdBwm.hh:134
XrdSfsFile(const char *user=0, int MonID=0)

References tident.

◆ ~XrdBwmFile()

virtual XrdBwmFile::~XrdBwmFile ( )
inlinevirtual

Definition at line 131 of file XrdBwm.hh.

131 {if (oh) close();}
int close()
Definition: XrdBwm.cc:336

References close().

+ Here is the call graph for this function:

Member Function Documentation

◆ close()

int XrdBwmFile::close ( )
virtual

Close the file.

Returns
One of SFS_OK or SFS_ERROR.

Implements XrdSfsFile.

Definition at line 336 of file XrdBwm.cc.

344 {
345  EPNAME("close");
346  XrdBwmHandle *hP;
347 
348 // Trace the call
349 //
350  FTRACE(calls, "close" <<oh->Name());
351 
352 // Verify the handle (we briefly maintain a global lock)
353 //
354  XrdBwmFS.ocMutex.Lock();
355  if (oh == XrdBwm::dummyHandle)
356  {XrdBwmFS.ocMutex.UnLock(); return SFS_OK;}
357  hP = oh; oh = XrdBwm::dummyHandle;
358  XrdBwmFS.ocMutex.UnLock();
359 
360 // Now retire it and possibly return the token
361 //
362  hP->Retire();
363 
364 // All done
365 //
366  return SFS_OK;
367 }
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
#define FTRACE(act, x)
Definition: XrdBwmTrace.hh:45
XrdBwm XrdBwmFS
Definition: XrdBwm.cc:83
#define SFS_OK
const char * Name()
Definition: XrdBwmHandle.hh:57

References EPNAME, FTRACE, XrdSysMutex::Lock(), XrdBwmHandle::Name(), XrdBwmHandle::Retire(), SFS_OK, XrdSysMutex::UnLock(), and XrdBwmFS.

Referenced by ~XrdBwmFile().

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

◆ fctl() [1/3]

virtual int XrdSfsFile::fctl

Execute a special operation on the file (version 1)

Parameters
cmd- The operation to be performed (see below). SFS_FCTL_GETFD Return file descriptor if possible SFS_FCTL_STATV Reserved for future use.
args- specific arguments to cmd SFS_FCTL_GETFD Set to zero.
eInfo- The object where error info or results are to be returned. This is legacy and the error onject may be used as well.
Returns
If an error occurs or the operation is not support, SFS_ERROR should be returned with error.code set to errno. Otherwise, SFS_FCTL_GETFD error.code holds the real file descriptor number If the value is negative, sendfile() is not used. If the value is SFS_SFIO_FDVAL then the SendData() method is used for future read requests.

◆ fctl() [2/3]

int XrdBwmFile::fctl ( const int  cmd,
const char *  args,
XrdOucErrInfo eInfo 
)
virtual

Execute a special operation on the file (version 1)

Parameters
cmd- The operation to be performed (see below). SFS_FCTL_GETFD Return file descriptor if possible SFS_FCTL_STATV Reserved for future use.
args- specific arguments to cmd SFS_FCTL_GETFD Set to zero.
eInfo- The object where error info or results are to be returned. This is legacy and the error onject may be used as well.
Returns
If an error occurs or the operation is not support, SFS_ERROR should be returned with error.code set to errno. Otherwise, SFS_FCTL_GETFD error.code holds the real file descriptor number If the value is negative, sendfile() is not used. If the value is SFS_SFIO_FDVAL then the SendData() method is used for future read requests.

Implements XrdSfsFile.

Definition at line 373 of file XrdBwm.cc.

387 {
388 
389 // Make sure the file is open
390 //
391  if (oh == XrdBwm::dummyHandle)
392  return XrdBwmFS.Emsg("fctl", out_error, EBADF, "fctl file");
393 
394 // Scan through the fctl operations
395 //
396  switch(cmd)
397  {case SFS_FCTL_GETFD: out_error.setErrInfo(-1,"");
398  return SFS_OK;
399  case SFS_FCTL_STATV: return oh->Activate(out_error);
400  default: break;
401  }
402 
403 // Invalid fctl
404 //
405  out_error.setErrInfo(EINVAL, "invalid fctl command");
406  return SFS_ERROR;
407 }
#define SFS_ERROR
#define SFS_FCTL_STATV
#define SFS_FCTL_GETFD
int Activate(XrdOucErrInfo &einfo)
int Emsg(const char *, XrdOucErrInfo &, int, const char *, const char *y="")
Definition: XrdBwm.cc:961

References XrdBwmHandle::Activate(), XrdBwm::Emsg(), XrdOucErrInfo::setErrInfo(), SFS_ERROR, SFS_FCTL_GETFD, SFS_FCTL_STATV, SFS_OK, and XrdBwmFS.

+ Here is the call graph for this function:

◆ fctl() [3/3]

int XrdSfsFile::fctl

Execute a special operation on the file (version 2)

Parameters
cmd- The operation to be performed: SFS_FCTL_SPEC1 Perform implementation defined action
alen- Length of data pointed to by args.
args- Data sent with request, zero if alen is zero.
client- Client's identify (see common description).
Returns
SFS_OK a null response is sent.
SFS_DATA error.code length of the data to be sent. error.message contains the data to be sent. o/w one of SFS_ERROR, SFS_REDIRECT, or SFS_STALL.

Definition at line 489 of file XrdSfsInterface.cc.

84 {
85  (void)cmd; (void)alen; (void)args; (void)client;
86  return SFS_OK;
87 }

◆ FName()

const char* XrdBwmFile::FName ( )
inlinevirtual

Get the file path.

Returns
Null terminated string of the path used in open().

Implements XrdSfsFile.

Definition at line 100 of file XrdBwm.hh.

100 {return (oh ? oh->Name() : "?");}

References XrdBwmHandle::Name().

Referenced by stat().

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

◆ getCXinfo()

int XrdBwmFile::getCXinfo ( char  cxtype[4],
int &  cxrsz 
)
virtual

Get compression information for the file.

Parameters
cxtype- Place where the compression algorithm name is to be placed
cxrsz- Place where the compression page size is to be returned
Returns
One of the valid SFS return codes described above. If the file is not compressed or an error is returned, cxrsz must be set to 0.

Implements XrdSfsFile.

Definition at line 672 of file XrdBwm.cc.

683 {
684 
685 // Indicate not compressed
686 //
687  cxrsz = 0;
688  cxtype[0] = cxtype[1] = cxtype[2] = cxtype[3] = 0;
689  return SFS_OK;
690 }

References SFS_OK.

◆ getMmap()

int XrdBwmFile::getMmap ( void **  Addr,
off_t &  Size 
)
virtual

Get file's memory mapping if one exists (memory mapped files only).

Parameters
Addr- Place where the starting memory address is returned.
Size- Place where the file's size is returned.
Returns
SFS_OK when the file is memory mapped or any other code otherwise.

Implements XrdSfsFile.

Definition at line 548 of file XrdBwm.cc.

556 {
557 
558 // Mapping is not supported
559 //
560  *Addr= 0;
561  Size = 0;
562 
563  return SFS_OK;
564 }

References SFS_OK.

◆ open()

int XrdBwmFile::open ( const char *  fileName,
XrdSfsFileOpenMode  openMode,
mode_t  createMode,
const XrdSecEntity client,
const char *  opaque = 0 
)
virtual

Open a file.

Parameters
fileName- Pointer to the path of the file to be opened.
openMode- Flags indicating how the open is to be handled. SFS_O_CREAT create the file SFS_O_MKPTH Make directory path if missing SFS_O_NOWAIT do not impose operational delays SFS_O_NOTPC do not allow TPC operation SFS_O_POSC persist only on successful close SFS_O_RAWIO allow client-side decompression SFS_O_RDONLY open read/only SFS_O_RDWR open read/write SFS_O_REPLICA Open for replication SFS_O_RESET Reset any cached information SFS_O_TRUNC truncate existing file to zero length SFS_O_WRONLY open write/only
createMode- The file's mode if it will be created.
client- Client's identify (see common description).
opaque- path's CGI information (see common description).
Returns
One of SFS_OK, SFS_ERROR, SFS_REDIRECT, SFS_STALL, or SFS_STARTED

Implements XrdSfsFile.

Definition at line 244 of file XrdBwm.cc.

270 {
271  EPNAME("open");
272  XrdBwmHandle *hP;
273  int incoming;
274  const char *miss, *theUsr, *theSrc, *theDst=0, *theLfn=0, *lclNode, *rmtNode;
275  XrdOucEnv Open_Env(info);
276 
277 // Trace entry
278 //
279  ZTRACE(calls,std::hex <<open_mode <<std::dec <<" fn=" <<path);
280 
281 // Verify that this object is not already associated with an open file
282 //
283  XrdBwmFS.ocMutex.Lock();
284  if (oh != XrdBwm::dummyHandle)
285  {XrdBwmFS.ocMutex.UnLock();
286  return XrdBwmFS.Emsg("open",error,EADDRINUSE,"open file",path);
287  }
288  XrdBwmFS.ocMutex.UnLock();
289 
290 // Verify that the file is being opened in r/w mode only!
291 //
292  if (!(open_mode & SFS_O_RDWR))
293  return XrdBwmFS.Emsg("open", error, EINVAL, "open", path);
294 
295 // Apply security. Note that we reject r/w access but apply r/o access
296 // restrictions if so wanted.
297 //
298  if (client && XrdBwmFS.Authorization
299  && !XrdBwmFS.Authorization->Access(client, path, AOP_Update, &Open_Env))
300  return XrdBwmFS.Emsg("open", error, EACCES, "open", path);
301 
302 // Make sure that all of the relevant information is present
303 //
304  if (!(theSrc = Open_Env.Get("bwm.src"))) miss = "bwm.src";
305  else if (!(theDst = Open_Env.Get("bwm.dst"))) miss = "bwm.dst";
306  else if (!(theLfn = index(path+1,'/'))
307  || !(*(theLfn+1))) miss = "lfn";
308  else miss = 0;
309 
310  if (miss) return XrdBwmFS.Emsg("open", error, miss, "open", path);
311  theUsr = error.getErrUser();
312 
313 // Determine the direction of flow
314 //
316  {incoming = 0; lclNode = theSrc; rmtNode = theDst;}
318  {incoming = 1; lclNode = theDst; rmtNode = theSrc;}
319  else return XrdBwmFS.Emsg("open", error, EREMOTE, "open", path);
320 
321 // Get a handle for this file.
322 //
323  if (!(hP = XrdBwmHandle::Alloc(theUsr,theLfn,lclNode,rmtNode,incoming)))
324  return XrdBwmFS.Stall(error, 13, path);
325 
326 // All done
327 //
328  XrdBwmFS.ocMutex.Lock(); oh = hP; XrdBwmFS.ocMutex.UnLock();
329  return SFS_OK;
330 }
@ AOP_Update
open() r/w or append
#define ZTRACE(act, x)
Definition: XrdBwmTrace.hh:52
#define SFS_O_RDWR
virtual XrdAccPrivs Access(const XrdSecEntity *Entity, const char *path, const Access_Operation oper, XrdOucEnv *Env=0)=0
static XrdBwmHandle * Alloc(const char *theUsr, const char *thePath, const char *lclNode, const char *rmtNode, int Incoming)
char * myDomain
Definition: XrdBwm.hh:249
int myDomLen
Definition: XrdBwm.hh:250
int Stall(XrdOucErrInfo &, int, const char *)
Definition: XrdBwm.cc:1022
const char * getErrUser()
static bool endsWith(const char *text, const char *ending, int endlen)
Definition: XrdOucUtils.cc:183
XrdOucErrInfo & error
@ dec
Definition: XrdSysTrace.hh:42
@ hex
Definition: XrdSysTrace.hh:42

References XrdAccAuthorize::Access(), XrdBwmHandle::Alloc(), AOP_Update, Xrd::dec, XrdBwm::Emsg(), XrdOucUtils::endsWith(), EPNAME, XrdSfsFile::error, XrdOucEnv::Get(), XrdOucErrInfo::getErrUser(), Xrd::hex, XrdSysMutex::Lock(), XrdBwm::myDomain, XrdBwm::myDomLen, SFS_O_RDWR, SFS_OK, XrdBwm::Stall(), XrdSysMutex::UnLock(), XrdBwmFS, and ZTRACE.

+ Here is the call graph for this function:

◆ read() [1/3]

int XrdBwmFile::read ( XrdSfsAio aioparm)
virtual

Read file bytes using asynchronous I/O.

Parameters
aioparm- Pointer to async I/O object controlling the I/O.
Returns
SFS_OK Request accepted and will be scheduled.
SFS_ERROR File could not be read, error holds the reason.

Implements XrdSfsFile.

Definition at line 480 of file XrdBwm.cc.

481 {
482 
483 // Async mode not supported.
484 //
485  aiop->Result = this->read((XrdSfsFileOffset)aiop->sfsAio.aio_offset,
486  (char *)aiop->sfsAio.aio_buf,
487  (XrdSfsXferSize)aiop->sfsAio.aio_nbytes);
488  aiop->doneRead();
489  return 0;
490 }
long long XrdSfsFileOffset
int XrdSfsXferSize
int read(XrdSfsFileOffset fileOffset, XrdSfsXferSize amount)
Definition: XrdBwm.cc:413

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, XrdSfsAio::doneRead(), read(), XrdSfsAio::Result, and XrdSfsAio::sfsAio.

+ Here is the call graph for this function:

◆ read() [2/3]

XrdSfsXferSize XrdBwmFile::read ( XrdSfsFileOffset  offset,
char *  buffer,
XrdSfsXferSize  size 
)
virtual

Read file bytes into a buffer.

Parameters
offset- The offset where the read is to start.
buffer- pointer to buffer where the bytes are to be placed.
size- The number of bytes to read.
Returns
>= 0 The number of bytes that placed in buffer.
SFS_ERROR File could not be read, error holds the reason.

Implements XrdSfsFile.

Definition at line 439 of file XrdBwm.cc.

455 {
456  EPNAME("read");
457 
458 // Perform required tracing
459 //
460  FTRACE(calls,blen <<"@" <<offset);
461 
462 // Return number of bytes read
463 //
464  return 0;
465 }

References EPNAME, and FTRACE.

◆ read() [3/3]

int XrdBwmFile::read ( XrdSfsFileOffset  offset,
XrdSfsXferSize  size 
)
virtual

Preread file blocks into the file system cache.

Parameters
offset- The offset where the read is to start.
size- The number of bytes to pre-read.
Returns
>= 0 The number of bytes that will be pre-read.
SFS_ERROR File could not be preread, error holds the reason.

Implements XrdSfsFile.

Definition at line 413 of file XrdBwm.cc.

423 {
424  EPNAME("read");
425 
426 // Perform required tracing
427 //
428  FTRACE(calls,"preread " <<blen <<"@" <<offset);
429 
430 // Return number of bytes read
431 //
432  return 0;
433 }

References EPNAME, and FTRACE.

Referenced by read().

+ Here is the caller graph for this function:

◆ stat()

int XrdBwmFile::stat ( struct stat *  buf)
virtual

Return state information on the file.

Parameters
buf- Pointer to the structure where info it to be returned.
Returns
One of SFS_OK, SFS_ERROR, SFS_REDIRECT, or SFS_STALL. When SFS_OK is returned, buf must hold stat information.

Implements XrdSfsFile.

Definition at line 570 of file XrdBwm.cc.

578 {
579  EPNAME("fstat");
580  static unsigned int myInode = 0;
581  union {long long Fill;
582  int Xor[2];
583  XrdBwmFile *fP;
584  dev_t Num;
585  } theDev;
586 
587 // Perform any required tracing
588 //
589  FTRACE(calls, FName());
590 
591 // Develop the device number
592 //
593  theDev.Fill = 0; theDev.fP = this; theDev.Xor[0] ^= theDev.Xor[1];
594 
595 // Fill out the stat structure for this pseudo file
596 //
597  memset(buf, 0, sizeof(struct stat));
598  buf->st_ino = myInode++;
599  buf->st_dev = theDev.Num;
600  buf->st_blksize = 4096;
601  buf->st_mode = S_IFBLK;
602  return SFS_OK;
603 }
const char * FName()
Definition: XrdBwm.hh:100
int stat(struct stat *buf)
Definition: XrdBwm.cc:570

References EPNAME, FName(), FTRACE, and SFS_OK.

+ Here is the call graph for this function:

◆ sync() [1/2]

int XrdBwmFile::sync ( )
virtual

Make sure all outstanding data is actually written to the file (sync).

Returns
One of SFS_OK, SFS_ERROR, SFS_REDIRECT, SFS_STALL, or SFS_STARTED

Implements XrdSfsFile.

Definition at line 609 of file XrdBwm.cc.

617 {
618  EPNAME("sync");
619 
620 // Perform any required tracing
621 //
622  FTRACE(calls,"");
623 
624 // We always succeed
625 //
626  return SFS_OK;
627 }

References EPNAME, FTRACE, and SFS_OK.

Referenced by sync().

+ Here is the caller graph for this function:

◆ sync() [2/2]

int XrdBwmFile::sync ( XrdSfsAio aiop)
virtual

Make sure all outstanding data is actually written to the file (async).

Returns
SFS_OK Request accepted and will be scheduled.
SFS_ERROR Request could not be accepted, return error has reason.

Implements XrdSfsFile.

Definition at line 635 of file XrdBwm.cc.

636 {
637  aiop->Result = this->sync();
638  aiop->doneWrite();
639  return 0;
640 }
int sync()
Definition: XrdBwm.cc:609
ssize_t Result
Definition: XrdSfsAio.hh:65
virtual void doneWrite()=0

References XrdSfsAio::doneWrite(), XrdSfsAio::Result, and sync().

+ Here is the call graph for this function:

◆ truncate()

int XrdBwmFile::truncate ( XrdSfsFileOffset  fsize)
virtual

Truncate the file.

Parameters
fsize- The size that the file is to have.
Returns
One of SFS_OK, SFS_ERROR, SFS_REDIRECT, or SFS_STALL

Implements XrdSfsFile.

Definition at line 646 of file XrdBwm.cc.

656 {
657  EPNAME("trunc");
658 
659 // Lock the file handle and perform any tracing
660 //
661  FTRACE(calls, "len=" <<flen);
662 
663 // Return an error
664 //
665  return XrdBwmFS.Emsg("trunc", error, ENOTSUP, "truncate", oh->Name());
666 }

References XrdBwm::Emsg(), EPNAME, XrdSfsFile::error, FTRACE, XrdBwmHandle::Name(), and XrdBwmFS.

+ Here is the call graph for this function:

◆ write() [1/2]

int XrdBwmFile::write ( XrdSfsAio aioparm)
virtual

Write file bytes using asynchronous I/O.

Parameters
aioparm- Pointer to async I/O object controlling the I/O.
Returns
0 Request accepted and will be scheduled.
!0 Request not accepted, returned value is errno.

Implements XrdSfsFile.

Definition at line 532 of file XrdBwm.cc.

533 {
534 
535 // Async mode not supported.
536 //
537  aiop->Result = this->write((XrdSfsFileOffset)aiop->sfsAio.aio_offset,
538  (char *)aiop->sfsAio.aio_buf,
539  (XrdSfsXferSize)aiop->sfsAio.aio_nbytes);
540  aiop->doneWrite();
541  return 0;
542 }
XrdSfsXferSize write(XrdSfsFileOffset fileOffset, const char *buffer, XrdSfsXferSize buffer_size)
Definition: XrdBwm.cc:496

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, XrdSfsAio::doneWrite(), XrdSfsAio::Result, XrdSfsAio::sfsAio, and write().

+ Here is the call graph for this function:

◆ write() [2/2]

XrdSfsXferSize XrdBwmFile::write ( XrdSfsFileOffset  offset,
const char *  buffer,
XrdSfsXferSize  size 
)
virtual

Write file bytes from a buffer.

Parameters
offset- The offset where the write is to start.
buffer- pointer to buffer where the bytes reside.
size- The number of bytes to write.
Returns
>= 0 The number of bytes that were written.
SFS_ERROR File could not be written, error holds the reason.

Implements XrdSfsFile.

Definition at line 496 of file XrdBwm.cc.

514 {
515  EPNAME("write");
516 
517 // Perform any required tracing
518 //
519  FTRACE(calls, blen <<"@" <<offset);
520 
521 // Return number of bytes written
522 //
523  return 0;
524 }

References EPNAME, and FTRACE.

Referenced by write().

+ Here is the caller graph for this function:

Member Data Documentation

◆ tident

const char* XrdBwmFile::tident
protected

Definition at line 134 of file XrdBwm.hh.

Referenced by XrdBwmFile().


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