XRootD
XrdSsiFile Class Reference

#include <XrdSsiFile.hh>

+ Inheritance diagram for XrdSsiFile:
+ Collaboration diagram for XrdSsiFile:

Public Member Functions

 XrdSsiFile (const char *user, int MonID)
 
virtual ~XrdSsiFile ()
 
int close ()
 
int fctl (const int cmd, const char *args, XrdOucErrInfo &out_error)
 
int fctl (const int cmd, int alen, const char *args, const XrdSecEntity *client)
 
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=0, const char *opaque=0)
 
int read (XrdSfsAio *aioparm)
 
XrdSfsXferSize read (XrdSfsFileOffset fileOffset, char *buffer, XrdSfsXferSize buffer_size)
 
int read (XrdSfsFileOffset fileOffset, XrdSfsXferSize preread_sz)
 
XrdSfsXferSize readv (XrdOucIOVec *readV, int readCount)
 
int SendData (XrdSfsDio *sfDio, XrdSfsFileOffset offset, XrdSfsXferSize size)
 
void setXio (XrdSfsXio *xP)
 
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 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 writev (XrdOucIOVec *writeV, int wdvCnt)
 

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 39 of file XrdSsiFile.hh.

Constructor & Destructor Documentation

◆ XrdSsiFile()

XrdSsiFile::XrdSsiFile ( const char *  user,
int  MonID 
)
inline

Definition at line 102 of file XrdSsiFile.hh.

103  : XrdSfsFile(myEInfo), fsFile(0), fSessP(0),
104  myEInfo(user, MonID) {}
XrdSfsFile(const char *user=0, int MonID=0)

◆ ~XrdSsiFile()

XrdSsiFile::~XrdSsiFile ( )
virtual

Definition at line 65 of file XrdSsiFile.cc.

66 {
67 
68 // If we have a file object then delete it -- it needs to close. Else do it.
69 //
70  if (fsFile) delete fsFile;
71  if (fSessP) fSessP->Recycle();
72 }

Member Function Documentation

◆ close()

int XrdSsiFile::close ( )
virtual

Close the file.

Returns
One of SFS_OK or SFS_ERROR.

Implements XrdSfsFile.

Definition at line 78 of file XrdSsiFile.cc.

86 {
87 
88 // Route this request as needed
89 //
90  if (fsFile) return fsFile->close();
91 
92 // Forward this to the file session object
93 //
94  return fSessP->close();
95 }
virtual int close()=0
int close(bool viaDel=false)

◆ fctl() [1/2]

int XrdSsiFile::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 101 of file XrdSsiFile.cc.

104 {
105 
106 // Route this request as needed
107 //
108  if (fsFile) return fsFile->fctl(cmd, args, out_error);
109 
110 // Indicate we would like to use SendData()
111 //
112  if (cmd == SFS_FCTL_GETFD)
113  {out_error.setErrCode(SFS_SFIO_FDVAL);
114  return SFS_OK;
115  }
116 
117 // We don't support any other kind of command
118 //
119  return XrdSsiUtils::Emsg("fctl",ENOTSUP,"fctl",fSessP->FName(),out_error);
120 }
#define SFS_SFIO_FDVAL
#define SFS_FCTL_GETFD
#define SFS_OK
virtual int fctl(const int cmd, const char *args, XrdOucErrInfo &eInfo)=0
const char * FName()
static int Emsg(const char *pfx, int ecode, const char *op, const char *path, XrdOucErrInfo &eDest)
Definition: XrdSsiUtils.cc:159

References XrdSsiUtils::Emsg(), XrdOucErrInfo::setErrCode(), SFS_FCTL_GETFD, SFS_OK, and SFS_SFIO_FDVAL.

+ Here is the call graph for this function:

◆ fctl() [2/2]

int XrdSsiFile::fctl ( const int  cmd,
int  alen,
const char *  args,
const XrdSecEntity client 
)
virtual

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.

Reimplemented from XrdSfsFile.

Definition at line 124 of file XrdSsiFile.cc.

128 {
129 
130 // Route this request as needed (callback possible)
131 //
132  if (fsFile) return fsFile->fctl(cmd, alen, args, client);
133 
134 // Forward this to the session object
135 //
136  return fSessP->fctl(cmd, alen, args, client);
137 }
int fctl(const int cmd, int alen, const char *args, const XrdSecEntity *client)

◆ FName()

const char * XrdSsiFile::FName ( )
virtual

Get the file path.

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

Implements XrdSfsFile.

Definition at line 143 of file XrdSsiFile.cc.

144 {
145 
146 // Route to filesystem if need be
147 //
148  if (fsFile) return fsFile->FName();
149 
150 // Return our name
151 //
152  return fSessP->FName();
153 }
virtual const char * FName()=0

◆ getCXinfo()

int XrdSsiFile::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 159 of file XrdSsiFile.cc.

170 {
171 // Route this request as needed (no callback possible)
172 //
173  if (fsFile) return fsFile->getCXinfo(cxtype, cxrsz);
174 
175 // Indicate we don't support compression
176 //
177  cxrsz = 0;
178  return SFS_OK;
179 }
virtual int getCXinfo(char cxtype[4], int &cxrsz)=0

References SFS_OK.

◆ getMmap()

int XrdSsiFile::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 185 of file XrdSsiFile.cc.

193 {
194 // Route this request as needed (no callback possible)
195 //
196  if (fsFile) return fsFile->getMmap(Addr, Size);
197 
198 // Indicate we don't support memory mapping
199 //
200  if (Addr) *Addr = 0;
201  Size = 0;
202  return SFS_OK;
203 }
virtual int getMmap(void **Addr, off_t &Size)=0

References SFS_OK.

◆ open()

int XrdSsiFile::open ( const char *  fileName,
XrdSfsFileOpenMode  openMode,
mode_t  createMode,
const XrdSecEntity client = 0,
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 209 of file XrdSsiFile.cc.

225 {
226  static const char *epname = "open";
227  int eNum;
228 
229 // Verify that this object is not already associated with an open file
230 //
231  if (fsFile || fSessP)
232  return XrdSsiUtils::Emsg(epname, EADDRINUSE, "open session", path, error);
233 
234 // Open a regular file if this is wanted
235 //
236  if (fsChk && FSPath.Find(path))
237  {if (!(fsFile = theFS->newFile(error)))
238  return XrdSsiUtils::Emsg(epname, ENOMEM, "open file", path, error);
239  return fsFile->open(path, open_mode, Mode, client, info);
240  }
241 
242 // Convert opaque and security into an environment
243 //
244  XrdOucEnv Open_Env(info, 0, client);
245 
246 // Allocate file session and issue open
247 //
249  eNum = fSessP->open(path, Open_Env, open_mode);
250  if (eNum) {fSessP->Recycle(); fSessP = 0;}
251  return eNum;
252 }
int Mode
const char * getErrUser()
unsigned long long Find(const char *pathname)
Definition: XrdOucPList.hh:112
virtual XrdSfsFile * newFile(char *user=0, int MonID=0)=0
XrdOucErrInfo & error
virtual int open(const char *fileName, XrdSfsFileOpenMode openMode, mode_t createMode, const XrdSecEntity *client=0, const char *opaque=0)=0
int open(const char *fileName, XrdOucEnv &theEnv, XrdSfsFileOpenMode openMode)
static XrdSsiFileSess * Alloc(XrdOucErrInfo &einfo, const char *user)
XrdSfsFileSystem * theFS
Definition: XrdSsiFile.cc:54
bool fsChk
Definition: XrdSsiFile.cc:56
XrdOucPListAnchor FSPath
Definition: XrdSsiFile.cc:55

References XrdSsiFileSess::Alloc(), XrdSsiUtils::Emsg(), XrdOucPListAnchor::Find(), XrdSsi::fsChk, XrdSsi::FSPath, Mode, XrdSfsFileSystem::newFile(), and XrdSsi::theFS.

+ Here is the call graph for this function:

◆ read() [1/3]

int XrdSsiFile::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 312 of file XrdSsiFile.cc.

313 {
314 
315 // Route to file system if need be (no callback possible)
316 //
317  if (fsFile) return fsFile->read(aiop);
318 
319 // Execute this request in a synchronous fashion
320 //
321  aiop->Result = fSessP->read((XrdSfsFileOffset)aiop->sfsAio.aio_offset,
322  (char *)aiop->sfsAio.aio_buf,
323  (XrdSfsXferSize)aiop->sfsAio.aio_nbytes);
324  aiop->doneRead();
325  return 0;
326 }
long long XrdSfsFileOffset
int XrdSfsXferSize
virtual XrdSfsXferSize read(XrdSfsFileOffset offset, XrdSfsXferSize size)=0
XrdSfsXferSize read(XrdSfsFileOffset fileOffset, char *buffer, XrdSfsXferSize buffer_size)

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

+ Here is the call graph for this function:

◆ read() [2/3]

XrdSfsXferSize XrdSsiFile::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 283 of file XrdSsiFile.cc.

297 {
298 
299 // Route to file system if need be (no callback possible)
300 //
301  if (fsFile) return fsFile->read(offset, buff, blen);
302 
303 // Forward this to the file session
304 //
305  return fSessP->read(offset, buff, blen);
306 }

◆ read() [3/3]

int XrdSsiFile::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 258 of file XrdSsiFile.cc.

268 {
269 
270 // Route to file system if need be (no callback possible)
271 //
272  if (fsFile) return fsFile->read(offset, blen);
273 
274 // We ignore these
275 //
276  return SFS_OK;
277 }

References SFS_OK.

◆ readv()

XrdSfsXferSize XrdSsiFile::readv ( XrdOucIOVec readV,
int  rdvCnt 
)
virtual

Given an array of read requests (size rdvCnt), read them from the file and place the contents consecutively in the provided buffer. A dumb default implementation is supplied but should be replaced to increase performance.

Parameters
readVpointer to the array of read requests.
rdvCntthe number of elements in readV.
Returns
>=0 The numbe of bytes placed into the buffer.
SFS_ERROR File could not be read, error holds the reason.

Reimplemented from XrdSfsFile.

Definition at line 332 of file XrdSsiFile.cc.

344 {
345 
346 // Route this request to file system if need be (no callback possible)
347 //
348  if (fsFile) return fsFile->readv(readV, readCount);
349 
350  return XrdSsiUtils::Emsg("readv",ENOTSUP,"readv",fSessP->FName(),error);
351 }
virtual XrdSfsXferSize readv(XrdOucIOVec *readV, int rdvCnt)

References XrdSsiUtils::Emsg().

+ Here is the call graph for this function:

◆ SendData()

int XrdSsiFile::SendData ( XrdSfsDio sfDio,
XrdSfsFileOffset  offset,
XrdSfsXferSize  size 
)
virtual

Send file bytes via a XrdSfsDio sendfile object to a client (optional).

Parameters
sfDio- Pointer to the sendfile object for data transfer.
offset- The offset where the read is to start.
size- The number of bytes to read and send.
Returns
SFS_ERROR File not read, error object has reason.
SFS_OK Either data has been successfully sent via sfDio or no data has been sent and a normal read() should be issued.

Reimplemented from XrdSfsFile.

Definition at line 357 of file XrdSsiFile.cc.

360 {
361 
362 // Route this request to file system if need be (no callback possible)
363 //
364  if (fsFile) return fsFile->SendData(sfDio, offset, size);
365 
366 // Forward this to the file session object
367 //
368  return fSessP->SendData(sfDio, offset, size);
369 }
virtual int SendData(XrdSfsDio *sfDio, XrdSfsFileOffset offset, XrdSfsXferSize size)
int SendData(XrdSfsDio *sfDio, XrdSfsFileOffset offset, XrdSfsXferSize size)

◆ setXio()

void XrdSsiFile::setXio ( XrdSfsXio xioP)
virtual

Enable exchange buffer I/O for write calls.

Parameters
xioP- Pointer to the XrdSfsXio object to be used for buffer exchanges.

Reimplemented from XrdSfsFile.

Definition at line 375 of file XrdSsiFile.cc.

376 {
377  if (fSessP) fSessP->setXio(xP);
378  if (fsFile) fsFile->setXio(xP);
379 }
virtual void setXio(XrdSfsXio *xioP)
void setXio(XrdSfsXio *xP)

◆ stat()

int XrdSsiFile::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 385 of file XrdSsiFile.cc.

393 {
394 
395 // Route this request to file system if need be (no callback possible)
396 //
397  if (fsFile) return fsFile->stat(buf);
398 
399 // Otherwise there is no stat information
400 //
401  memset(buf, 0 , sizeof(struct stat));
402  return SFS_OK;
403 }
virtual int stat(struct stat *buf)=0
int stat(struct stat *buf)
Definition: XrdSsiFile.cc:385

References SFS_OK, and stat().

+ Here is the call graph for this function:

◆ sync() [1/2]

int XrdSsiFile::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 409 of file XrdSsiFile.cc.

417 {
418 
419 // Route this request to file system if need be (callback possible)
420 //
421  if (fsFile) return fsFile->sync();
422 
423 // We don't support this
424 //
425  return XrdSsiUtils::Emsg("sync",ENOTSUP,"sync",fSessP->FName(),error);
426 }
virtual int sync()=0

References XrdSsiUtils::Emsg().

+ Here is the call graph for this function:

◆ sync() [2/2]

int XrdSsiFile::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 432 of file XrdSsiFile.cc.

433 {
434 
435 // Route this request to file system if need be (callback possible)
436 //
437  if (fsFile) return fsFile->sync(aiop);
438 
439 // We don't support this
440 //
441  return XrdSsiUtils::Emsg("syncaio",ENOTSUP,"sync",fSessP->FName(),error);
442 }

References XrdSsiUtils::Emsg().

+ Here is the call graph for this function:

◆ truncate()

int XrdSsiFile::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 448 of file XrdSsiFile.cc.

456 {
457 
458 // Route this request to file system if need be (callback possible)
459 //
460  if (fsFile) return fsFile->truncate(flen);
461 
462 // Route this to the file session object
463 //
464  return fSessP->truncate(flen);
465 }
virtual int truncate(XrdSfsFileOffset fsize)=0
int truncate(XrdSfsFileOffset fileOffset)

◆ write() [1/2]

int XrdSsiFile::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 503 of file XrdSsiFile.cc.

504 {
505 
506 // Route to file system if need be (no callback possible)
507 //
508  if (fsFile) return fsFile->write(aiop);
509 
510 // Execute this request in a synchronous fashion
511 //
512  aiop->Result = fSessP->write((XrdSfsFileOffset)aiop->sfsAio.aio_offset,
513  (char *)aiop->sfsAio.aio_buf,
514  (XrdSfsXferSize)aiop->sfsAio.aio_nbytes);
515  aiop->doneWrite();
516  return 0;
517 }
virtual XrdSfsXferSize write(XrdSfsFileOffset offset, const char *buffer, XrdSfsXferSize size)=0
XrdSfsXferSize write(XrdSfsFileOffset fileOffset, const char *buffer, XrdSfsXferSize buffer_size)

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

+ Here is the call graph for this function:

◆ write() [2/2]

XrdSfsXferSize XrdSsiFile::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 471 of file XrdSsiFile.cc.

488 {
489 
490 // Route this request to file system if need be (no callback possible)
491 //
492  if (fsFile) return fsFile->write(offset, buff, blen);
493 
494 // Route this to the file session object
495 //
496  return fSessP->write(offset, buff, blen);
497 }

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