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 ()
 
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)
 
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)
 

Protected Attributes

bool ckpBad
 
int dorawio
 
XrdOucChkPntmyCKP
 
XrdOfsTPCmyTPC
 
XrdOfsHandleoh
 
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
XrdOucErrInfoerror
 
- Static Public Attributes inherited from XrdSfsFile
static const uint64_t Verify = 0x8000000000000000ULL
 Options for pgRead() and pgWrite() as noted below.
 

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:201
const char * tident
Definition XrdOfs.hh:196
XrdOfsHandle * oh
Definition XrdOfs.hh:197
int dorawio
Definition XrdOfs.hh:200
XrdOucChkPnt * myCKP
Definition XrdOfs.hh:199
bool ckpBad
Definition XrdOfs.hh:202
XrdOfsTPC * myTPC
Definition XrdOfs.hh:198
XrdSfsFile(const char *user=0, int MonID=0)

◆ ~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 911 of file XrdOfs.cc.

912{
913 EPNAME("chkpnt");
914 const char *ckpName;
915 int rc;
916 bool readok;
917
918// Make sure we are active
919//
920 if (oh->Inactive()) return XrdOfsFS->Emsg(epname, error, EBADF,
921 "handle checkpoint", (const char *)0);
922
923// If checkpointing is disabled, the don't accept this request.
924//
925 if (!XrdOfsConfigCP::Enabled) return XrdOfsFS->Emsg(epname, error, ENOTSUP,
926 "handle disabled checkpoint", (const char *)0);
927
928// If this checkpoint is bad then only a delete, query or restore is allowed.
929//
930 if (ckpBad && (act == XrdSfsFile::cpTrunc || act == XrdSfsFile::cpWrite))
931 return XrdOfsFS->Emsg(epname, error, EIDRM, "extend checkpoint "
932 "(only delete or restore possible) for", oh->Name());
933
934// Handle the request
935//
936 switch(act)
938 ckpName = "create checkpoint for";
939 if ((rc = CreateCKP())) return rc;
940 if ((rc = myCKP->Create())) {myCKP->Finished(); myCKP = 0;}
941 break;
943 ckpName = "delete checkpoint for";
944 if (!myCKP) rc = ENOENT;
945 else {rc = myCKP->Delete();
946 myCKP->Finished();
947 myCKP = 0;
948 ckpBad = false;
949 }
950 break;
952 ckpName = "query checkpoint for";
953 if (!range || n <= 0)
954 return XrdOfsFS->Emsg(epname, error, EINVAL,
955 "query checkpoint limits for", oh->Name());
956 rc = (myCKP ? myCKP->Query(*range) : ENOENT);
957 break;
959 ckpName = "restore checkpoint for";
960 if (!myCKP) rc = ENOENT;
961 else {if (!(rc = myCKP->Restore(&readok)))
962 {myCKP->Finished();
963 myCKP = 0;
964 ckpBad = false;
965 } else {
966 if (!(oh->Select().DFType() & XrdOssDF::DF_isProxy))
967 oh->Suppress((readok ? 0 : -EDOM));
968 ckpBad = true;
969 }
970 }
971 break;
973 ckpName = "checkpoint truncate";
974 if (!range) rc = EINVAL;
975 else if (!myCKP) rc = ENOENT;
976 else if ((rc = myCKP->Truncate(range))) ckpBad = true;
977 break;
979 ckpName = "checkpoint write";
980 if (!range || n <= 0) rc = EINVAL;
981 else if (!myCKP) rc = ENOENT;
982 else if ((rc = myCKP->Write(range, n))) ckpBad = true;
983 break;
984
985 default: return XrdOfsFS->Emsg(epname, error, EINVAL,
986 "decode checkpoint request for", oh->Name());
987 };
988
989// Complete as needed
990//
991 if (rc) return XrdOfsFS->Emsg(epname, error, rc, ckpName, oh->Name());
992
993// Trace success and return
994//
995 FTRACE(chkpnt, ckpName);
996 return SFS_OK;
997}
#define EPNAME(x)
#define FTRACE(act, x)
XrdOfs * XrdOfsFS
Definition XrdOfsFS.cc:47
#define SFS_OK
static bool Enabled
void Suppress(int rrc=-EDOM, int wrc=-EDOM)
XrdOssDF & Select(void)
const char * Name()
static int Emsg(const char *, XrdOucErrInfo &, int, const char *x, XrdOfsHandle *hP)
Definition XrdOfs.cc:2513
static const uint16_t DF_isProxy
Object is a proxy object.
Definition XrdOss.hh:394
uint16_t DFType()
Definition XrdOss.hh:396
virtual void Finished()=0
virtual int Restore(bool *readok=0)=0
virtual int Query(struct iov &range)=0
virtual int Write(struct iov *&range, int rnum)=0
virtual int Delete()=0
virtual int Truncate(struct iov *&range)=0
virtual int Create()=0
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, XrdOucChkPnt::Create(), XrdOucChkPnt::Delete(), XrdOssDF::DF_isProxy, XrdOssDF::DFType(), XrdOfs::Emsg(), XrdOfsConfigCP::Enabled, EPNAME, XrdSfsFile::error, XrdOucChkPnt::Finished(), FTRACE, XrdOfsHandle::Inactive(), myCKP, XrdOfsHandle::Name(), oh, XrdOucChkPnt::Query(), XrdOucChkPnt::Restore(), XrdOfsHandle::Select(), SFS_OK, XrdOfsHandle::Suppress(), XrdOucChkPnt::Truncate(), XrdOucChkPnt::Write(), and XrdOfsFS.

+ Here is the call graph for this function:

◆ 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// If this file was tagged as a POSC then we need to make sure it will persist
854// Note that we unpersist the file immediately when it's inactive or if no hold
855// time is allowed. Also, close events occur only for active handles. If the
856// entry was via delete then we ignore the close return code as there is no
857// one to handle it on the other side.
858//
859 if ((poscNum = hP->PoscGet(theMode, !viaDel)))
860 {if (viaDel)
861 {if (hP->Inactive() || !XrdOfsFS->poscHold)
862 {XrdOfsFS->Unpersist(hP, !hP->Inactive()); hP->Retire(cRetc);}
863 else hP->Retire(hCB, XrdOfsFS->poscHold);
864 return SFS_OK;
865 }
866 if ((retc = hP->Select().Fchmod(theMode)))
867 XrdOfsFS->Emsg(epname, error, retc, "fchmod", hP->Name());
868 else {XrdOfsFS->poscQ->Del(hP->Name(), poscNum);
869 if (XrdOfsFS->Balancer) XrdOfsFS->Balancer->Added(hP->Name());
870 }
871 }
872
873// Handle any oustanding checkpoint
874//
875 if (myCKP)
876 {retc = myCKP->Restore();
877 if (retc) XrdOfsFS->Emsg(epname,error,retc,"restore chkpnt",hP->Name());
878 myCKP->Finished();
879 myCKP = 0;
880 }
881
882// We need to handle the cunudrum that an event may have to be sent upon
883// the final close. However, that would cause the path name to be destroyed.
884// So, we have two modes of logic where we copy out the pathname if a final
885// close actually occurs. The path is not copied if it's not final and we
886// don't bother with any of it if we need not generate an event.
887//
888 if (XrdOfsFS->evsObject && tident
889 && XrdOfsFS->evsObject->Enabled(hP->isRW ? XrdOfsEvs::Closew
890 : XrdOfsEvs::Closer))
891 {long long FSize, *retsz;
892 char pathbuff[MAXPATHLEN+8];
893 XrdOfsEvs::Event theEvent;
894 if (hP->isRW) {theEvent = XrdOfsEvs::Closew; retsz = &FSize;}
895 else { theEvent = XrdOfsEvs::Closer; retsz = 0; FSize=0;}
896 if (!(hP->Retire(cRetc, retsz, pathbuff, sizeof(pathbuff))))
897 {XrdOfsEvsInfo evInfo(tident, pathbuff, "" , 0, 0, FSize);
898 XrdOfsFS->evsObject->Notify(theEvent, evInfo);
899 }
900 } else hP->Retire(cRetc);
901
902// All done
903//
904 return (cRetc ? XrdOfsFS->Emsg(epname, error, cRetc, "close file") : SFS_OK);
905}
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
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
int Del(const char *Lfn, int Offset, int Unlink=0)
struct XrdOfsStats::StatsData Data
XrdSysMutex sdMutex
virtual void Del()
Definition XrdOfsTPC.hh:79
void Unpersist(XrdOfsHandle *hP, int xcev=1)
Definition XrdOfs.cc:2738
virtual int Fchmod(mode_t mode)
Definition XrdOss.hh:120

References XrdCmsClient::Added(), close(), XrdOfsEvs::Closer, XrdOfsEvs::Closew, XrdOfsStats::Data, XrdOfsTPC::Del(), XrdOfsPoscq::Del(), XrdOfs::Emsg(), XrdOfsEvs::Enabled(), EPNAME, XrdSfsFile::error, XrdOssDF::Fchmod(), XrdOucChkPnt::Finished(), FTRACE, XrdOfsHandle::Inactive(), XrdOfsHandle::isRW, XrdOfsHandle::Lock(), XrdSysMutex::Lock(), myCKP, myTPC, XrdOfsHandle::Name(), XrdOfsEvs::Notify(), XrdOfsStats::StatsData::numOpenP, XrdOfsStats::StatsData::numOpenR, XrdOfsStats::StatsData::numOpenW, OfsStats, oh, XrdOfsHandle::opPC, XrdOfsHandle::PoscGet(), XrdOucChkPnt::Restore(), XrdOfsHandle::Retire(), XrdOfsStats::sdMutex, XrdOfsHandle::Select(), SFS_OK, tident, XrdSysMutex::UnLock(), XrdOfs::Unpersist(), XrdOfsHandle::Usage(), 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/4]

virtual int XrdSfsFile::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.

◆ fctl() [2/4]

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 1041 of file XrdOfs.cc.

1044{
1045// See if we can do this
1046//
1047 if (cmd == SFS_FCTL_GETFD)
1048 {out_error.setErrCode(oh->Select().getFD());
1049 return SFS_OK;
1050 }
1051
1052// We don't support this
1053//
1054 out_error.setErrInfo(ENOTSUP, "fctl operation not supported");
1055
1056// Return
1057//
1058 return SFS_ERROR;
1059}
#define SFS_ERROR
#define SFS_FCTL_GETFD
virtual int getFD()
Definition XrdOss.hh:426

References XrdOssDF::getFD(), oh, XrdOfsHandle::Select(), XrdOucErrInfo::setErrCode(), XrdOucErrInfo::setErrInfo(), SFS_ERROR, SFS_FCTL_GETFD, and SFS_OK.

+ Here is the call graph for this function:

◆ fctl() [3/4]

int XrdSfsFile::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 489 of file XrdSfsInterface.cc.

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

◆ fctl() [4/4]

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 1063 of file XrdOfs.cc.

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

References XrdOfsTPC::Del(), XrdSfsFile::error, XrdOfs::FSctl(), myTPC, XrdOucErrInfo::setErrInfo(), SFS_ERROR, SFS_FCTL_SPEC1, SFS_OK, and XrdOfsFS.

+ Here is the call graph for this function:

◆ 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 XrdOfsHandle::Name(), and oh.

+ Here is the call graph for this function:

◆ 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 1732 of file XrdOfs.cc.

1743{
1744
1745// Copy out the info
1746//
1747 cxrsz = oh->Select().isCompressed(cxtype);
1748 return SFS_OK;
1749}
virtual int isCompressed(char *cxidp=0)
Definition XrdOss.hh:187

References XrdOssDF::isCompressed(), oh, XrdOfsHandle::Select(), and SFS_OK.

+ Here is the call graph for this function:

◆ 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 1575 of file XrdOfs.cc.

1583{
1584
1585// Perform the function
1586//
1587 Size = oh->Select().getMmap(Addr);
1588
1589 return SFS_OK;
1590}
virtual off_t getMmap(void **addr)
Definition XrdOss.hh:176

References XrdOssDF::getMmap(), oh, XrdOfsHandle::Select(), and SFS_OK.

+ Here is the call graph for this function:

◆ 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])
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;
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
#define open
Definition XrdPosix.hh:76
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
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
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:429
mode_t fMask[2]
Definition XrdOfs.hh:385
XrdOfsEvr evrObject
Definition XrdOfs.hh:428
int tpcRdrPort[2]
Definition XrdOfs.hh:390
char * tpcRdrHost[2]
Definition XrdOfs.hh:389
int Options
Definition XrdOfs.hh:379
static int fsError(XrdOucErrInfo &myError, int rc)
Definition XrdOfs.cc:2628
@ RdrTPC
Definition XrdOfs.hh:376
int Stall(XrdOucErrInfo &, int, const char *)
Definition XrdOfs.cc:2702
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 XrdAccAuthorize::Access(), XrdOfsPoscq::Add(), XrdCmsClient::Added(), XrdOfsHandle::Alloc(), AOP_Create, AOP_Excl_Create, AOP_Read, AOP_Update, AUTHORIZE, XrdOfsTPC::Authorize(), XrdOfsPoscq::Commit(), XrdOfsEvs::Create, XrdOss::Create(), XrdOfsStats::Data, XrdOfsPoscq::Del(), dorawio, XrdOfs::Emsg(), XrdSysError::Emsg(), XrdOfsEvs::Enabled(), EPNAME, XrdSfsFile::error, XrdOfs::evrObject, XrdOfs::Finder, XrdOfs::fMask, XrdOfs::fsError(), FTRACE, XrdOucErrInfo::getUCap(), Xrd::hex1, XrdOfsHandle::isCompressed, XrdOss::Lfn2Pfn(), XrdCmsClient::Locate(), XrdSysMutex::Lock(), Mode, myTPC, XrdOss::newFile(), XrdOfsEvs::Notify(), XrdOfsStats::StatsData::numOpenP, XrdOfsStats::StatsData::numOpenR, XrdOfsStats::StatsData::numOpenW, O_DIRECT, Xrd::oct1, OfsEroute, OfsStats, oh, OOIDENTENV, open, XrdOfsEvs::Openr, XrdOfsEvs::Openw, XrdOfsHandle::opPC, XrdOfsHandle::opRW, XrdOfs::Options, Path, XrdOfs::RdrTPC, XrdCmsClient::Removed(), XrdOfsHandle::Retire(), XrdOfsStats::sdMutex, XrdOucErrInfo::setErrInfo(), 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, XrdOfs::Stall(), tident, XrdOucTPC::tpcDlgOn, XrdOucTPC::tpcKey, XrdOfs::tpcRdrHost, XrdOfs::tpcRdrPort, XrdOucEI::uLclF, XrdSysMutex::UnLock(), XrdOfsHandle::Usage(), XrdOucEI::uUrlOK, XrdOfsTPC::Validate(), XrdOfsEvr::Wait4Event(), XrdOfsFS, XrdOfsOss, XRDOSS_mkpath, XRDOSS_new, XRDSFS_POSCPEND, and ZTRACE.

+ Here is the call 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 1142 of file XrdOfs.cc.

1143{
1144 EPNAME("aiopgread");
1145 uint64_t pgOpts;
1146 int rc;
1147
1148// If the oss plugin does not support pgRead or if we are doing rawio or the
1149// file is compressed then revert to using a standard async read. Note that
1150// the standard async read will generate checksums if a vector is present.
1151// Note: we set cksVec in the request to nil to indicate simulation!
1152//
1153 if (!XrdOfsFS->OssHasPGrw || dorawio || oh->isCompressed)
1154 {aioparm->cksVec = 0;
1155 return XrdOfsFile::read(aioparm);
1156 }
1157
1158// Perform required tracing
1159//
1160 FTRACE(aio, aioparm->sfsAio.aio_nbytes <<"@" <<aioparm->sfsAio.aio_offset);
1161
1162// Make sure the offset is not too large
1163//
1164#if _FILE_OFFSET_BITS!=64
1165 if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1166 return XrdOfsFS->Emsg(epname, error, EFBIG, "pgRead", oh->Name());
1167#endif
1168
1169// Pass through any flags of interest
1170//
1172 else pgOpts = 0;
1173
1174// Issue the read. Only true errors are returned here.
1175//
1176 if ((rc = oh->Select().pgRead(aioparm, pgOpts)) < 0)
1177 return XrdOfsFS->Emsg(epname, error, rc, "pgRead", oh->Name());
1178
1179// All done
1180//
1181 return SFS_OK;
1182}
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:1307
static const uint64_t Verify
all: Verify checksums
Definition XrdOss.hh:223
virtual ssize_t pgRead(void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
Definition XrdOss.cc:160
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, XrdOfs::Emsg(), EPNAME, XrdSfsFile::error, FTRACE, XrdOfsHandle::isCompressed, XrdOfsHandle::Name(), oh, opts, XrdOssDF::pgRead(), read(), XrdOfsHandle::Select(), 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 1092 of file XrdOfs.cc.

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

References XrdOucPgrwUtils::csCalc(), dorawio, XrdOfs::Emsg(), EPNAME, XrdSfsFile::error, FTRACE, XrdOfsHandle::Name(), oh, opts, XrdOssDF::pgRead(), read, read(), XrdOfsHandle::Select(), 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 1242 of file XrdOfs.cc.

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

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

References XrdOfs::Emsg(), XrdOfsEvs::Enabled(), EPNAME, XrdSfsFile::error, FTRACE, XrdOfsEvs::Fwrite, XrdOfsHandle::isChanged, XrdOfsHandle::isPending, oh, opts, XrdOssDF::pgWrite(), XrdOfsHandle::Select(), SFS_ERROR, XrdOssDF::Verify, XrdSfsFile::Verify, write, 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 1432 of file XrdOfs.cc.

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

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, XrdSfsAio::doneRead(), XrdOfs::Emsg(), EPNAME, XrdSfsFile::error, FTRACE, XrdOfsHandle::isCompressed, XrdOfsHandle::Name(), oh, read, XrdOssDF::Read(), XrdSfsAio::Result, XrdOfsHandle::Select(), 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 1346 of file XrdOfs.cc.

1360{
1361 EPNAME("read");
1362 XrdSfsXferSize nbytes;
1363
1364// Perform required tracing
1365//
1366 FTRACE(read, blen <<"@" <<offset);
1367
1368// Make sure the offset is not too large
1369//
1370#if _FILE_OFFSET_BITS!=64
1371 if (offset > 0x000000007fffffff)
1372 return XrdOfsFS->Emsg(epname, error, EFBIG, "read", oh->Name());
1373#endif
1374
1375// Now read the actual number of bytes
1376//
1377 nbytes = (dorawio ?
1378 (XrdSfsXferSize)(oh->Select().ReadRaw((void *)buff,
1379 (off_t)offset, (size_t)blen))
1380 : (XrdSfsXferSize)(oh->Select().Read((void *)buff,
1381 (off_t)offset, (size_t)blen)));
1382 if (nbytes < 0)
1383 return XrdOfsFS->Emsg(epname, error, (int)nbytes, "read", oh->Name());
1384
1385// Return number of bytes read
1386//
1387 return nbytes;
1388}
virtual ssize_t ReadRaw(void *buffer, off_t offset, size_t size)
Definition XrdOss.hh:319
ReadImpl< false > Read(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, uint16_t timeout=0)
Factory for creating ReadImpl objects.

References dorawio, XrdOfs::Emsg(), EPNAME, XrdSfsFile::error, FTRACE, XrdOfsHandle::Name(), oh, read, XrdOssDF::Read(), XrdOssDF::ReadRaw(), XrdOfsHandle::Select(), 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 1307 of file XrdOfs.cc.

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

References XrdOfs::Emsg(), EPNAME, XrdSfsFile::error, FTRACE, XrdOfsHandle::Name(), oh, read, XrdOssDF::Read(), XrdOfsHandle::Select(), and XrdOfsFS.

Referenced by pgRead(), and pgRead().

+ 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 1394 of file XrdOfs.cc.

1408{
1409 EPNAME("readv");
1410
1411 XrdSfsXferSize nbytes = oh->Select().ReadV(readV, readCount);
1412 if (nbytes < 0)
1413 return XrdOfsFS->Emsg(epname, error, (int)nbytes, "readv", oh->Name());
1414
1415 return nbytes;
1416
1417}
virtual ssize_t ReadV(XrdOucIOVec *readV, int rdvcnt)
Definition XrdOss.cc:236

References XrdOfs::Emsg(), EPNAME, XrdSfsFile::error, XrdOfsHandle::Name(), oh, XrdOssDF::ReadV(), XrdOfsHandle::Select(), and XrdOfsFS.

+ Here is the call graph for this function:

◆ 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 1596 of file XrdOfs.cc.

1604{
1605 EPNAME("fstat");
1606 int retc;
1607
1608// Perform any required tracing
1609//
1610 FTRACE(stat, "");
1611
1612// Perform the function
1613//
1614 if ((retc = oh->Select().Fstat(buf)) < 0)
1615 return XrdOfsFS->Emsg(epname,error,retc,"get state for",oh->Name());
1616
1617 return SFS_OK;
1618}
#define stat(a, b)
Definition XrdPosix.hh:101
virtual int Fstat(struct stat *buf)
Definition XrdOss.hh:136

References XrdOfs::Emsg(), EPNAME, XrdSfsFile::error, XrdOssDF::Fstat(), FTRACE, XrdOfsHandle::Name(), oh, XrdOfsHandle::Select(), SFS_OK, stat, and XrdOfsFS.

+ Here is the call 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 1624 of file XrdOfs.cc.

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

References XrdOfs::Emsg(), EPNAME, XrdSfsFile::error, XrdOssDF::Fsync(), FTRACE, XrdOfsHandle::isPending, XrdOfsHandle::Lock(), myTPC, oh, XrdOfsHandle::Select(), SFS_OK, sync(), XrdOfsTPC::Sync(), XrdOfsHandle::UnLock(), 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 1674 of file XrdOfs.cc.

1675{
1676 aiop->Result = this->sync();
1677 aiop->doneWrite();
1678 return 0;
1679}

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 1685 of file XrdOfs.cc.

1699{
1700 EPNAME("trunc");
1701 int retc;
1702
1703// Lock the file handle and perform any tracing
1704//
1705 FTRACE(truncate, "len=" <<flen);
1706
1707// Make sure the offset is not too large
1708//
1709 if (sizeof(off_t) < sizeof(flen) && flen > 0x000000007fffffff)
1710 return XrdOfsFS->Emsg(epname, error, EFBIG, "truncate", oh);
1711
1712// Silly Castor stuff
1713//
1714 if (XrdOfsFS->evsObject && !(oh->isChanged)
1715 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1716
1717// Perform the function
1718//
1719 oh->isPending = 1;
1720 if ((retc = oh->Select().Ftruncate(flen)))
1721 return XrdOfsFS->Emsg(epname, error, retc, "truncate", oh);
1722
1723// Indicate Success
1724//
1725 return SFS_OK;
1726}
#define truncate(a, b)
Definition XrdPosix.hh:111
virtual int Ftruncate(unsigned long long flen)
Definition XrdOss.hh:164

References XrdOfs::Emsg(), XrdOfsEvs::Enabled(), EPNAME, XrdSfsFile::error, FTRACE, XrdOssDF::Ftruncate(), XrdOfsEvs::Fwrite, XrdOfsHandle::isChanged, XrdOfsHandle::isPending, oh, XrdOfsHandle::Select(), SFS_OK, truncate, and XrdOfsFS.

+ Here is the call 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 1528 of file XrdOfs.cc.

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

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, XrdSfsAio::doneWrite(), XrdOfs::Emsg(), XrdOfsEvs::Enabled(), EPNAME, XrdSfsFile::error, FTRACE, XrdOfsEvs::Fwrite, XrdOfsHandle::isChanged, XrdOfsHandle::isPending, XrdOfsHandle::isRW, XrdOfsHandle::Name(), oh, XrdOfsHandle::opPC, XrdSfsAio::Result, XrdOfsHandle::Select(), SFS_OK, XrdSfsAio::sfsAio, write, XrdOssDF::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 1472 of file XrdOfs.cc.

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

References XrdOfs::Emsg(), XrdOfsEvs::Enabled(), EPNAME, XrdSfsFile::error, FTRACE, XrdOfsEvs::Fwrite, XrdOfsHandle::isChanged, XrdOfsHandle::isPending, oh, XrdOfsHandle::Select(), write, XrdOssDF::Write(), and XrdOfsFS.

Referenced by pgWrite(), and pgWrite().

+ 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 202 of file XrdOfs.hh.

Referenced by checkpoint().

◆ dorawio

int XrdOfsFile::dorawio
protected

Definition at line 200 of file XrdOfs.hh.

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

◆ myCKP

XrdOucChkPnt* XrdOfsFile::myCKP
protected

Definition at line 199 of file XrdOfs.hh.

Referenced by checkpoint(), and close().

◆ myTPC

XrdOfsTPC* XrdOfsFile::myTPC
protected

Definition at line 198 of file XrdOfs.hh.

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

◆ oh

◆ tident

const char* XrdOfsFile::tident
protected

Definition at line 196 of file XrdOfs.hh.

Referenced by close(), and open().

◆ viaDel

char XrdOfsFile::viaDel
protected

Definition at line 201 of file XrdOfs.hh.

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


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