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 Clone (const std::vector< XrdOucCloneSeg > &cVec)
 
int Clone (XrdSfsFile &srcFile)
 
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 XrdSfsXferSize read (XrdOucRangeList &rlist)
 
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
 
bool 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 115 of file XrdOfs.hh.

Constructor & Destructor Documentation

◆ XrdOfsFile()

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

Definition at line 462 of file XrdOfs.cc.

463 : XrdSfsFile(eInfo), tident(user ? user : ""),
464 oh(XrdOfs::dummyHandle), myTPC(0), myCKP(0),
465 dorawio(0), viaDel(false), ckpBad(false) {}
bool viaDel
Definition XrdOfs.hh:208
const char * tident
Definition XrdOfs.hh:203
XrdOfsHandle * oh
Definition XrdOfs.hh:204
int dorawio
Definition XrdOfs.hh:207
XrdOucChkPnt * myCKP
Definition XrdOfs.hh:206
bool ckpBad
Definition XrdOfs.hh:209
XrdOfsTPC * myTPC
Definition XrdOfs.hh:205
XrdSfsFile(const char *user=0, int MonID=0)

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

Referenced by XrdOfsFileFull::XrdOfsFileFull(), and Clone().

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

◆ ~XrdOfsFile()

XrdOfsFile::~XrdOfsFile ( )
inline

Definition at line 197 of file XrdOfs.hh.

197{viaDel = true; if (oh) close();}
int close()
Definition XrdOfs.cc:899

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

1011{
1012 EPNAME("chkpnt");
1013 const char *ckpName;
1014 int rc;
1015 bool readok;
1016
1017// Make sure we are active
1018//
1019 if (oh->Inactive()) return XrdOfsFS->Emsg(epname, error, EBADF,
1020 "handle checkpoint", (const char *)0);
1021
1022// If checkpointing is disabled, the don't accept this request.
1023//
1024 if (!XrdOfsConfigCP::Enabled) return XrdOfsFS->Emsg(epname, error, ENOTSUP,
1025 "handle disabled checkpoint", (const char *)0);
1026
1027// If this checkpoint is bad then only a delete, query or restore is allowed.
1028//
1029 if (ckpBad && (act == XrdSfsFile::cpTrunc || act == XrdSfsFile::cpWrite))
1030 return XrdOfsFS->Emsg(epname, error, EIDRM, "extend checkpoint "
1031 "(only delete or restore possible) for", oh->Name());
1032
1033// Handle the request
1034//
1035 switch(act)
1037 ckpName = "create checkpoint for";
1038 if ((rc = CreateCKP())) return rc;
1039 if ((rc = myCKP->Create())) {myCKP->Finished(); myCKP = 0;}
1040 break;
1042 ckpName = "delete checkpoint for";
1043 if (!myCKP) rc = ENOENT;
1044 else {rc = myCKP->Delete();
1045 myCKP->Finished();
1046 myCKP = 0;
1047 ckpBad = false;
1048 }
1049 break;
1051 ckpName = "query checkpoint for";
1052 if (!range || n <= 0)
1053 return XrdOfsFS->Emsg(epname, error, EINVAL,
1054 "query checkpoint limits for", oh->Name());
1055 rc = (myCKP ? myCKP->Query(*range) : ENOENT);
1056 break;
1058 ckpName = "restore checkpoint for";
1059 if (!myCKP) rc = ENOENT;
1060 else {if (!(rc = myCKP->Restore(&readok)))
1061 {myCKP->Finished();
1062 myCKP = 0;
1063 ckpBad = false;
1064 } else {
1065 if (!(oh->Select().DFType() & XrdOssDF::DF_isProxy))
1066 oh->Suppress((readok ? 0 : -EDOM));
1067 ckpBad = true;
1068 }
1069 }
1070 break;
1072 ckpName = "checkpoint truncate";
1073 if (!range) rc = EINVAL;
1074 else if (!myCKP) rc = ENOENT;
1075 else if ((rc = myCKP->Truncate(range))) ckpBad = true;
1076 break;
1078 ckpName = "checkpoint write";
1079 if (!range || n <= 0) rc = EINVAL;
1080 else if (!myCKP) rc = ENOENT;
1081 else if ((rc = myCKP->Write(range, n))) ckpBad = true;
1082 break;
1083
1084 default: return XrdOfsFS->Emsg(epname, error, EINVAL,
1085 "decode checkpoint request for", oh->Name());
1086 };
1087
1088// Complete as needed
1089//
1090 if (rc) return XrdOfsFS->Emsg(epname, error, rc, ckpName, oh->Name());
1091
1092// Trace success and return
1093//
1094 FTRACE(chkpnt, ckpName);
1095 return SFS_OK;
1096}
#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, bool posChk=false, bool chktype=true)
Definition XrdOfs.cc:2637
static const uint16_t DF_isProxy
Object is a proxy object.
Definition XrdOss.hh:434
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.

◆ Clone() [1/2]

int XrdOfsFile::Clone ( const std::vector< XrdOucCloneSeg > & cVec)
virtual

Clone contents of a file from one or more other files.

Parameters
cVec- A vector of struct XrdOucCloneSeg describing the action.
Returns
One of SFS_OK or SFS_ERROR.

Reimplemented from XrdSfsFile.

Definition at line 881 of file XrdOfs.cc.

882{
883 EPNAME("Clone");
884 int rc = oh->Select().Clone(cVec);
885
886 if (rc < 0)
887 {char etxt[4096];
888 snprintf(etxt,sizeof(etxt),"%s from file ranges",oh->Name());
889 return XrdOfsFS->Emsg(epname, error, rc, "clone", etxt);
890 }
891
892 return SFS_OK;
893}

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

◆ Clone() [2/2]

int XrdOfsFile::Clone ( XrdSfsFile & srcFile)
virtual

Clone contents of a file from another file.

Parameters
srcFile- Reference to the file to used to clone contents of this file,
Returns
One of SFS_OK or SFS_ERROR.

Reimplemented from XrdSfsFile.

Definition at line 864 of file XrdOfs.cc.

865{
866 EPNAME("Clone");
867 XrdOfsFile& ofsFile = static_cast<XrdOfsFile&>(srcFile);
868 int rc = oh->Select().Clone(ofsFile.oh->Select());
869
870 if (rc < 0)
871 {char etxt[4096];
872 snprintf(etxt,sizeof(etxt),"%s from %s",oh->Name(),ofsFile.oh->Name());
873 return XrdOfsFS->Emsg(epname, error, rc, "clone", etxt);
874 }
875
876 return SFS_OK;
877}
XrdOfsFile(XrdOucErrInfo &eInfo, const char *user)
Definition XrdOfs.cc:462
XrdOssDF & Select(void)
const char * Name()

References XrdOfsFile(), XrdSfsFile::XrdSfsFile(), EPNAME, XrdSfsFile::error, XrdOfsHandle::Name(), oh, XrdOfsHandle::Select(), SFS_OK, 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 899 of file XrdOfs.cc.

907{
908 EPNAME("close");
909
910 class CloseFH : public XrdOfsHanCB
911 {public: void Retired(XrdOfsHandle *hP) {XrdOfsFS->Unpersist(hP);}};
912 static XrdOfsHanCB *hCB = static_cast<XrdOfsHanCB *>(new CloseFH);
913
914 XrdOfsHandle *hP;
915 int poscNum, retc, cRetc = 0;
916 short theMode;
917
918// Trace the call
919//
920 FTRACE(close, "use=" <<oh->Usage()); // Unreliable trace, no origin lock
921
922// Verify the handle (we briefly maintain a global lock)
923//
924 XrdOfsFS->ocMutex.Lock();
925 if (oh == XrdOfs::dummyHandle)
926 {XrdOfsFS->ocMutex.UnLock(); return SFS_OK;}
927 if ((oh->Inactive()))
928 {XrdOfsFS->ocMutex.UnLock();
929 return XrdOfsFS->Emsg(epname, error, EBADF, "close file");
930 }
931 hP = oh; oh = XrdOfs::dummyHandle;
932 XrdOfsFS->ocMutex.UnLock();
933 hP->Lock();
934
935// Delete the tpc object, if any
936//
937 if (myTPC) {myTPC->Del(); myTPC = 0;}
938
939// Maintain statistics
940//
942 if (!(hP->isRW)) OfsStats.Data.numOpenR--;
943 else {OfsStats.Data.numOpenW--;
945 }
947
948// Do an fsync() on this file prior to closing if it was open r/w
949//
950 if (ocFsync && hP->isRW) hP->Select().Fsync(); // Ignore errors
951
952// If this file was tagged as a POSC then we need to make sure it will persist
953// Note that we unpersist the file immediately when it's inactive or if no hold
954// time is allowed. Also, close events occur only for active handles. If the
955// entry was via delete then we ignore the close return code as there is no
956// one to handle it on the other side.
957//
958 if ((poscNum = hP->PoscGet(theMode, !viaDel)))
959 {if (viaDel)
960 {if (hP->Inactive() || !XrdOfsFS->poscHold)
961 {XrdOfsFS->Unpersist(hP, !hP->Inactive()); hP->Retire(cRetc);}
962 else hP->Retire(hCB, XrdOfsFS->poscHold);
963 return SFS_OK;
964 }
965 if ((retc = hP->Select().Fchmod(theMode)))
966 XrdOfsFS->Emsg(epname, error, retc, "fchmod", hP->Name());
967 else {XrdOfsFS->poscQ->Del(hP->Name(), poscNum);
968 if (XrdOfsFS->Balancer) XrdOfsFS->Balancer->Added(hP->Name());
969 }
970 }
971
972// Handle any oustanding checkpoint
973//
974 if (myCKP)
975 {retc = myCKP->Restore();
976 if (retc) XrdOfsFS->Emsg(epname,error,retc,"restore chkpnt",hP->Name());
977 myCKP->Finished();
978 myCKP = 0;
979 }
980
981// We need to handle the cunudrum that an event may have to be sent upon
982// the final close. However, that would cause the path name to be destroyed.
983// So, we have two modes of logic where we copy out the pathname if a final
984// close actually occurs. The path is not copied if it's not final and we
985// don't bother with any of it if we need not generate an event.
986//
987 if (XrdOfsFS->evsObject && tident
988 && XrdOfsFS->evsObject->Enabled(hP->isRW ? XrdOfsEvs::Closew
990 {long long FSize, *retsz;
991 char pathbuff[MAXPATHLEN+8];
992 XrdOfsEvs::Event theEvent;
993 if (hP->isRW) {theEvent = XrdOfsEvs::Closew; retsz = &FSize;}
994 else { theEvent = XrdOfsEvs::Closer; retsz = 0; FSize=0;}
995 if (!(hP->Retire(cRetc, retsz, pathbuff, sizeof(pathbuff))))
996 {XrdOfsEvsInfo evInfo(tident, pathbuff, "" , 0, 0, FSize);
997 XrdOfsFS->evsObject->Notify(theEvent, evInfo);
998 }
999 } else hP->Retire(cRetc);
1000
1001// All done
1002//
1003 return (cRetc ? XrdOfsFS->Emsg(epname, error, cRetc, "close file") : SFS_OK);
1004}
XrdOfsStats OfsStats
Definition XrdOfs.cc:115
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:199
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
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:2947
virtual int Fsync()
Definition XrdOss.hh:172
virtual int Fchmod(mode_t mode)
Definition XrdOss.hh:148

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

1145{
1146// See if we can do this
1147//
1148 if (cmd == SFS_FCTL_GETFD)
1149 {out_error.setErrCode(oh->Select().getFD());
1150 return SFS_OK;
1151 }
1152
1153// We don't support this
1154//
1155 out_error.setErrInfo(ENOTSUP, "fctl operation not supported");
1156
1157// Return
1158//
1159 return SFS_ERROR;
1160}
#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 V1 SFS_FCTL_SPEC2 Perform implementation defined action V2
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 1164 of file XrdOfs.cc.

1166{ // 12345678901234
1167 EPNAME("fctl");
1168 static const char *fctlArg = "ofs.tpc cancel";
1169 static const int fctlAsz = 15;
1170
1171// For QFINFO we simply pass it to the Oss layer
1172//
1173 if (cmd == SFS_FCTL_QFINFO)
1174 {char* resp = 0;;
1175 int rc = oh->Select().Fctl(XrdOssDF::Fctl_QFinfo, alen, args, &resp);
1176 if (rc < 0)
1177 {if (resp) delete[] resp;
1178 return XrdOfsFS->Emsg(epname,error,rc,"fctl",oh,false,false);
1179 }
1180 if (resp)
1181 {if ((rc = strlen(resp)))
1182 {error.setErrInfo(rc, resp);
1183 delete[] resp;
1184 return SFS_DATA;
1185 }
1186 delete[] resp;
1187 }
1188 return SFS_OK;
1189 }
1190
1191// See if the is a tpc cancellation (the only thing we support here)
1192//
1193 if (cmd != SFS_FCTL_SPEC1 || !args || alen < fctlAsz || strcmp(fctlArg,args))
1194 return XrdOfsFS->FSctl(*this, cmd, alen, args, client);
1195
1196// Check if we have a tpc operation in progress
1197//
1198 if (!myTPC)
1199 {error.setErrInfo(ESRCH, "tpc operation not found");
1200 return SFS_ERROR;
1201 }
1202
1203// Cancel the tpc
1204//
1205 myTPC->Del();
1206 myTPC = 0;
1207 return SFS_OK;
1208}
#define SFS_DATA
#define SFS_FCTL_QFINFO
#define SFS_FCTL_SPEC1
int FSctl(const int cmd, XrdSfsFSctl &args, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0)
static const int Fctl_QFinfo
Definition XrdOss.hh:461

References EPNAME, XrdSfsFile::error, XrdOssDF::Fctl_QFinfo, myTPC, oh, SFS_DATA, SFS_ERROR, SFS_FCTL_QFINFO, 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 145 of file XrdOfs.hh.

145{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 1854 of file XrdOfs.cc.

1865{
1866
1867// Copy out the info
1868//
1869 cxrsz = oh->Select().isCompressed(cxtype);
1870 return SFS_OK;
1871}

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

1705{
1706
1707// Perform the function
1708//
1709 Size = oh->Select().getMmap(Addr);
1710
1711 return SFS_OK;
1712}

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_CREATAT create the file in a perticular FS 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
Note
When SFS_O_CREATAT is specified, the CGI should contain an element oss.coloc=<path> where <path> is URL encoded and determines the filesystem in which the new file should be created.

Implements XrdSfsFile.

Definition at line 471 of file XrdOfs.cc.

502{
503 EPNAME("open");
504 static const int crMask = (SFS_O_CREAT | SFS_O_TRUNC);
505 static const int opMask = (SFS_O_RDONLY | SFS_O_WRONLY | SFS_O_RDWR);
506
507 struct OpenHelper
508 {const char *Path;
509 XrdOfsHandle *hP;
510 XrdOssDF *fP;
511 XrdCksCalc *cP;
512 int poscNum;
513
514 int OK() {hP=0; fP=0; cP=0; poscNum=0; return SFS_OK;}
515
516 OpenHelper(const char *path)
517 : Path(path), hP(0), fP(0), cP(0), poscNum(0) {}
518
519 ~OpenHelper()
520 {int retc;
521 if (hP) hP->Retire(retc);
522 if (fP) delete fP;
523 if (cP) cP->Recycle();
524 if (poscNum > 0) XrdOfsFS->poscQ->Del(Path, poscNum, 1);
525 }
526 } oP(path);
527
528 mode_t theMode = (Mode | XrdOfsFS->fMask[0]) & XrdOfsFS->fMask[1];
529 const char *tpcKey;
530 int retc, isPosc = 0, crOpts = 0, isRW = 0, open_flag = 0;
531 int find_flag = open_mode & (SFS_O_NOWAIT | SFS_O_RESET | SFS_O_MULTIW);
532 XrdOucEnv Open_Env(info,0,client);
533
534// Trace entry
535//
536 ZTRACE(open, Xrd::hex1 <<open_mode <<"-" <<Xrd::oct1 <<Mode <<" ("
537 <<Xrd::oct1 <<theMode <<") fn=" <<path);
538
539// Verify that this object is not already associated with an open file
540//
541 XrdOfsFS->ocMutex.Lock();
542 if (oh != XrdOfs::dummyHandle)
543 {XrdOfsFS->ocMutex.UnLock();
544 return XrdOfsFS->Emsg(epname,error,EADDRINUSE,"open file",path);
545 }
546 XrdOfsFS->ocMutex.UnLock();
547
548// Handle the open mode options
549//
550 if (open_mode & crMask)
551 {crOpts = (Mode & SFS_O_MKPTH ? XRDOSS_mkpath : 0);
552 if (XrdOfsFS->poscQ && ((open_mode & SFS_O_POSC) ||
553 XrdOfsFS->poscAuto || Open_Env.Get("ofs.posc")))
554 {isPosc = 1; isRW = XrdOfsHandle::opPC;}
555 else isRW = XrdOfsHandle::opRW;
556 if (open_mode & SFS_O_CREAT)
557 {open_flag = O_RDWR | O_CREAT | O_EXCL;
558 find_flag |= SFS_O_RDWR | SFS_O_CREAT | (open_mode & SFS_O_REPLICA);
559 crOpts |= XRDOSS_new;
560 } else {
561 open_flag |= O_RDWR | O_CREAT | O_TRUNC;
562 find_flag |= SFS_O_RDWR | SFS_O_TRUNC;
563 }
564 if (XrdOfsFS->WantCksRT())
565 {const char* cipher = 0;
566 if ((retc = XrdOfsFS->SetupCksRT(oP.cP, Open_Env, cipher)))
567 {char eBuff[80];
568 snprintf(eBuff, sizeof(eBuff), "setup real-time %s checksum",
569 (cipher ? cipher : "unknown"));
570 return XrdOfsFS->Emsg(epname, error, retc, eBuff, path);
571 }
572 }
573 }
574 else
575 switch(open_mode & opMask)
576 {case SFS_O_RDONLY: open_flag = O_RDONLY; find_flag |= SFS_O_RDONLY;
577 break;
578 case SFS_O_WRONLY: open_flag = O_WRONLY; find_flag |= SFS_O_WRONLY;
579 isRW = XrdOfsHandle::opRW;
580 if (XrdOfsFS->poscQ && ((open_mode & SFS_O_POSC) ||
581 Open_Env.Get("ofs.posc"))) oP.poscNum = -1;
582 break;
583 case SFS_O_RDWR: open_flag = O_RDWR; find_flag |= SFS_O_RDWR;
584 isRW = XrdOfsHandle::opRW;
585 if (XrdOfsFS->poscQ && ((open_mode & SFS_O_POSC) ||
586 Open_Env.Get("ofs.posc"))) oP.poscNum = -1;
587 break;
588 default: open_flag = O_RDONLY; find_flag |= SFS_O_RDONLY;
589 break;
590 }
591
592// Preset TPC handling
593//
594 tpcKey = Open_Env.Get(XrdOucTPC::tpcKey);
595
596// Check if we will be redirecting the tpc request
597//
598 if (tpcKey && isRW && (XrdOfsFS->Options & XrdOfs::RdrTPC))
599 {const char *dOn = Open_Env.Get(XrdOucTPC::tpcDlgOn);
600 int k = ((dOn && *dOn == '1') || strcmp(tpcKey, "delegate") ? 1 : 0);
601 if (XrdOfsFS->tpcRdrHost[k])
602 {error.setErrInfo(XrdOfsFS->tpcRdrPort[k], XrdOfsFS->tpcRdrHost[k]);
603 return SFS_REDIRECT;
604 }
605 }
606
607// If we have a finder object, use it to direct the client. The final
608// destination will apply the security that is needed
609//
610 if (XrdOfsFS->Finder && (retc = XrdOfsFS->Finder->Locate(error, path,
611 find_flag, &Open_Env)))
612 return XrdOfsFS->fsError(error, retc);
613
614// Preset TPC handling and if not allowed, complain
615//
616 if (tpcKey && (open_mode & SFS_O_NOTPC))
617 return XrdOfsFS->Emsg(epname, error, EPROTOTYPE, "tpc", path,
618 "+TPC prohibited due to security configuration");
619
620// Create the file if so requested o/w try to attach the file
621//
622 if (open_flag & O_CREAT)
623 {// Apply security, as needed
624 //
625 // If we aren't requesting O_EXCL, one needs AOP_Create
626 bool overwrite_permitted = true;
627 if (!(open_flag & O_EXCL))
628 {if (client && XrdOfsFS->Authorization &&
629 !XrdOfsFS->Authorization->Access(client, path, AOP_Create, &Open_Env))
630 { // We don't have the ability to create a file without O_EXCL. If we have AOP_Excl_Create,
631 // then manipulate the open flags and see if we're successful with it.
632 AUTHORIZE(client,&Open_Env,AOP_Excl_Create,"create",path,error);
633 overwrite_permitted = false;
634 open_flag |= O_EXCL;
635 open_flag &= ~O_TRUNC;
636 }
637 }
638 // If we are in O_EXCL mode, then we accept either AOP_Excl_Create or AOP_Create
639 else if (client && XrdOfsFS->Authorization &&
640 !XrdOfsFS->Authorization->Access(client, path, AOP_Create, &Open_Env))
641 {AUTHORIZE(client,&Open_Env,AOP_Excl_Create,"create",path,error);
642 // In this case, we don't have AOP_Create but we do have AOP_Excl_Create; note that
643 // overwrites are not permitted (this is later used to correct an error code).
644 overwrite_permitted = false;
645 }
646
647 OOIDENTENV(client, Open_Env);
648
649 // For ephemeral file, we must enter the file into the queue
650 //
651 if (isPosc)
652 {bool isNew = (open_mode & SFS_O_TRUNC) == 0;
653 if ((oP.poscNum = XrdOfsFS->poscQ->Add(tident, path, isNew)) < 0)
654 return XrdOfsFS->Emsg(epname, error, oP.poscNum, "pcreate", path,
655 "+ofs_open: failed to enter file into posc queue");
656 }
657
658 // If placement information is present provide a hint to the oss plugin
659 //
660 if ((open_mode & ~SFS_O_CREAT) & SFS_O_CREATAT) crOpts |= XRDOSS_coloc;
661
662 // Create the file. If ENOTSUP is returned, promote the creation to
663 // the subsequent open. This is to accomodate proxy support.
664 //
665 if ((retc = XrdOfsOss->Create(tident, path, theMode, Open_Env,
666 ((open_flag << 8) | crOpts))))
667 {if (retc > 0) return XrdOfsFS->Stall(error, retc, path);
668 if (retc == -EINPROGRESS)
671 }
672 if (retc != -ENOTSUP)
673 {// If we tried to overwrite an existing file but do not have the AOP_Create
674 // privilege, then ensure we generate a 'permission denied' instead of 'exists'
675 if ((open_flag & O_EXCL) && retc == -EEXIST && !overwrite_permitted)
676 {retc = -EACCES;}
677 if (XrdOfsFS->Balancer) XrdOfsFS->Balancer->Removed(path);
678 return XrdOfsFS->Emsg(epname, error, retc, "create", path);
679 }
680 } else {
681 if (XrdOfsFS->Balancer) XrdOfsFS->Balancer->Added(path, isPosc);
682 open_flag = O_RDWR|O_TRUNC;
683 if (XrdOfsFS->evsObject
684 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Create))
685 {XrdOfsEvsInfo evInfo(tident,path,info,&Open_Env,Mode);
686 XrdOfsFS->evsObject->Notify(XrdOfsEvs::Create, evInfo);
687 }
688 }
689
690 } else {
691
692 // Apply security, as needed
693 //
694 if (tpcKey && !isRW)
695 {XrdOfsTPC::Facts Args(client, &error, &Open_Env, tpcKey, path);
696 if ((retc = XrdOfsTPC::Authorize(&myTPC, Args))) return retc;
697 } else {AUTHORIZE(client, &Open_Env, (isRW?AOP_Update:AOP_Read),
698 "open", path, error);
699 }
700 OOIDENTENV(client, Open_Env);
701 }
702
703// Get a handle for this file.
704//
705 if ((retc = XrdOfsHandle::Alloc(path, isRW, &oP.hP)))
706 {if (retc > 0) return XrdOfsFS->Stall(error, retc, path);
707 return XrdOfsFS->Emsg(epname, error, retc, "attach", path);
708 }
709
710// If this is a third party copy and we are the destination, then validate
711// specification at this point and setup to transfer. Note that if the
712// call fails and auto removal is enabled, the file we created will be deleted.
713//
714 if (tpcKey && isRW)
715 {char pfnbuff[MAXPATHLEN+8]; const char *pfnP;
716 if (!(pfnP = XrdOfsOss->Lfn2Pfn(path, pfnbuff, MAXPATHLEN, retc)))
717 return XrdOfsFS->Emsg(epname, error, retc, "open", path,
718 "+ofs_open: mapping tpc target lfn to pfn failed");
719 XrdOfsTPC::Facts Args(client, &error, &Open_Env, tpcKey, path, pfnP);
720 if ((retc = XrdOfsTPC::Validate(&myTPC, Args))) return retc;
721 }
722
723// Assign/transfer posc ownership. We may need to delay the client if the
724// file create ownership does not match and this is not a create request.
725//
726 if (oP.hP->isRW == XrdOfsHandle::opPC)
727 {if (!isRW) return XrdOfsFS->Stall(error, -1, path);
728 if ((retc = oP.hP->PoscSet(tident, oP.poscNum, theMode)))
729 {if (retc > 0) XrdOfsFS->poscQ->Del(path, retc);
730 else return XrdOfsFS->Emsg(epname, error, retc, "access", path,
731 "+ofs_open: posc mode initiation failed");
732 }
733 }
734
735// If this is a previously existing handle, we are almost done. If this is
736// the target of a third party copy request, fail it now. We don't support
737// multiple writers in tpc mode (this should really never happen).
738//
739 if (!(oP.hP->Inactive()))
740 {dorawio = (oh->isCompressed && open_mode & SFS_O_RAWIO ? 1 : 0);
741 if (tpcKey && isRW)
742 return XrdOfsFS->Emsg(epname, error, EALREADY, "tpc", path,
743 "+ofs_open: this tpc is already in progress");
744 XrdOfsFS->ocMutex.Lock(); oh = oP.hP; XrdOfsFS->ocMutex.UnLock();
745 FTRACE(open, "attach use=" <<oh->Usage());
746 if (oP.poscNum > 0) XrdOfsFS->poscQ->Commit(path, oP.poscNum);
747 oP.hP->UnLock();
750 if (oP.poscNum > 0) OfsStats.Data.numOpenP++;
752 return oP.OK();
753 }
754
755// Get a storage system object
756//
757 if (!(oP.fP = XrdOfsOss->newFile(tident)))
758 return XrdOfsFS->Emsg(epname, error, ENOMEM, "open", path);
759
760// We need to make special provisions for proxy servers in the presence of
761// the TPC option and possibly cache as it's handled differently in this case.
762//
763 if (XrdOfsFS->OssIsProxy)
764 {if (myTPC) open_flag |= O_NOFOLLOW;
765 if (error.getUCap() & XrdOucEI::uUrlOK &&
766 error.getUCap() & XrdOucEI::uLclF) open_flag |= O_DIRECT;
767 }
768
769// If we are doing real-time checksums, wrap the Oss file with a Cks file
770//
771 if (oP.cP)
772 {XrdOfsCksFile* cfP = new XrdOfsCksFile(tident,path,oP.fP,oP.cP,viaDel);
773 oP.fP = static_cast<XrdOssDF*>(cfP);
774 oP.cP = 0;
775 }
776
777// Open the file
778//
779 if ((retc = oP.fP->Open(path, open_flag, theMode, Open_Env)))
780 {if (retc > 0) return XrdOfsFS->Stall(error, retc, path);
781 if (retc == -EINPROGRESS)
784 }
785 if (retc == -ETXTBSY) return XrdOfsFS->Stall(error, -1, path);
786 if (retc == -EDESTADDRREQ)
787 {char *url = Open_Env.Get("FileURL");
788 if (url) {error.setErrInfo(-1, url); return SFS_REDIRECT;}
789 }
790 if (XrdOfsFS->Balancer && retc == -ENOENT)
791 XrdOfsFS->Balancer->Removed(path);
792 const char* etP = 0;
793 std::string eText;
794 if (XrdOfsFS->tryXERT && oP.fP->getErrMsg(eText)) etP = eText.c_str();
795 return XrdOfsFS->Emsg(epname, error, retc, "open", path, etP);
796 }
797
798// Verify that we can actually use this file
799//
800 if (oP.poscNum > 0)
801 {if ((retc = oP.fP->Fchmod(static_cast<mode_t>(theMode|XRDSFS_POSCPEND))))
802 return XrdOfsFS->Emsg(epname, error, retc, "fchmod", path,
803 "+ofs_open: POSC file designation failed");
804 XrdOfsFS->poscQ->Commit(path, oP.poscNum);
805 }
806
807// Set compression values and activate the handle
808//
809 if (oP.fP->isCompressed() > 0)
810 {oP.hP->isCompressed = 1;
811 dorawio = (open_mode & SFS_O_RAWIO ? 1 : 0);
812 }
813 oP.hP->Activate(oP.fP);
814 oP.hP->UnLock();
815
816// If this is being opened for sequential I/O advise the filesystem about it.
817//
818#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
819 if (!(XrdOfsFS->OssIsProxy) && open_mode & SFS_O_SEQIO)
820 {static RAtomic_int fadFails(0);
821 int theFD = oP.fP->getFD();
822 if (theFD >= 0 && fadFails < 4096)
823 if (posix_fadvise(theFD, 0, 0, POSIX_FADV_SEQUENTIAL) < 0)
824 {OfsEroute.Emsg(epname, errno, "fadvise for sequential I/O.");
825 fadFails++;
826 }
827 }
828#endif
829
830// Send an open event if we must
831//
832 if (XrdOfsFS->evsObject)
834 if (XrdOfsFS->evsObject->Enabled(theEvent))
835 {XrdOfsEvsInfo evInfo(tident, path, info, &Open_Env);
836 XrdOfsFS->evsObject->Notify(theEvent, evInfo);
837 }
838 }
839
840// Maintain statistics
841//
844 if (oP.poscNum > 0) OfsStats.Data.numOpenP++;
846
847// All done
848//
849 XrdOfsFS->ocMutex.Lock(); oh = oP.hP; XrdOfsFS->ocMutex.UnLock();
850 return oP.OK();
851}
@ 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:165
#define XRDOSS_coloc
Definition XrdOss.hh:529
#define XRDOSS_new
Definition XrdOss.hh:527
#define XRDOSS_mkpath
Definition XrdOss.hh:526
int Mode
XrdOucString Path
#define XRDSFS_POSCPEND
#define SFS_O_RESET
#define SFS_O_CREATAT
#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 Recycle()
Recycle the checksum object as it is no longer needed. A default is given.
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:471
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
bool WantCksRT()
Definition XrdOfs.hh:365
XrdCmsClient * Finder
Definition XrdOfs.hh:441
mode_t fMask[2]
Definition XrdOfs.hh:397
XrdOfsEvr evrObject
Definition XrdOfs.hh:440
int tpcRdrPort[2]
Definition XrdOfs.hh:402
char * tpcRdrHost[2]
Definition XrdOfs.hh:401
int Options
Definition XrdOfs.hh:391
static int fsError(XrdOucErrInfo &myError, int rc)
Definition XrdOfs.cc:2837
int SetupCksRT(XrdCksCalc *&, XrdOucEnv &, const char *&)
Definition XrdOfs.cc:2763
int Stall(XrdOucErrInfo &, int, const char *)
Definition XrdOfs.cc:2911
@ RdrTPC
Definition XrdOfs.hh:388
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:954
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, XrdCksCalc::Recycle(), XrdOfsHandle::Retire(), SFS_O_CREAT, SFS_O_CREATAT, 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(), viaDel, XrdOfsFS, XrdOfsOss, XRDOSS_coloc, 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 1264 of file XrdOfs.cc.

1265{
1266 EPNAME("aiopgread");
1267 uint64_t pgOpts;
1268 int rc;
1269
1270// If the oss plugin does not support pgRead or if we are doing rawio or the
1271// file is compressed then revert to using a standard async read. Note that
1272// the standard async read will generate checksums if a vector is present.
1273// Note: we set cksVec in the request to nil to indicate simulation!
1274//
1275 if (!XrdOfsFS->OssHasPGrw || dorawio || oh->isCompressed)
1276 {aioparm->cksVec = 0;
1277 return XrdOfsFile::read(aioparm);
1278 }
1279
1280// Perform required tracing
1281//
1282 FTRACE(aio, aioparm->sfsAio.aio_nbytes <<"@" <<aioparm->sfsAio.aio_offset);
1283
1284// Make sure the offset is not too large
1285//
1286#if _FILE_OFFSET_BITS!=64
1287 if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1288 return XrdOfsFS->Emsg(epname,error,-EFBIG,"pgRead",oh->Name(),0,false);
1289#endif
1290
1291// Pass through any flags of interest
1292//
1294 else pgOpts = 0;
1295
1296// Issue the read. Only true errors are returned here.
1297//
1298 if ((rc = oh->Select().pgRead(aioparm, pgOpts)) < 0)
1299 return XrdOfsFS->Emsg(epname, error, rc, "pgRead", oh, false, false);
1300
1301// All done
1302//
1303 return SFS_OK;
1304}
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:1429
static const uint64_t Verify
all: Verify checksums
Definition XrdOss.hh:251
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 1214 of file XrdOfs.cc.

1219{
1220 EPNAME("pgRead");
1221 XrdSfsXferSize nbytes;
1222 uint64_t pgOpts;
1223
1224// If the oss plugin does not support pgRead and we doing rawio then simulate
1225// the pgread. As this is relatively common we skip the vtable. This means
1226// this class cannot be a inherited to override the read() method.
1227//
1228 if (!XrdOfsFS->OssHasPGrw || dorawio)
1229 {if ((nbytes = XrdOfsFile::read(offset, buffer, rdlen)) > 0)
1230 XrdOucPgrwUtils::csCalc(buffer, offset, nbytes, csvec);
1231 return nbytes;
1232 }
1233
1234// Perform required tracing
1235//
1236 FTRACE(read, rdlen <<"@" <<offset);
1237
1238// Make sure the offset is not too large
1239//
1240#if _FILE_OFFSET_BITS!=64
1241 if (offset > 0x000000007fffffff)
1242 return XrdOfsFS->Emsg(epname, error, EFBIG, "pgRead", oh->Name());
1243#endif
1244
1245// Pass through any flags of interest
1246//
1248 else pgOpts = 0;
1249
1250// Now read the actual number of bytes
1251//
1252 nbytes = (XrdSfsXferSize)(oh->Select().pgRead((void *)buffer,
1253 (off_t)offset, (size_t)rdlen, csvec, pgOpts));
1254 if (nbytes < 0)
1255 return XrdOfsFS->Emsg(epname,error,(int)nbytes,"pgRead",oh,false,false);
1256
1257// Return number of bytes read
1258//
1259 return nbytes;
1260}
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 1364 of file XrdOfs.cc.

1365{
1366 EPNAME("aiopgWrite");
1367 uint64_t pgOpts;
1368 int rc;
1369
1370// If the oss plugin does not support pgWrite revert to using a standard write.
1371//
1372 if (!XrdOfsFS->OssHasPGrw)
1373 {if ((opts & XrdSfsFile::Verify)
1374 && !VerPgw((char *)aioparm->sfsAio.aio_buf,
1375 aioparm->sfsAio.aio_offset,
1376 aioparm->sfsAio.aio_nbytes,
1377 aioparm->cksVec, oh, error)) return SFS_ERROR;
1378 return XrdOfsFile::write(aioparm);
1379 }
1380
1381// If this is a POSC file, we must convert the async call to a sync call as we
1382// must trap any errors that unpersist the file. We can't do that via aio i/f.
1383//
1384 if (oh->isRW == XrdOfsHandle::opPC)
1385 {aioparm->Result = XrdOfsFile::pgWrite(aioparm->sfsAio.aio_offset,
1386 (char *)aioparm->sfsAio.aio_buf,
1387 aioparm->sfsAio.aio_nbytes,
1388 aioparm->cksVec, opts);
1389 aioparm->doneWrite();
1390 return SFS_OK;
1391 }
1392
1393// Perform any required tracing
1394//
1395 FTRACE(aio, aioparm->sfsAio.aio_nbytes <<"@" <<aioparm->sfsAio.aio_offset);
1396
1397// Make sure the offset is not too large
1398//
1399#if _FILE_OFFSET_BITS!=64
1400 if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1401 return XrdOfsFS->Emsg(epname, error, -EFBIG, "pgwrite", oh, true, false);
1402#endif
1403
1404// Silly Castor stuff
1405//
1406 if (XrdOfsFS->evsObject && !(oh->isChanged)
1407 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1408
1409// Pass through any flags of interest
1410//
1412 else pgOpts = 0;
1413
1414// Write the requested bytes
1415//
1416 oh->isPending = 1;
1417 if ((rc = oh->Select().pgWrite(aioparm, pgOpts)) < 0)
1418 return XrdOfsFS->Emsg(epname, error, rc, "pgwrite", oh, true, false);
1419
1420// All done
1421//
1422 return SFS_OK;
1423}
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:1310
XrdSfsXferSize write(XrdSfsFileOffset fileOffset, const char *buffer, XrdSfsXferSize buffer_size)
Definition XrdOfs.cc:1594
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 1310 of file XrdOfs.cc.

1315{
1316 EPNAME("pgWrite");
1317 XrdSfsXferSize nbytes;
1318 uint64_t pgOpts;
1319
1320// If the oss plugin does not support pgWrite revert to using a standard write.
1321//
1322 if (!XrdOfsFS->OssHasPGrw)
1323 {if ((opts & XrdSfsFile::Verify)
1324 && !VerPgw(buffer, offset, wrlen, csvec, oh, error)) return SFS_ERROR;
1325 return XrdOfsFile::write(offset, buffer, wrlen);
1326 }
1327
1328// Perform any required tracing
1329//
1330 FTRACE(write, wrlen <<"@" <<offset);
1331
1332// Make sure the offset is not too large
1333//
1334#if _FILE_OFFSET_BITS!=64
1335 if (offset > 0x000000007fffffff)
1336 return XrdOfsFS->Emsg(epname, error, -EFBIG, "pgwrite", oh, true, false);
1337#endif
1338
1339// Silly Castor stuff
1340//
1341 if (XrdOfsFS->evsObject && !(oh->isChanged)
1342 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1343
1344// Pass through any flags of interest
1345//
1347 else pgOpts = 0;
1348
1349// Write the requested bytes
1350//
1351 oh->isPending = 1;
1352 nbytes = (XrdSfsXferSize)(oh->Select().pgWrite((void *)buffer,
1353 (off_t)offset, (size_t)wrlen, csvec, pgOpts));
1354 if (nbytes < 0)
1355 return XrdOfsFS->Emsg(epname,error,(int)nbytes,"pgwrite",oh,true,false);
1356
1357// Return number of bytes written
1358//
1359 return nbytes;
1360}

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

1555{
1556 EPNAME("aioread");
1557 int rc;
1558
1559// Async mode for compressed files is not supported.
1560//
1561 if (oh->isCompressed)
1562 {aiop->Result = this->read((XrdSfsFileOffset)aiop->sfsAio.aio_offset,
1563 (char *)aiop->sfsAio.aio_buf,
1564 (XrdSfsXferSize)aiop->sfsAio.aio_nbytes);
1565 aiop->doneRead();
1566 return 0;
1567 }
1568
1569// Perform required tracing
1570//
1571 FTRACE(aio, aiop->sfsAio.aio_nbytes <<"@" <<aiop->sfsAio.aio_offset);
1572
1573// Make sure the offset is not too large
1574//
1575#if _FILE_OFFSET_BITS!=64
1576 if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1577 return XrdOfsFS->Emsg(epname,error,-EFBIG,"read",oh->Name(),0,false);
1578#endif
1579
1580// Issue the read. Only true errors are returned here.
1581//
1582 if ((rc = oh->Select().Read(aiop)) < 0)
1583 return XrdOfsFS->Emsg(epname, error, rc, "read", oh, false, false);
1584
1585// All done
1586//
1587 return SFS_OK;
1588}
#define read(a, b, c)
Definition XrdPosix.hh:86
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 1468 of file XrdOfs.cc.

1482{
1483 EPNAME("read");
1484 XrdSfsXferSize nbytes;
1485
1486// Perform required tracing
1487//
1488 FTRACE(read, blen <<"@" <<offset);
1489
1490// Make sure the offset is not too large
1491//
1492#if _FILE_OFFSET_BITS!=64
1493 if (offset > 0x000000007fffffff)
1494 return XrdOfsFS->Emsg(epname,error,-EFBIG,"read",oh->Name(),0,false);
1495#endif
1496
1497// Now read the actual number of bytes
1498//
1499 nbytes = (dorawio ?
1500 (XrdSfsXferSize)(oh->Select().ReadRaw((void *)buff,
1501 (off_t)offset, (size_t)blen))
1502 : (XrdSfsXferSize)(oh->Select().Read((void *)buff,
1503 (off_t)offset, (size_t)blen)));
1504 if (nbytes < 0)
1505 return XrdOfsFS->Emsg(epname, error, (int)nbytes, "read", oh, 0, false);
1506
1507// Return number of bytes read
1508//
1509 return nbytes;
1510}

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 a file block 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 When 0, the request was ignored; otherwise, it has been accepted.
SFS_ERROR File could not be preread, error holds the reason.

Implements XrdSfsFile.

Definition at line 1429 of file XrdOfs.cc.

1439{
1440 EPNAME("read");
1441 int retc;
1442
1443// Perform required tracing
1444//
1445 FTRACE(read, "preread " <<blen <<"@" <<offset);
1446
1447// Make sure the offset is not too large
1448//
1449#if _FILE_OFFSET_BITS!=64
1450 if (offset > 0x000000007fffffff)
1451 return XrdOfsFS->Emsg(epname,error,-EFBIG,"read",oh->Name(),0,false);
1452#endif
1453
1454// Now preread the actual number of bytes
1455//
1456 if ((retc = oh->Select().Read((off_t)offset, (size_t)blen)) < 0)
1457 return XrdOfsFS->Emsg(epname, error, (int)retc, "preread", oh, 0, false);
1458
1459// Return number of bytes read
1460//
1461 return retc;
1462}

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

1530{
1531 EPNAME("readv");
1532
1533 XrdSfsXferSize nbytes = oh->Select().ReadV(readV, readCount);
1534 if (nbytes < 0)
1535 return XrdOfsFS->Emsg(epname,error,(int)nbytes,"readv",oh,false,false);
1536
1537 return nbytes;
1538
1539}

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

1726{
1727 EPNAME("fstat");
1728 int retc;
1729
1730// Perform any required tracing
1731//
1732 FTRACE(stat, "");
1733
1734// Perform the function
1735//
1736 if ((retc = oh->Select().Fstat(buf)) < 0)
1737 return XrdOfsFS->Emsg(epname,error,retc,"get state for",oh);
1738
1739 return SFS_OK;
1740}
int stat(struct stat *buf)
Definition XrdOfs.cc:1718

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

1754{
1755 EPNAME("sync");
1756 int retc;
1757
1758// Perform any required tracing
1759//
1760 FTRACE(sync, "");
1761
1762// If we have a tpc object hanging about, we need to dispatch that first
1763//
1764 if (myTPC && (retc = myTPC->Sync(&error))) return retc;
1765
1766// We can test the pendio flag w/o a lock because the person doing this
1767// sync must have done the previous write. Causality is the synchronizer.
1768//
1769 if (!(oh->isPending)) return SFS_OK;
1770
1771// We can also skip the sync if the file is closed. However, we need a file
1772// object lock in order to test the flag. We can also reset the PENDIO flag.
1773//
1774 oh->Lock();
1775 oh->isPending = 0;
1776 oh->UnLock();
1777
1778// Perform the function
1779//
1780 if ((retc = oh->Select().Fsync()))
1781 {oh->isPending = 1;
1782 return XrdOfsFS->Emsg(epname, error, retc, "synchronize", oh, true);
1783 }
1784
1785// Indicate all went well
1786//
1787 return SFS_OK;
1788}
int sync()
Definition XrdOfs.cc:1746

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

1797{
1798 aiop->Result = this->sync();
1799 aiop->doneWrite();
1800 return 0;
1801}

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

1821{
1822 EPNAME("trunc");
1823 int retc;
1824
1825// Lock the file handle and perform any tracing
1826//
1827 FTRACE(truncate, "len=" <<flen);
1828
1829// Make sure the offset is not too large
1830//
1831 if (sizeof(off_t) < sizeof(flen) && flen > 0x000000007fffffff)
1832 return XrdOfsFS->Emsg(epname, error, EFBIG, "truncate", oh, true);
1833
1834// Silly Castor stuff
1835//
1836 if (XrdOfsFS->evsObject && !(oh->isChanged)
1837 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1838
1839// Perform the function
1840//
1841 oh->isPending = 1;
1842 if ((retc = oh->Select().Ftruncate(flen)))
1843 return XrdOfsFS->Emsg(epname, error, retc, "truncate", oh, true);
1844
1845// Indicate Success
1846//
1847 return SFS_OK;
1848}
int truncate(XrdSfsFileOffset fileOffset)
Definition XrdOfs.cc:1807

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

1651{
1652 EPNAME("aiowrite");
1653 int rc;
1654
1655// Perform any required tracing
1656//
1657 FTRACE(aio, aiop->sfsAio.aio_nbytes <<"@" <<aiop->sfsAio.aio_offset);
1658
1659// If this is a POSC file, we must convert the async call to a sync call as we
1660// must trap any errors that unpersist the file. We can't do that via aio i/f.
1661//
1662 if (oh->isRW == XrdOfsHandle::opPC)
1663 {aiop->Result = this->write(aiop->sfsAio.aio_offset,
1664 (const char *)aiop->sfsAio.aio_buf,
1665 aiop->sfsAio.aio_nbytes);
1666 aiop->doneWrite();
1667 return 0;
1668 }
1669
1670// Make sure the offset is not too large
1671//
1672#if _FILE_OFFSET_BITS!=64
1673 if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1674 return XrdOfsFS->Emsg(epname, error, -EFBIG, "write", oh, true, false);
1675#endif
1676
1677// Silly Castor stuff
1678//
1679 if (XrdOfsFS->evsObject && !(oh->isChanged)
1680 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1681
1682// Write the requested bytes
1683//
1684 oh->isPending = 1;
1685 if ((rc = oh->Select().Write(aiop)) < 0)
1686 return XrdOfsFS->Emsg(epname, error, rc, "write", oh, true, false);
1687
1688// All done
1689//
1690 return SFS_OK;
1691}
#define write(a, b, c)
Definition XrdPosix.hh:121

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

1611{
1612 EPNAME("write");
1613 XrdSfsXferSize nbytes;
1614
1615// Perform any required tracing
1616//
1617 FTRACE(write, blen <<"@" <<offset);
1618
1619// Make sure the offset is not too large
1620//
1621#if _FILE_OFFSET_BITS!=64
1622 if (offset > 0x000000007fffffff)
1623 return XrdOfsFS->Emsg(epname,error,-EFBIG,"write",oh,true,false);
1624#endif
1625
1626// Silly Castor stuff
1627//
1628 if (XrdOfsFS->evsObject && !(oh->isChanged)
1629 && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1630
1631// Write the requested bytes
1632//
1633 oh->isPending = 1;
1634 nbytes = (XrdSfsXferSize)(oh->Select().Write((const void *)buff,
1635 (off_t)offset, (size_t)blen));
1636 if (nbytes < 0)
1637 return XrdOfsFS->Emsg(epname,error,(int)nbytes,"write",oh,true,false);
1638
1639// Return number of bytes written
1640//
1641 return nbytes;
1642}

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

Referenced by XrdOfsFile(), and checkpoint().

◆ dorawio

int XrdOfsFile::dorawio
protected

Definition at line 207 of file XrdOfs.hh.

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

◆ myCKP

XrdOucChkPnt* XrdOfsFile::myCKP
protected

Definition at line 206 of file XrdOfs.hh.

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

◆ myTPC

XrdOfsTPC* XrdOfsFile::myTPC
protected

Definition at line 205 of file XrdOfs.hh.

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

◆ ocFsync

bool XrdOfsFile::ocFsync = false
inlinestatic

Definition at line 199 of file XrdOfs.hh.

Referenced by close().

◆ oh

◆ tident

const char* XrdOfsFile::tident
protected

Definition at line 203 of file XrdOfs.hh.

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

◆ viaDel

bool XrdOfsFile::viaDel
protected

Definition at line 208 of file XrdOfs.hh.

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


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