XRootD
Loading...
Searching...
No Matches
XrdOfsFile Class Reference

#include <XrdOfs.hh>

Inheritance diagram for XrdOfsFile:
Collaboration diagram for XrdOfsFile:

Public Member Functions

 XrdOfsFile (XrdOucErrInfo &eInfo, const char *user)
 ~XrdOfsFile ()
int checkpoint (XrdSfsFile::cpAct act, struct iov *range=0, int n=0)
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=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 pgRead (XrdSfsAio *aioparm, uint64_t opts=0)
XrdSfsXferSize pgRead (XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize rdlen, uint32_t *csvec, uint64_t opts=0)
int pgWrite (XrdSfsAio *aioparm, uint64_t opts=0)
XrdSfsXferSize pgWrite (XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize wrlen, uint32_t *csvec, uint64_t opts=0)
int read (XrdSfsAio *aioparm)
XrdSfsXferSize read (XrdSfsFileOffset fileOffset, char *buffer, XrdSfsXferSize buffer_size)
int read (XrdSfsFileOffset fileOffset, XrdSfsXferSize amount)
XrdSfsXferSize readv (XrdOucIOVec *readV, int readCount)
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.
virtual int SendData (XrdSfsDio *sfDio, XrdSfsFileOffset offset, XrdSfsXferSize size)
virtual void setXio (XrdSfsXio *xioP)
virtual XrdSfsXferSize writev (XrdOucIOVec *writeV, int wdvCnt)

Static Public Attributes

static bool ocFsync = false
Static Public Attributes inherited from XrdSfsFile
static const uint64_t Verify = 0x8000000000000000ULL
 Options for pgRead() and pgWrite() as noted below.

Protected Attributes

bool ckpBad
int dorawio
XrdOucChkPnt * myCKP
XrdOfsTPC * myTPC
XrdOfsHandle * oh
const char * tident
char viaDel

Additional Inherited Members

Public Types inherited from XrdSfsFile
enum  cpAct {
  cpCreate =0 ,
  cpDelete ,
  cpRestore ,
  cpQuery ,
  cpTrunc ,
  cpWrite
}
Public Attributes inherited from XrdSfsFile
XrdOucErrInfo & error

Detailed Description

Definition at line 114 of file XrdOfs.hh.

Constructor & Destructor Documentation

◆ XrdOfsFile()

XrdOfsFile::XrdOfsFile ( XrdOucErrInfo & eInfo,
const char * user )

Definition at line 442 of file XrdOfs.cc.

443 : XrdSfsFile(eInfo), tident(user ? user : ""),
444 oh(XrdOfs::dummyHandle), myTPC(0), myCKP(0),
445 dorawio(0), viaDel(0), ckpBad(false) {}
char viaDel
Definition XrdOfs.hh:203
const char * tident
Definition XrdOfs.hh:198
XrdOfsHandle * oh
Definition XrdOfs.hh:199
int dorawio
Definition XrdOfs.hh:202
XrdOucChkPnt * myCKP
Definition XrdOfs.hh:201
bool ckpBad
Definition XrdOfs.hh:204
XrdOfsTPC * myTPC
Definition XrdOfs.hh:200
XrdSfsFile(const char *user=0, int MonID=0)

References XrdSfsFile::XrdSfsFile(), ckpBad, dorawio, myCKP, myTPC, oh, tident, and viaDel.

Referenced by XrdOfsFileFull::XrdOfsFileFull().

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

◆ ~XrdOfsFile()

XrdOfsFile::~XrdOfsFile ( )
inline

Definition at line 192 of file XrdOfs.hh.

192{viaDel = 1; if (oh) close();}
int close()
Definition XrdOfs.cc:804

References close(), oh, and viaDel.

Here is the call graph for this function:

Member Function Documentation

◆ checkpoint()

int XrdOfsFile::checkpoint ( XrdSfsFile::cpAct act,
struct iov * range = 0,
int n = 0 )
virtual

Reimplemented from XrdSfsFile.

Definition at line 915 of file XrdOfs.cc.

916{
917 EPNAME("chkpnt");
918 const char *ckpName;
919 int rc;
920 bool readok;
921
922// Make sure we are active
923//
924 if (oh->Inactive()) return XrdOfsFS->Emsg(epname, error, EBADF,
925 "handle checkpoint", (const char *)0);
926
927// If checkpointing is disabled, the don't accept this request.
928//
929 if (!XrdOfsConfigCP::Enabled) return XrdOfsFS->Emsg(epname, error, ENOTSUP,
930 "handle disabled checkpoint", (const char *)0);
931
932// If this checkpoint is bad then only a delete, query or restore is allowed.
933//
934 if (ckpBad && (act == XrdSfsFile::cpTrunc || act == XrdSfsFile::cpWrite))
935 return XrdOfsFS->Emsg(epname, error, EIDRM, "extend checkpoint "
936 "(only delete or restore possible) for", oh->Name());
937
938// Handle the request
939//
940 switch(act)
942 ckpName = "create checkpoint for";
943 if ((rc = CreateCKP())) return rc;
944 if ((rc = myCKP->Create())) {myCKP->Finished(); myCKP = 0;}
945 break;
947 ckpName = "delete checkpoint for";
948 if (!myCKP) rc = ENOENT;
949 else {rc = myCKP->Delete();
950 myCKP->Finished();
951 myCKP = 0;
952 ckpBad = false;
953 }
954 break;
956 ckpName = "query checkpoint for";
957 if (!range || n <= 0)
958 return XrdOfsFS->Emsg(epname, error, EINVAL,
959 "query checkpoint limits for", oh->Name());
960 rc = (myCKP ? myCKP->Query(*range) : ENOENT);
961 break;
963 ckpName = "restore checkpoint for";
964 if (!myCKP) rc = ENOENT;
965 else {if (!(rc = myCKP->Restore(&readok)))
966 {myCKP->Finished();
967 myCKP = 0;
968 ckpBad = false;
969 } else {
970 if (!(oh->Select().DFType() & XrdOssDF::DF_isProxy))
971 oh->Suppress((readok ? 0 : -EDOM));
972 ckpBad = true;
973 }
974 }
975 break;
977 ckpName = "checkpoint truncate";
978 if (!range) rc = EINVAL;
979 else if (!myCKP) rc = ENOENT;
980 else if ((rc = myCKP->Truncate(range))) ckpBad = true;
981 break;
983 ckpName = "checkpoint write";
984 if (!range || n <= 0) rc = EINVAL;
985 else if (!myCKP) rc = ENOENT;
986 else if ((rc = myCKP->Write(range, n))) ckpBad = true;
987 break;
988
989 default: return XrdOfsFS->Emsg(epname, error, EINVAL,
990 "decode checkpoint request for", oh->Name());
991 };
992
993// Complete as needed
994//
995 if (rc) return XrdOfsFS->Emsg(epname, error, rc, ckpName, oh->Name());
996
997// Trace success and return
998//
999 FTRACE(chkpnt, ckpName);
1000 return SFS_OK;
1001}
#define EPNAME(x)
#define FTRACE(act, x)
XrdOfs * XrdOfsFS
Definition XrdOfsFS.cc:47
#define SFS_OK
static bool Enabled
static int Emsg(const char *, XrdOucErrInfo &, int, const char *x, XrdOfsHandle *hP)
Definition XrdOfs.cc:2518
static const uint16_t DF_isProxy
Object is a proxy object.
Definition XrdOss.hh:394
XrdOucErrInfo & error
@ cpTrunc
Truncate a file within checkpoint.
@ cpDelete
Delete an existing checkpoint.
@ cpRestore
Restore an active checkpoint and delete it.
@ cpWrite
Add data to an existing checkpoint.
@ cpQuery
Return checkpoint limits.
@ cpCreate
Create a checkpoint, one must not be active.

References ckpBad, XrdSfsFile::cpCreate, XrdSfsFile::cpDelete, XrdSfsFile::cpQuery, XrdSfsFile::cpRestore, XrdSfsFile::cpTrunc, XrdSfsFile::cpWrite, XrdOssDF::DF_isProxy, XrdOfsConfigCP::Enabled, EPNAME, XrdSfsFile::error, FTRACE, myCKP, oh, SFS_OK, and XrdOfsFS.

◆ close()

int XrdOfsFile::close ( )
virtual

Close the file.

Returns
One of SFS_OK or SFS_ERROR.

Implements XrdSfsFile.

Definition at line 804 of file XrdOfs.cc.

812{
813 EPNAME("close");
814
815 class CloseFH : public XrdOfsHanCB
816 {public: void Retired(XrdOfsHandle *hP) {XrdOfsFS->Unpersist(hP);}};
817 static XrdOfsHanCB *hCB = static_cast<XrdOfsHanCB *>(new CloseFH);
818
819 XrdOfsHandle *hP;
820 int poscNum, retc, cRetc = 0;
821 short theMode;
822
823// Trace the call
824//
825 FTRACE(close, "use=" <<oh->Usage()); // Unreliable trace, no origin lock
826
827// Verify the handle (we briefly maintain a global lock)
828//
829 XrdOfsFS->ocMutex.Lock();
830 if (oh == XrdOfs::dummyHandle)
831 {XrdOfsFS->ocMutex.UnLock(); return SFS_OK;}
832 if ((oh->Inactive()))
833 {XrdOfsFS->ocMutex.UnLock();
834 return XrdOfsFS->Emsg(epname, error, EBADF, "close file");
835 }
836 hP = oh; oh = XrdOfs::dummyHandle;
837 XrdOfsFS->ocMutex.UnLock();
838 hP->Lock();
839
840// Delete the tpc object, if any
841//
842 if (myTPC) {myTPC->Del(); myTPC = 0;}
843
844// Maintain statistics
845//
847 if (!(hP->isRW)) OfsStats.Data.numOpenR--;
848 else {OfsStats.Data.numOpenW--;
850 }
852
853// Do an fsync() on this file prior to closing if it was open r/w
854//
855 if (ocFsync && hP->isRW) hP->Select().Fsync(); // Ignore errors
856
857// If this file was tagged as a POSC then we need to make sure it will persist
858// Note that we unpersist the file immediately when it's inactive or if no hold
859// time is allowed. Also, close events occur only for active handles. If the
860// entry was via delete then we ignore the close return code as there is no
861// one to handle it on the other side.
862//
863 if ((poscNum = hP->PoscGet(theMode, !viaDel)))
864 {if (viaDel)
865 {if (hP->Inactive() || !XrdOfsFS->poscHold)
866 {XrdOfsFS->Unpersist(hP, !hP->Inactive()); hP->Retire(cRetc);}
867 else hP->Retire(hCB, XrdOfsFS->poscHold);
868 return SFS_OK;
869 }
870 if ((retc = hP->Select().Fchmod(theMode)))
871 XrdOfsFS->Emsg(epname, error, retc, "fchmod", hP->Name());
872 else {XrdOfsFS->poscQ->Del(hP->Name(), poscNum);
873 if (XrdOfsFS->Balancer) XrdOfsFS->Balancer->Added(hP->Name());
874 }
875 }
876
877// Handle any oustanding checkpoint
878//
879 if (myCKP)
880 {retc = myCKP->Restore();
881 if (retc) XrdOfsFS->Emsg(epname,error,retc,"restore chkpnt",hP->Name());
882 myCKP->Finished();
883 myCKP = 0;
884 }
885
886// We need to handle the cunudrum that an event may have to be sent upon
887// the final close. However, that would cause the path name to be destroyed.
888// So, we have two modes of logic where we copy out the pathname if a final
889// close actually occurs. The path is not copied if it's not final and we
890// don't bother with any of it if we need not generate an event.
891//
892 if (XrdOfsFS->evsObject && tident
893 && XrdOfsFS->evsObject->Enabled(hP->isRW ? XrdOfsEvs::Closew
895 {long long FSize, *retsz;
896 char pathbuff[MAXPATHLEN+8];
897 XrdOfsEvs::Event theEvent;
898 if (hP->isRW) {theEvent = XrdOfsEvs::Closew; retsz = &FSize;}
899 else { theEvent = XrdOfsEvs::Closer; retsz = 0; FSize=0;}
900 if (!(hP->Retire(cRetc, retsz, pathbuff, sizeof(pathbuff))))
901 {XrdOfsEvsInfo evInfo(tident, pathbuff, "" , 0, 0, FSize);
902 XrdOfsFS->evsObject->Notify(theEvent, evInfo);
903 }
904 } else hP->Retire(cRetc);
905
906// All done
907//
908 return (cRetc ? XrdOfsFS->Emsg(epname, error, cRetc, "close file") : SFS_OK);
909}
XrdOfsStats OfsStats
Definition XrdOfs.cc:113
virtual void Added(const char *path, int Pend=0)
void Notify(Event eNum, XrdOfsEvsInfo &Info)
Definition XrdOfsEvs.cc:234
int Enabled(Event theEvents)
Definition XrdOfsEvs.hh:139
static bool ocFsync
Definition XrdOfs.hh:194
virtual void Retired(XrdOfsHandle *)=0
int Retire(int &retc, long long *retsz=0, char *buff=0, int blen=0)
int PoscGet(short &Mode, int Done=0)
static const int opPC
XrdOssDF & Select(void)
const char * Name()
int Del(const char *Lfn, int Offset, int Unlink=0)
struct XrdOfsStats::StatsData Data
XrdSysMutex sdMutex
void Unpersist(XrdOfsHandle *hP, int xcev=1)
Definition XrdOfs.cc:2743
virtual int Fsync()
Definition XrdOss.hh:144
virtual int Fchmod(mode_t mode)
Definition XrdOss.hh:120

References close(), XrdOfsEvs::Closer, XrdOfsEvs::Closew, EPNAME, XrdSfsFile::error, XrdOssDF::Fchmod(), XrdOssDF::Fsync(), FTRACE, XrdOfsHandle::Inactive(), XrdOfsHandle::isRW, XrdOfsHandle::Lock(), myCKP, myTPC, XrdOfsHandle::Name(), ocFsync, OfsStats, oh, XrdOfsHandle::opPC, XrdOfsHandle::PoscGet(), XrdOfsHandle::Retire(), XrdOfsHandle::Select(), SFS_OK, tident, viaDel, and XrdOfsFS.

Referenced by ~XrdOfsFile(), and close().

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

◆ fctl() [1/2]

int XrdOfsFile::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 1045 of file XrdOfs.cc.

1048{
1049// See if we can do this
1050//
1051 if (cmd == SFS_FCTL_GETFD)
1052 {out_error.setErrCode(oh->Select().getFD());
1053 return SFS_OK;
1054 }
1055
1056// We don't support this
1057//
1058 out_error.setErrInfo(ENOTSUP, "fctl operation not supported");
1059
1060// Return
1061//
1062 return SFS_ERROR;
1063}
#define SFS_ERROR
#define SFS_FCTL_GETFD

References oh, XrdOucErrInfo::setErrCode(), XrdOucErrInfo::setErrInfo(), SFS_ERROR, SFS_FCTL_GETFD, and SFS_OK.

Here is the call graph for this function:

◆ fctl() [2/2]

int XrdOfsFile::fctl ( const int cmd,
int alen,
const char * args,
const XrdSecEntity * client = 0 )
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 1067 of file XrdOfs.cc.

1069{ // 12345678901234
1070 static const char *fctlArg = "ofs.tpc cancel";
1071 static const int fctlAsz = 15;
1072
1073// See if the is a tpc cancellation (the only thing we support here)
1074//
1075 if (cmd != SFS_FCTL_SPEC1 || !args || alen < fctlAsz || strcmp(fctlArg,args))
1076 return XrdOfsFS->FSctl(*this, cmd, alen, args, client);
1077
1078// Check if we have a tpc operation in progress
1079//
1080 if (!myTPC)
1081 {error.setErrInfo(ESRCH, "tpc operation not found");
1082 return SFS_ERROR;
1083 }
1084
1085// Cancel the tpc
1086//
1087 myTPC->Del();
1088 myTPC = 0;
1089 return SFS_OK;
1090}
#define SFS_FCTL_SPEC1
int FSctl(const int cmd, XrdSfsFSctl &args, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0)

References XrdSfsFile::error, myTPC, SFS_ERROR, SFS_FCTL_SPEC1, SFS_OK, and XrdOfsFS.

◆ FName()

const char * XrdOfsFile::FName ( )
inlinevirtual

Get the file path.

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

Implements XrdSfsFile.

Definition at line 140 of file XrdOfs.hh.

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

References oh.

◆ getCXinfo()

int XrdOfsFile::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 1736 of file XrdOfs.cc.

1747{
1748
1749// Copy out the info
1750//
1751 cxrsz = oh->Select().isCompressed(cxtype);
1752 return SFS_OK;
1753}

References oh, and SFS_OK.

◆ getMmap()

int XrdOfsFile::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 1579 of file XrdOfs.cc.

1587{
1588
1589// Perform the function
1590//
1591 Size = oh->Select().getMmap(Addr);
1592
1593 return SFS_OK;
1594}

References oh, and SFS_OK.

◆ open()

int XrdOfsFile::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 451 of file XrdOfs.cc.

481{
482 EPNAME("open");
483 static const int crMask = (SFS_O_CREAT | SFS_O_TRUNC);
484 static const int opMask = (SFS_O_RDONLY | SFS_O_WRONLY | SFS_O_RDWR);
485
486 struct OpenHelper
487 {const char *Path;
488 XrdOfsHandle *hP;
489 XrdOssDF *fP;
490 int poscNum;
491
492 int OK() {hP = 0; fP = 0; poscNum = 0; return SFS_OK;}
493
494 OpenHelper(const char *path)
495 : Path(path), hP(0), fP(0), poscNum(0) {}
496
497 ~OpenHelper()
498 {int retc;
499 if (hP) hP->Retire(retc);
500 if (fP) delete fP;
501 if (poscNum > 0) XrdOfsFS->poscQ->Del(Path, poscNum, 1);
502 }
503 } oP(path);
504
505 mode_t theMode = (Mode | XrdOfsFS->fMask[0]) & XrdOfsFS->fMask[1];
506 const char *tpcKey;
507 int retc, isPosc = 0, crOpts = 0, isRW = 0, open_flag = 0;
508 int find_flag = open_mode & (SFS_O_NOWAIT | SFS_O_RESET | SFS_O_MULTIW);
509 XrdOucEnv Open_Env(info,0,client);
510
511// Trace entry
512//
513 ZTRACE(open, Xrd::hex1 <<open_mode <<"-" <<Xrd::oct1 <<Mode <<" ("
514 <<Xrd::oct1 <<theMode <<") fn=" <<path);
515
516// Verify that this object is not already associated with an open file
517//
518 XrdOfsFS->ocMutex.Lock();
519 if (oh != XrdOfs::dummyHandle)
520 {XrdOfsFS->ocMutex.UnLock();
521 return XrdOfsFS->Emsg(epname,error,EADDRINUSE,"open file",path);
522 }
523 XrdOfsFS->ocMutex.UnLock();
524
525// Handle the open mode options
526//
527 if (open_mode & crMask)
528 {crOpts = (Mode & SFS_O_MKPTH ? XRDOSS_mkpath : 0);
529 if (XrdOfsFS->poscQ && ((open_mode & SFS_O_POSC) ||
530 XrdOfsFS->poscAuto || Open_Env.Get("ofs.posc")))
531 {isPosc = 1; isRW = XrdOfsHandle::opPC;}
532 else isRW = XrdOfsHandle::opRW;
533 if (open_mode & SFS_O_CREAT)
534 {open_flag = O_RDWR | O_CREAT | O_EXCL;
535 find_flag |= SFS_O_RDWR | SFS_O_CREAT | (open_mode & SFS_O_REPLICA);
536 crOpts |= XRDOSS_new;
537 } else {
538 open_flag |= O_RDWR | O_CREAT | O_TRUNC;
539 find_flag |= SFS_O_RDWR | SFS_O_TRUNC;
540 }
541 }
542 else
543 switch(open_mode & opMask)
544 {case SFS_O_RDONLY: open_flag = O_RDONLY; find_flag |= SFS_O_RDONLY;
545 break;
546 case SFS_O_WRONLY: open_flag = O_WRONLY; find_flag |= SFS_O_WRONLY;
547 isRW = XrdOfsHandle::opRW;
548 if (XrdOfsFS->poscQ && ((open_mode & SFS_O_POSC) ||
549 Open_Env.Get("ofs.posc"))) oP.poscNum = -1;
550 break;
551 case SFS_O_RDWR: open_flag = O_RDWR; find_flag |= SFS_O_RDWR;
552 isRW = XrdOfsHandle::opRW;
553 if (XrdOfsFS->poscQ && ((open_mode & SFS_O_POSC) ||
554 Open_Env.Get("ofs.posc"))) oP.poscNum = -1;
555 break;
556 default: open_flag = O_RDONLY; find_flag |= SFS_O_RDONLY;
557 break;
558 }
559
560// Preset TPC handling
561//
562 tpcKey = Open_Env.Get(XrdOucTPC::tpcKey);
563
564// Check if we will be redirecting the tpc request
565//
566 if (tpcKey && isRW && (XrdOfsFS->Options & XrdOfs::RdrTPC))
567 {const char *dOn = Open_Env.Get(XrdOucTPC::tpcDlgOn);
568 int k = ((dOn && *dOn == '1') || strcmp(tpcKey, "delegate") ? 1 : 0);
569 if (XrdOfsFS->tpcRdrHost[k])
570 {error.setErrInfo(XrdOfsFS->tpcRdrPort[k], XrdOfsFS->tpcRdrHost[k]);
571 return SFS_REDIRECT;
572 }
573 }
574
575// If we have a finder object, use it to direct the client. The final
576// destination will apply the security that is needed
577//
578 if (XrdOfsFS->Finder && (retc = XrdOfsFS->Finder->Locate(error, path,
579 find_flag, &Open_Env)))
580 return XrdOfsFS->fsError(error, retc);
581
582// Preset TPC handling and if not allowed, complain
583//
584 if (tpcKey && (open_mode & SFS_O_NOTPC))
585 return XrdOfsFS->Emsg(epname, error, EPROTOTYPE, "tpc", path);
586
587// Create the file if so requested o/w try to attach the file
588//
589 if (open_flag & O_CREAT)
590 {// Apply security, as needed
591 //
592 // If we aren't requesting O_EXCL, one needs AOP_Create
593 bool overwrite_permitted = true;
594 if (!(open_flag & O_EXCL))
595 {if (client && XrdOfsFS->Authorization &&
596 !XrdOfsFS->Authorization->Access(client, path, AOP_Create, &Open_Env))
597 { // We don't have the ability to create a file without O_EXCL. If we have AOP_Excl_Create,
598 // then manipulate the open flags and see if we're successful with it.
599 AUTHORIZE(client,&Open_Env,AOP_Excl_Create,"create",path,error);
600 overwrite_permitted = false;
601 open_flag |= O_EXCL;
602 open_flag &= ~O_TRUNC;
603 }
604 }
605 // If we are in O_EXCL mode, then we accept either AOP_Excl_Create or AOP_Create
606 else if (client && XrdOfsFS->Authorization &&
607 !XrdOfsFS->Authorization->Access(client, path, AOP_Create, &Open_Env))
608 {AUTHORIZE(client,&Open_Env,AOP_Excl_Create,"create",path,error);
609 // In this case, we don't have AOP_Create but we do have AOP_Excl_Create; note that
610 // overwrites are not permitted (this is later used to correct an error code).
611 overwrite_permitted = false;
612 }
613
614 OOIDENTENV(client, Open_Env);
615
616 // For ephemeral file, we must enter the file into the queue
617 //
618 if (isPosc)
619 {bool isNew = (open_mode & SFS_O_TRUNC) == 0;
620 if ((oP.poscNum = XrdOfsFS->poscQ->Add(tident, path, isNew)) < 0)
621 return XrdOfsFS->Emsg(epname, error, oP.poscNum, "pcreate", path);
622 }
623
624 // Create the file. If ENOTSUP is returned, promote the creation to
625 // the subsequent open. This is to accomodate proxy support.
626 //
627 if ((retc = XrdOfsOss->Create(tident, path, theMode, Open_Env,
628 ((open_flag << 8) | crOpts))))
629 {if (retc > 0) return XrdOfsFS->Stall(error, retc, path);
630 if (retc == -EINPROGRESS)
633 }
634 if (retc != -ENOTSUP)
635 {// If we tried to overwrite an existing file but do not have the AOP_Create
636 // privilege, then ensure we generate a 'permission denied' instead of 'exists'
637 if ((open_flag & O_EXCL) && retc == -EEXIST && !overwrite_permitted)
638 {retc = -EACCES;}
639 if (XrdOfsFS->Balancer) XrdOfsFS->Balancer->Removed(path);
640 return XrdOfsFS->Emsg(epname, error, retc, "create", path);
641 }
642 } else {
643 if (XrdOfsFS->Balancer) XrdOfsFS->Balancer->Added(path, isPosc);
644 open_flag = O_RDWR|O_TRUNC;
645 if (XrdOfsFS->evsObject
646 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Create))
647 {XrdOfsEvsInfo evInfo(tident,path,info,&Open_Env,Mode);
648 XrdOfsFS->evsObject->Notify(XrdOfsEvs::Create, evInfo);
649 }
650 }
651
652 } else {
653
654 // Apply security, as needed
655 //
656 if (tpcKey && !isRW)
657 {XrdOfsTPC::Facts Args(client, &error, &Open_Env, tpcKey, path);
658 if ((retc = XrdOfsTPC::Authorize(&myTPC, Args))) return retc;
659 } else {AUTHORIZE(client, &Open_Env, (isRW?AOP_Update:AOP_Read),
660 "open", path, error);
661 }
662 OOIDENTENV(client, Open_Env);
663 }
664
665// Get a handle for this file.
666//
667 if ((retc = XrdOfsHandle::Alloc(path, isRW, &oP.hP)))
668 {if (retc > 0) return XrdOfsFS->Stall(error, retc, path);
669 return XrdOfsFS->Emsg(epname, error, retc, "attach", path);
670 }
671
672// If this is a third party copy and we are the destination, then validate
673// specification at this point and setup to transfer. Note that if the
674// call fails and auto removal is enabled, the file we created will be deleted.
675//
676 if (tpcKey && isRW)
677 {char pfnbuff[MAXPATHLEN+8]; const char *pfnP;
678 if (!(pfnP = XrdOfsOss->Lfn2Pfn(path, pfnbuff, MAXPATHLEN, retc)))
679 return XrdOfsFS->Emsg(epname, error, retc, "open", path);
680 XrdOfsTPC::Facts Args(client, &error, &Open_Env, tpcKey, path, pfnP);
681 if ((retc = XrdOfsTPC::Validate(&myTPC, Args))) return retc;
682 }
683
684// Assign/transfer posc ownership. We may need to delay the client if the
685// file create ownership does not match and this is not a create request.
686//
687 if (oP.hP->isRW == XrdOfsHandle::opPC)
688 {if (!isRW) return XrdOfsFS->Stall(error, -1, path);
689 if ((retc = oP.hP->PoscSet(tident, oP.poscNum, theMode)))
690 {if (retc > 0) XrdOfsFS->poscQ->Del(path, retc);
691 else return XrdOfsFS->Emsg(epname, error, retc, "access", path);
692 }
693 }
694
695// If this is a previously existing handle, we are almost done. If this is
696// the target of a third party copy request, fail it now. We don't support
697// multiple writers in tpc mode (this should really never happen).
698//
699 if (!(oP.hP->Inactive()))
700 {dorawio = (oh->isCompressed && open_mode & SFS_O_RAWIO ? 1 : 0);
701 if (tpcKey && isRW)
702 return XrdOfsFS->Emsg(epname, error, EALREADY, "tpc", path);
703 XrdOfsFS->ocMutex.Lock(); oh = oP.hP; XrdOfsFS->ocMutex.UnLock();
704 FTRACE(open, "attach use=" <<oh->Usage());
705 if (oP.poscNum > 0) XrdOfsFS->poscQ->Commit(path, oP.poscNum);
706 oP.hP->UnLock();
709 if (oP.poscNum > 0) OfsStats.Data.numOpenP++;
711 return oP.OK();
712 }
713
714// Get a storage system object
715//
716 if (!(oP.fP = XrdOfsOss->newFile(tident)))
717 return XrdOfsFS->Emsg(epname, error, ENOMEM, "open", path);
718
719// We need to make special provisions for proxy servers in the presence of
720// the TPC option and possibly cache as it's handled differently in this case.
721//
722 if (XrdOfsFS->OssIsProxy)
723 {if (myTPC) open_flag |= O_NOFOLLOW;
724 if (error.getUCap() & XrdOucEI::uUrlOK &&
725 error.getUCap() & XrdOucEI::uLclF) open_flag |= O_DIRECT;
726 }
727
728// Open the file
729//
730 if ((retc = oP.fP->Open(path, open_flag, theMode, Open_Env)))
731 {if (retc > 0) return XrdOfsFS->Stall(error, retc, path);
732 if (retc == -EINPROGRESS)
735 }
736 if (retc == -ETXTBSY) return XrdOfsFS->Stall(error, -1, path);
737 if (retc == -EDESTADDRREQ)
738 {char *url = Open_Env.Get("FileURL");
739 if (url) {error.setErrInfo(-1, url); return SFS_REDIRECT;}
740 }
741 if (XrdOfsFS->Balancer && retc == -ENOENT)
742 XrdOfsFS->Balancer->Removed(path);
743 return XrdOfsFS->Emsg(epname, error, retc, "open", path);
744 }
745
746// Verify that we can actually use this file
747//
748 if (oP.poscNum > 0)
749 {if ((retc = oP.fP->Fchmod(static_cast<mode_t>(theMode|XRDSFS_POSCPEND))))
750 return XrdOfsFS->Emsg(epname, error, retc, "fchmod", path);
751 XrdOfsFS->poscQ->Commit(path, oP.poscNum);
752 }
753
754// Set compression values and activate the handle
755//
756 if (oP.fP->isCompressed() > 0)
757 {oP.hP->isCompressed = 1;
758 dorawio = (open_mode & SFS_O_RAWIO ? 1 : 0);
759 }
760 oP.hP->Activate(oP.fP);
761 oP.hP->UnLock();
762
763// If this is being opened for sequential I/O advise the filesystem about it.
764//
765#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
766 if (!(XrdOfsFS->OssIsProxy) && open_mode & SFS_O_SEQIO)
767 {static RAtomic_int fadFails(0);
768 int theFD = oP.fP->getFD();
769 if (theFD >= 0 && fadFails < 4096)
770 if (posix_fadvise(theFD, 0, 0, POSIX_FADV_SEQUENTIAL) < 0)
771 {OfsEroute.Emsg(epname, errno, "fadsize for sequential I/O.");
772 fadFails++;
773 }
774 }
775#endif
776
777// Send an open event if we must
778//
779 if (XrdOfsFS->evsObject)
781 if (XrdOfsFS->evsObject->Enabled(theEvent))
782 {XrdOfsEvsInfo evInfo(tident, path, info, &Open_Env);
783 XrdOfsFS->evsObject->Notify(theEvent, evInfo);
784 }
785 }
786
787// Maintain statistics
788//
791 if (oP.poscNum > 0) OfsStats.Data.numOpenP++;
793
794// All done
795//
796 XrdOfsFS->ocMutex.Lock(); oh = oP.hP; XrdOfsFS->ocMutex.UnLock();
797 return oP.OK();
798}
@ AOP_Update
open() r/w or append
@ AOP_Create
open() with create
@ AOP_Read
open() r/o, prepare()
@ AOP_Excl_Create
open() with O_EXCL|O_CREAT
#define ZTRACE(act, x)
#define O_DIRECT
Definition XrdCrc32c.cc:51
#define OOIDENTENV(usr, env)
#define AUTHORIZE(usr, env, optype, action, pathp, edata)
XrdSysError OfsEroute(0)
XrdOss * XrdOfsOss
Definition XrdOfs.cc:163
#define XRDOSS_new
Definition XrdOss.hh:467
#define XRDOSS_mkpath
Definition XrdOss.hh:466
int Mode
XrdOucString Path
#define XRDSFS_POSCPEND
#define SFS_O_RESET
#define SFS_O_SEQIO
#define SFS_O_NOTPC
#define SFS_O_POSC
#define SFS_REDIRECT
#define SFS_O_MKPTH
#define SFS_O_RDONLY
#define SFS_STARTED
#define SFS_O_MULTIW
#define SFS_O_WRONLY
#define SFS_O_CREAT
#define SFS_O_RAWIO
#define SFS_O_RDWR
#define SFS_O_NOWAIT
#define SFS_O_REPLICA
#define SFS_O_TRUNC
XrdSys::RAtomic< int > RAtomic_int
virtual XrdAccPrivs Access(const XrdSecEntity *Entity, const char *path, const Access_Operation oper, XrdOucEnv *Env=0)=0
virtual void Removed(const char *path)
virtual int Locate(XrdOucErrInfo &Resp, const char *path, int flags, XrdOucEnv *Info=0)=0
void Wait4Event(const char *path, XrdOucErrInfo *einfo)
Definition XrdOfsEvr.cc:226
int open(const char *fileName, XrdSfsFileOpenMode openMode, mode_t createMode, const XrdSecEntity *client, const char *opaque=0)
Definition XrdOfs.cc:451
static const int opRW
static int Alloc(const char *thePath, int Opts, XrdOfsHandle **Handle)
int Commit(const char *Lfn, int Offset)
int Add(const char *Tident, const char *Lfn, bool isNew)
static int Authorize(XrdOfsTPC **theTPC, Facts &Args, int isPLE=0)
Definition XrdOfsTPC.cc:221
static int Validate(XrdOfsTPC **theTPC, Facts &Args)
Definition XrdOfsTPC.cc:550
XrdCmsClient * Finder
Definition XrdOfs.hh:431
mode_t fMask[2]
Definition XrdOfs.hh:387
XrdOfsEvr evrObject
Definition XrdOfs.hh:430
int tpcRdrPort[2]
Definition XrdOfs.hh:392
char * tpcRdrHost[2]
Definition XrdOfs.hh:391
int Options
Definition XrdOfs.hh:381
static int fsError(XrdOucErrInfo &myError, int rc)
Definition XrdOfs.cc:2633
int Stall(XrdOucErrInfo &, int, const char *)
Definition XrdOfs.cc:2707
@ RdrTPC
Definition XrdOfs.hh:378
virtual int Create(const char *tid, const char *path, mode_t mode, XrdOucEnv &env, int opts=0)=0
virtual XrdOssDF * newFile(const char *tident)=0
virtual int Lfn2Pfn(const char *Path, char *buff, int blen)
Definition XrdOss.hh:873
static const char * tpcDlgOn
Definition XrdOucTPC.hh:68
static const char * tpcKey
Definition XrdOucTPC.hh:58
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
static const int uUrlOK
ucap: Supports async responses
static const int uLclF
ucap: Client is on a private net

References XrdOfsHandle::Alloc(), AOP_Create, AOP_Excl_Create, AOP_Read, AOP_Update, AUTHORIZE, XrdOfsTPC::Authorize(), XrdOfsEvs::Create, dorawio, EPNAME, XrdSfsFile::error, FTRACE, Xrd::hex1, Mode, myTPC, O_DIRECT, Xrd::oct1, OfsEroute, OfsStats, oh, OOIDENTENV, open(), XrdOfsEvs::Openr, XrdOfsEvs::Openw, XrdOfsHandle::opPC, XrdOfsHandle::opRW, Path, XrdOfs::RdrTPC, XrdOfsHandle::Retire(), SFS_O_CREAT, SFS_O_MKPTH, SFS_O_MULTIW, SFS_O_NOTPC, SFS_O_NOWAIT, SFS_O_POSC, SFS_O_RAWIO, SFS_O_RDONLY, SFS_O_RDWR, SFS_O_REPLICA, SFS_O_RESET, SFS_O_SEQIO, SFS_O_TRUNC, SFS_O_WRONLY, SFS_OK, SFS_REDIRECT, SFS_STARTED, tident, XrdOucTPC::tpcDlgOn, XrdOucTPC::tpcKey, XrdOucEI::uLclF, XrdOucEI::uUrlOK, XrdOfsTPC::Validate(), XrdOfsFS, XrdOfsOss, XRDOSS_mkpath, XRDOSS_new, XRDSFS_POSCPEND, and ZTRACE.

Referenced by open().

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

◆ pgRead() [1/2]

XrdSfsXferSize XrdOfsFile::pgRead ( XrdSfsAio * aioparm,
uint64_t opts = 0 )
virtual

Read file pages and checksums using asynchronous I/O.

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

Reimplemented from XrdSfsFile.

Definition at line 1146 of file XrdOfs.cc.

1147{
1148 EPNAME("aiopgread");
1149 uint64_t pgOpts;
1150 int rc;
1151
1152// If the oss plugin does not support pgRead or if we are doing rawio or the
1153// file is compressed then revert to using a standard async read. Note that
1154// the standard async read will generate checksums if a vector is present.
1155// Note: we set cksVec in the request to nil to indicate simulation!
1156//
1157 if (!XrdOfsFS->OssHasPGrw || dorawio || oh->isCompressed)
1158 {aioparm->cksVec = 0;
1159 return XrdOfsFile::read(aioparm);
1160 }
1161
1162// Perform required tracing
1163//
1164 FTRACE(aio, aioparm->sfsAio.aio_nbytes <<"@" <<aioparm->sfsAio.aio_offset);
1165
1166// Make sure the offset is not too large
1167//
1168#if _FILE_OFFSET_BITS!=64
1169 if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1170 return XrdOfsFS->Emsg(epname, error, EFBIG, "pgRead", oh->Name());
1171#endif
1172
1173// Pass through any flags of interest
1174//
1176 else pgOpts = 0;
1177
1178// Issue the read. Only true errors are returned here.
1179//
1180 if ((rc = oh->Select().pgRead(aioparm, pgOpts)) < 0)
1181 return XrdOfsFS->Emsg(epname, error, rc, "pgRead", oh->Name());
1182
1183// All done
1184//
1185 return SFS_OK;
1186}
struct myOpts opts
off_t aio_offset
Definition XrdSfsAio.hh:49
size_t aio_nbytes
Definition XrdSfsAio.hh:48
int read(XrdSfsFileOffset fileOffset, XrdSfsXferSize amount)
Definition XrdOfs.cc:1311
static const uint64_t Verify
all: Verify checksums
Definition XrdOss.hh:223
uint32_t * cksVec
Definition XrdSfsAio.hh:63
struct aiocb sfsAio
Definition XrdSfsAio.hh:62
static const uint64_t Verify
Options for pgRead() and pgWrite() as noted below.

References aiocb::aio_nbytes, aiocb::aio_offset, XrdSfsAio::cksVec, dorawio, EPNAME, XrdSfsFile::error, FTRACE, oh, opts, read(), SFS_OK, XrdSfsAio::sfsAio, XrdOssDF::Verify, XrdSfsFile::Verify, and XrdOfsFS.

Here is the call graph for this function:

◆ pgRead() [2/2]

XrdSfsXferSize XrdOfsFile::pgRead ( XrdSfsFileOffset offset,
char * buffer,
XrdSfsXferSize rdlen,
uint32_t * csvec,
uint64_t opts = 0 )
virtual

Read file pages into a buffer and return corresponding checksums.

Parameters
offset- The offset where the read is to start. It may be unaligned with certain caveats relative to csvec.
buffer- pointer to buffer where the bytes are to be placed.
rdlen- The number of bytes to read. The amount must be an integral number of XrdSfsPage::Size bytes.
csvec- A vector of entries to be filled with the cooresponding CRC32C checksum for each page. However, if the offset is unaligned, then csvec[0] contains the crc for the page fragment that brings it to alignment for csvec[1]. It must be sized to hold all aligned XrdSys::Pagesize crc's plus additional ones for leading and ending page fragments, if any.
opts- Processing options (see above).
Returns
>= 0 The number of bytes that placed in buffer.
SFS_ERROR File could not be read, error holds the reason.

Reimplemented from XrdSfsFile.

Definition at line 1096 of file XrdOfs.cc.

1101{
1102 EPNAME("pgRead");
1103 XrdSfsXferSize nbytes;
1104 uint64_t pgOpts;
1105
1106// If the oss plugin does not support pgRead and we doing rawio then simulate
1107// the pgread. As this is relatively common we skip the vtable. This means
1108// this class cannot be a inherited to override the read() method.
1109//
1110 if (!XrdOfsFS->OssHasPGrw || dorawio)
1111 {if ((nbytes = XrdOfsFile::read(offset, buffer, rdlen)) > 0)
1112 XrdOucPgrwUtils::csCalc(buffer, offset, nbytes, csvec);
1113 return nbytes;
1114 }
1115
1116// Perform required tracing
1117//
1118 FTRACE(read, rdlen <<"@" <<offset);
1119
1120// Make sure the offset is not too large
1121//
1122#if _FILE_OFFSET_BITS!=64
1123 if (offset > 0x000000007fffffff)
1124 return XrdOfsFS->Emsg(epname, error, EFBIG, "pgRead", oh->Name());
1125#endif
1126
1127// Pass through any flags of interest
1128//
1130 else pgOpts = 0;
1131
1132// Now read the actual number of bytes
1133//
1134 nbytes = (XrdSfsXferSize)(oh->Select().pgRead((void *)buffer,
1135 (off_t)offset, (size_t)rdlen, csvec, pgOpts));
1136 if (nbytes < 0)
1137 return XrdOfsFS->Emsg(epname, error, (int)nbytes, "pgRead", oh->Name());
1138
1139// Return number of bytes read
1140//
1141 return nbytes;
1142}
int XrdSfsXferSize
static void csCalc(const char *data, off_t offs, size_t count, uint32_t *csval)

References XrdOucPgrwUtils::csCalc(), dorawio, EPNAME, XrdSfsFile::error, FTRACE, oh, opts, read(), XrdOssDF::Verify, XrdSfsFile::Verify, and XrdOfsFS.

Here is the call graph for this function:

◆ pgWrite() [1/2]

XrdSfsXferSize XrdOfsFile::pgWrite ( XrdSfsAio * aioparm,
uint64_t opts = 0 )
virtual

Write file pages and checksums using asynchronous I/O.

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

Reimplemented from XrdSfsFile.

Definition at line 1246 of file XrdOfs.cc.

1247{
1248 EPNAME("aiopgWrite");
1249 uint64_t pgOpts;
1250 int rc;
1251
1252// If the oss plugin does not support pgWrite revert to using a standard write.
1253//
1254 if (!XrdOfsFS->OssHasPGrw)
1255 {if ((opts & XrdSfsFile::Verify)
1256 && !VerPgw((char *)aioparm->sfsAio.aio_buf,
1257 aioparm->sfsAio.aio_offset,
1258 aioparm->sfsAio.aio_nbytes,
1259 aioparm->cksVec, oh, error)) return SFS_ERROR;
1260 return XrdOfsFile::write(aioparm);
1261 }
1262
1263// If this is a POSC file, we must convert the async call to a sync call as we
1264// must trap any errors that unpersist the file. We can't do that via aio i/f.
1265//
1266 if (oh->isRW == XrdOfsHandle::opPC)
1267 {aioparm->Result = XrdOfsFile::pgWrite(aioparm->sfsAio.aio_offset,
1268 (char *)aioparm->sfsAio.aio_buf,
1269 aioparm->sfsAio.aio_nbytes,
1270 aioparm->cksVec, opts);
1271 aioparm->doneWrite();
1272 return SFS_OK;
1273 }
1274
1275// Perform any required tracing
1276//
1277 FTRACE(aio, aioparm->sfsAio.aio_nbytes <<"@" <<aioparm->sfsAio.aio_offset);
1278
1279// Make sure the offset is not too large
1280//
1281#if _FILE_OFFSET_BITS!=64
1282 if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1283 return XrdOfsFS->Emsg(epname, error, EFBIG, "pgwrite", oh->Name());
1284#endif
1285
1286// Silly Castor stuff
1287//
1288 if (XrdOfsFS->evsObject && !(oh->isChanged)
1289 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1290
1291// Pass through any flags of interest
1292//
1294 else pgOpts = 0;
1295
1296// Write the requested bytes
1297//
1298 oh->isPending = 1;
1299 if ((rc = oh->Select().pgWrite(aioparm, pgOpts)) < 0)
1300 return XrdOfsFS->Emsg(epname, error, rc, "pgwrite", oh->Name());
1301
1302// All done
1303//
1304 return SFS_OK;
1305}
void * aio_buf
Definition XrdSfsAio.hh:47
XrdSfsXferSize pgWrite(XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize wrlen, uint32_t *csvec, uint64_t opts=0)
Definition XrdOfs.cc:1192
XrdSfsXferSize write(XrdSfsFileOffset fileOffset, const char *buffer, XrdSfsXferSize buffer_size)
Definition XrdOfs.cc:1476
ssize_t Result
Definition XrdSfsAio.hh:65
virtual void doneWrite()=0

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, XrdSfsAio::cksVec, XrdSfsAio::doneWrite(), EPNAME, XrdSfsFile::error, FTRACE, XrdOfsEvs::Fwrite, oh, XrdOfsHandle::opPC, opts, pgWrite(), XrdSfsAio::Result, SFS_ERROR, SFS_OK, XrdSfsAio::sfsAio, XrdOssDF::Verify, XrdSfsFile::Verify, write(), and XrdOfsFS.

Here is the call graph for this function:

◆ pgWrite() [2/2]

XrdSfsXferSize XrdOfsFile::pgWrite ( XrdSfsFileOffset offset,
char * buffer,
XrdSfsXferSize wrlen,
uint32_t * csvec,
uint64_t opts = 0 )
virtual

Write file pages into a file with corresponding checksums.

Parameters
offset- The offset where the write is to start. It may be unaligned with certain caveats relative to csvec.
buffer- pointer to buffer containing the bytes to write.
wrlen- The number of bytes to write. If amount is not an integral number of XrdSys::PageSize bytes, then this must be the last write to the file at or above the offset.
csvec- A vector which contains the corresponding CRC32 checksum for each page or page fragment. If offset is unaligned then csvec[0] is the crc of the leading fragment to align the subsequent full page who's crc is in csvec[1]. It must be sized to hold all aligned XrdSys::Pagesize crc's plus additional ones for leading and ending page fragments, if any.
opts- Processing options (see above).
Returns
>= 0 The number of bytes written.
SFS_ERROR File could not be read, error holds the reason.

Reimplemented from XrdSfsFile.

Definition at line 1192 of file XrdOfs.cc.

1197{
1198 EPNAME("pgWrite");
1199 XrdSfsXferSize nbytes;
1200 uint64_t pgOpts;
1201
1202// If the oss plugin does not support pgWrite revert to using a standard write.
1203//
1204 if (!XrdOfsFS->OssHasPGrw)
1205 {if ((opts & XrdSfsFile::Verify)
1206 && !VerPgw(buffer, offset, wrlen, csvec, oh, error)) return SFS_ERROR;
1207 return XrdOfsFile::write(offset, buffer, wrlen);
1208 }
1209
1210// Perform any required tracing
1211//
1212 FTRACE(write, wrlen <<"@" <<offset);
1213
1214// Make sure the offset is not too large
1215//
1216#if _FILE_OFFSET_BITS!=64
1217 if (offset > 0x000000007fffffff)
1218 return XrdOfsFS->Emsg(epname, error, EFBIG, "pgwrite", oh);
1219#endif
1220
1221// Silly Castor stuff
1222//
1223 if (XrdOfsFS->evsObject && !(oh->isChanged)
1224 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1225
1226// Pass through any flags of interest
1227//
1229 else pgOpts = 0;
1230
1231// Write the requested bytes
1232//
1233 oh->isPending = 1;
1234 nbytes = (XrdSfsXferSize)(oh->Select().pgWrite((void *)buffer,
1235 (off_t)offset, (size_t)wrlen, csvec, pgOpts));
1236 if (nbytes < 0)
1237 return XrdOfsFS->Emsg(epname, error, (int)nbytes, "pgwrite", oh);
1238
1239// Return number of bytes written
1240//
1241 return nbytes;
1242}

References EPNAME, XrdSfsFile::error, FTRACE, XrdOfsEvs::Fwrite, oh, opts, SFS_ERROR, XrdOssDF::Verify, XrdSfsFile::Verify, write(), and XrdOfsFS.

Referenced by pgWrite().

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

◆ read() [1/3]

int XrdOfsFile::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 1436 of file XrdOfs.cc.

1437{
1438 EPNAME("aioread");
1439 int rc;
1440
1441// Async mode for compressed files is not supported.
1442//
1443 if (oh->isCompressed)
1444 {aiop->Result = this->read((XrdSfsFileOffset)aiop->sfsAio.aio_offset,
1445 (char *)aiop->sfsAio.aio_buf,
1446 (XrdSfsXferSize)aiop->sfsAio.aio_nbytes);
1447 aiop->doneRead();
1448 return 0;
1449 }
1450
1451// Perform required tracing
1452//
1453 FTRACE(aio, aiop->sfsAio.aio_nbytes <<"@" <<aiop->sfsAio.aio_offset);
1454
1455// Make sure the offset is not too large
1456//
1457#if _FILE_OFFSET_BITS!=64
1458 if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1459 return XrdOfsFS->Emsg(epname, error, EFBIG, "read", oh->Name());
1460#endif
1461
1462// Issue the read. Only true errors are returned here.
1463//
1464 if ((rc = oh->Select().Read(aiop)) < 0)
1465 return XrdOfsFS->Emsg(epname, error, rc, "read", oh->Name());
1466
1467// All done
1468//
1469 return SFS_OK;
1470}
#define read(a, b, c)
Definition XrdPosix.hh:82
long long XrdSfsFileOffset

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, XrdSfsAio::doneRead(), EPNAME, XrdSfsFile::error, FTRACE, oh, read, XrdSfsAio::Result, SFS_OK, XrdSfsAio::sfsAio, and XrdOfsFS.

Here is the call graph for this function:

◆ read() [2/3]

XrdSfsXferSize XrdOfsFile::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 1350 of file XrdOfs.cc.

1364{
1365 EPNAME("read");
1366 XrdSfsXferSize nbytes;
1367
1368// Perform required tracing
1369//
1370 FTRACE(read, blen <<"@" <<offset);
1371
1372// Make sure the offset is not too large
1373//
1374#if _FILE_OFFSET_BITS!=64
1375 if (offset > 0x000000007fffffff)
1376 return XrdOfsFS->Emsg(epname, error, EFBIG, "read", oh->Name());
1377#endif
1378
1379// Now read the actual number of bytes
1380//
1381 nbytes = (dorawio ?
1382 (XrdSfsXferSize)(oh->Select().ReadRaw((void *)buff,
1383 (off_t)offset, (size_t)blen))
1384 : (XrdSfsXferSize)(oh->Select().Read((void *)buff,
1385 (off_t)offset, (size_t)blen)));
1386 if (nbytes < 0)
1387 return XrdOfsFS->Emsg(epname, error, (int)nbytes, "read", oh->Name());
1388
1389// Return number of bytes read
1390//
1391 return nbytes;
1392}

References dorawio, EPNAME, XrdSfsFile::error, FTRACE, oh, read(), and XrdOfsFS.

Here is the call graph for this function:

◆ read() [3/3]

int XrdOfsFile::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 1311 of file XrdOfs.cc.

1321{
1322 EPNAME("read");
1323 int retc;
1324
1325// Perform required tracing
1326//
1327 FTRACE(read, "preread " <<blen <<"@" <<offset);
1328
1329// Make sure the offset is not too large
1330//
1331#if _FILE_OFFSET_BITS!=64
1332 if (offset > 0x000000007fffffff)
1333 return XrdOfsFS->Emsg(epname, error, EFBIG, "read", oh->Name());
1334#endif
1335
1336// Now preread the actual number of bytes
1337//
1338 if ((retc = oh->Select().Read((off_t)offset, (size_t)blen)) < 0)
1339 return XrdOfsFS->Emsg(epname, error, (int)retc, "preread", oh->Name());
1340
1341// Return number of bytes read
1342//
1343 return retc;
1344}

References EPNAME, XrdSfsFile::error, FTRACE, oh, read(), and XrdOfsFS.

Referenced by pgRead(), pgRead(), read(), and read().

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

◆ readv()

XrdSfsXferSize XrdOfsFile::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 1398 of file XrdOfs.cc.

1412{
1413 EPNAME("readv");
1414
1415 XrdSfsXferSize nbytes = oh->Select().ReadV(readV, readCount);
1416 if (nbytes < 0)
1417 return XrdOfsFS->Emsg(epname, error, (int)nbytes, "readv", oh->Name());
1418
1419 return nbytes;
1420
1421}

References EPNAME, XrdSfsFile::error, oh, and XrdOfsFS.

◆ stat()

int XrdOfsFile::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 1600 of file XrdOfs.cc.

1608{
1609 EPNAME("fstat");
1610 int retc;
1611
1612// Perform any required tracing
1613//
1614 FTRACE(stat, "");
1615
1616// Perform the function
1617//
1618 if ((retc = oh->Select().Fstat(buf)) < 0)
1619 return XrdOfsFS->Emsg(epname,error,retc,"get state for",oh->Name());
1620
1621 return SFS_OK;
1622}
int stat(struct stat *buf)
Definition XrdOfs.cc:1600

References EPNAME, XrdSfsFile::error, FTRACE, oh, SFS_OK, stat(), and XrdOfsFS.

Referenced by stat().

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

◆ sync() [1/2]

int XrdOfsFile::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 1628 of file XrdOfs.cc.

1636{
1637 EPNAME("sync");
1638 int retc;
1639
1640// Perform any required tracing
1641//
1642 FTRACE(sync, "");
1643
1644// If we have a tpc object hanging about, we need to dispatch that first
1645//
1646 if (myTPC && (retc = myTPC->Sync(&error))) return retc;
1647
1648// We can test the pendio flag w/o a lock because the person doing this
1649// sync must have done the previous write. Causality is the synchronizer.
1650//
1651 if (!(oh->isPending)) return SFS_OK;
1652
1653// We can also skip the sync if the file is closed. However, we need a file
1654// object lock in order to test the flag. We can also reset the PENDIO flag.
1655//
1656 oh->Lock();
1657 oh->isPending = 0;
1658 oh->UnLock();
1659
1660// Perform the function
1661//
1662 if ((retc = oh->Select().Fsync()))
1663 {oh->isPending = 1;
1664 return XrdOfsFS->Emsg(epname, error, retc, "synchronize", oh);
1665 }
1666
1667// Indicate all went well
1668//
1669 return SFS_OK;
1670}
int sync()
Definition XrdOfs.cc:1628

References EPNAME, XrdSfsFile::error, FTRACE, myTPC, oh, SFS_OK, sync(), and XrdOfsFS.

Referenced by sync(), and sync().

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

◆ sync() [2/2]

int XrdOfsFile::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 1678 of file XrdOfs.cc.

1679{
1680 aiop->Result = this->sync();
1681 aiop->doneWrite();
1682 return 0;
1683}

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

Here is the call graph for this function:

◆ truncate()

int XrdOfsFile::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 1689 of file XrdOfs.cc.

1703{
1704 EPNAME("trunc");
1705 int retc;
1706
1707// Lock the file handle and perform any tracing
1708//
1709 FTRACE(truncate, "len=" <<flen);
1710
1711// Make sure the offset is not too large
1712//
1713 if (sizeof(off_t) < sizeof(flen) && flen > 0x000000007fffffff)
1714 return XrdOfsFS->Emsg(epname, error, EFBIG, "truncate", oh);
1715
1716// Silly Castor stuff
1717//
1718 if (XrdOfsFS->evsObject && !(oh->isChanged)
1719 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1720
1721// Perform the function
1722//
1723 oh->isPending = 1;
1724 if ((retc = oh->Select().Ftruncate(flen)))
1725 return XrdOfsFS->Emsg(epname, error, retc, "truncate", oh);
1726
1727// Indicate Success
1728//
1729 return SFS_OK;
1730}
int truncate(XrdSfsFileOffset fileOffset)
Definition XrdOfs.cc:1689

References EPNAME, XrdSfsFile::error, FTRACE, XrdOfsEvs::Fwrite, oh, SFS_OK, truncate(), and XrdOfsFS.

Referenced by truncate().

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

◆ write() [1/2]

int XrdOfsFile::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 1532 of file XrdOfs.cc.

1533{
1534 EPNAME("aiowrite");
1535 int rc;
1536
1537// Perform any required tracing
1538//
1539 FTRACE(aio, aiop->sfsAio.aio_nbytes <<"@" <<aiop->sfsAio.aio_offset);
1540
1541// If this is a POSC file, we must convert the async call to a sync call as we
1542// must trap any errors that unpersist the file. We can't do that via aio i/f.
1543//
1544 if (oh->isRW == XrdOfsHandle::opPC)
1545 {aiop->Result = this->write(aiop->sfsAio.aio_offset,
1546 (const char *)aiop->sfsAio.aio_buf,
1547 aiop->sfsAio.aio_nbytes);
1548 aiop->doneWrite();
1549 return 0;
1550 }
1551
1552// Make sure the offset is not too large
1553//
1554#if _FILE_OFFSET_BITS!=64
1555 if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1556 return XrdOfsFS->Emsg(epname, error, EFBIG, "write", oh->Name());
1557#endif
1558
1559// Silly Castor stuff
1560//
1561 if (XrdOfsFS->evsObject && !(oh->isChanged)
1562 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1563
1564// Write the requested bytes
1565//
1566 oh->isPending = 1;
1567 if ((rc = oh->Select().Write(aiop)) < 0)
1568 return XrdOfsFS->Emsg(epname, error, rc, "write", oh->Name());
1569
1570// All done
1571//
1572 return SFS_OK;
1573}
#define write(a, b, c)
Definition XrdPosix.hh:115

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, XrdSfsAio::doneWrite(), EPNAME, XrdSfsFile::error, FTRACE, XrdOfsEvs::Fwrite, oh, XrdOfsHandle::opPC, XrdSfsAio::Result, SFS_OK, XrdSfsAio::sfsAio, write, and XrdOfsFS.

Here is the call graph for this function:

◆ write() [2/2]

XrdSfsXferSize XrdOfsFile::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 1476 of file XrdOfs.cc.

1493{
1494 EPNAME("write");
1495 XrdSfsXferSize nbytes;
1496
1497// Perform any required tracing
1498//
1499 FTRACE(write, blen <<"@" <<offset);
1500
1501// Make sure the offset is not too large
1502//
1503#if _FILE_OFFSET_BITS!=64
1504 if (offset > 0x000000007fffffff)
1505 return XrdOfsFS->Emsg(epname, error, EFBIG, "write", oh);
1506#endif
1507
1508// Silly Castor stuff
1509//
1510 if (XrdOfsFS->evsObject && !(oh->isChanged)
1511 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1512
1513// Write the requested bytes
1514//
1515 oh->isPending = 1;
1516 nbytes = (XrdSfsXferSize)(oh->Select().Write((const void *)buff,
1517 (off_t)offset, (size_t)blen));
1518 if (nbytes < 0)
1519 return XrdOfsFS->Emsg(epname, error, (int)nbytes, "write", oh);
1520
1521// Return number of bytes written
1522//
1523 return nbytes;
1524}

References EPNAME, XrdSfsFile::error, FTRACE, XrdOfsEvs::Fwrite, oh, write(), and XrdOfsFS.

Referenced by pgWrite(), pgWrite(), and write().

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

Member Data Documentation

◆ ckpBad

bool XrdOfsFile::ckpBad
protected

Definition at line 204 of file XrdOfs.hh.

Referenced by XrdOfsFile(), and checkpoint().

◆ dorawio

int XrdOfsFile::dorawio
protected

Definition at line 202 of file XrdOfs.hh.

Referenced by XrdOfsFile(), open(), pgRead(), pgRead(), and read().

◆ myCKP

XrdOucChkPnt* XrdOfsFile::myCKP
protected

Definition at line 201 of file XrdOfs.hh.

Referenced by XrdOfsFile(), checkpoint(), and close().

◆ myTPC

XrdOfsTPC* XrdOfsFile::myTPC
protected

Definition at line 200 of file XrdOfs.hh.

Referenced by XrdOfsFile(), close(), fctl(), open(), and sync().

◆ ocFsync

bool XrdOfsFile::ocFsync = false
inlinestatic

Definition at line 194 of file XrdOfs.hh.

Referenced by close().

◆ oh

◆ tident

const char* XrdOfsFile::tident
protected

Definition at line 198 of file XrdOfs.hh.

Referenced by XrdOfsFile(), close(), and open().

◆ viaDel

char XrdOfsFile::viaDel
protected

Definition at line 203 of file XrdOfs.hh.

Referenced by XrdOfsFile(), ~XrdOfsFile(), and close().


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