XRootD
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 ()
 
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. More...
 
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)
 

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. More...
 

Detailed Description

Definition at line 115 of file XrdOfs.hh.

Constructor & Destructor Documentation

◆ XrdOfsFile()

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

Definition at line 457 of file XrdOfs.cc.

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

◆ ~XrdOfsFile()

XrdOfsFile::~XrdOfsFile ( )
inline

Definition at line 197 of file XrdOfs.hh.

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

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

983 {
984  EPNAME("chkpnt");
985  const char *ckpName;
986  int rc;
987  bool readok;
988 
989 // Make sure we are active
990 //
991  if (oh->Inactive()) return XrdOfsFS->Emsg(epname, error, EBADF,
992  "handle checkpoint", (const char *)0);
993 
994 // If checkpointing is disabled, the don't accept this request.
995 //
996  if (!XrdOfsConfigCP::Enabled) return XrdOfsFS->Emsg(epname, error, ENOTSUP,
997  "handle disabled checkpoint", (const char *)0);
998 
999 // If this checkpoint is bad then only a delete, query or restore is allowed.
1000 //
1001  if (ckpBad && (act == XrdSfsFile::cpTrunc || act == XrdSfsFile::cpWrite))
1002  return XrdOfsFS->Emsg(epname, error, EIDRM, "extend checkpoint "
1003  "(only delete or restore possible) for", oh->Name());
1004 
1005 // Handle the request
1006 //
1007  switch(act)
1008  {case XrdSfsFile::cpCreate:
1009  ckpName = "create checkpoint for";
1010  if ((rc = CreateCKP())) return rc;
1011  if ((rc = myCKP->Create())) {myCKP->Finished(); myCKP = 0;}
1012  break;
1013  case XrdSfsFile::cpDelete:
1014  ckpName = "delete checkpoint for";
1015  if (!myCKP) rc = ENOENT;
1016  else {rc = myCKP->Delete();
1017  myCKP->Finished();
1018  myCKP = 0;
1019  ckpBad = false;
1020  }
1021  break;
1022  case XrdSfsFile::cpQuery:
1023  ckpName = "query checkpoint for";
1024  if (!range || n <= 0)
1025  return XrdOfsFS->Emsg(epname, error, EINVAL,
1026  "query checkpoint limits for", oh->Name());
1027  rc = (myCKP ? myCKP->Query(*range) : ENOENT);
1028  break;
1029  case XrdSfsFile::cpRestore:
1030  ckpName = "restore checkpoint for";
1031  if (!myCKP) rc = ENOENT;
1032  else {if (!(rc = myCKP->Restore(&readok)))
1033  {myCKP->Finished();
1034  myCKP = 0;
1035  ckpBad = false;
1036  } else {
1037  if (!(oh->Select().DFType() & XrdOssDF::DF_isProxy))
1038  oh->Suppress((readok ? 0 : -EDOM));
1039  ckpBad = true;
1040  }
1041  }
1042  break;
1043  case XrdSfsFile::cpTrunc:
1044  ckpName = "checkpoint truncate";
1045  if (!range) rc = EINVAL;
1046  else if (!myCKP) rc = ENOENT;
1047  else if ((rc = myCKP->Truncate(range))) ckpBad = true;
1048  break;
1049  case XrdSfsFile::cpWrite:
1050  ckpName = "checkpoint write";
1051  if (!range || n <= 0) rc = EINVAL;
1052  else if (!myCKP) rc = ENOENT;
1053  else if ((rc = myCKP->Write(range, n))) ckpBad = true;
1054  break;
1055 
1056  default: return XrdOfsFS->Emsg(epname, error, EINVAL,
1057  "decode checkpoint request for", oh->Name());
1058  };
1059 
1060 // Complete as needed
1061 //
1062  if (rc) return XrdOfsFS->Emsg(epname, error, rc, ckpName, oh->Name());
1063 
1064 // Trace success and return
1065 //
1066  FTRACE(chkpnt, ckpName);
1067  return SFS_OK;
1068 }
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
#define FTRACE(act, x)
Definition: XrdBwmTrace.hh:45
XrdOfs * XrdOfsFS
Definition: XrdOfsFS.cc:47
#define SFS_OK
static bool Enabled
const char * Name()
void Suppress(int rrc=-EDOM, int wrc=-EDOM)
XrdOssDF & Select(void)
static int Emsg(const char *, XrdOucErrInfo &, int, const char *x, XrdOfsHandle *hP, bool posChk=false, bool chktype=true)
Definition: XrdOfs.cc:2609
static const uint16_t DF_isProxy
Object is a proxy object.
Definition: XrdOss.hh:434
uint16_t DFType()
Definition: XrdOss.hh:436
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:

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

858 {
859  EPNAME("Clone");
860  int rc = oh->Select().Clone(cVec);
861 
862  if (rc < 0)
863  {char etxt[4096];
864  snprintf(etxt,sizeof(etxt),"%s from file ranges",oh->Name());
865  return XrdOfsFS->Emsg(epname, error, rc, "clone", etxt);
866  }
867 
868  return SFS_OK;
869 }
virtual int Clone(XrdOssDF &srcFile)
Definition: XrdOss.hh:127

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

+ Here is the call graph for this function:

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

841 {
842  EPNAME("Clone");
843  XrdOfsFile& ofsFile = static_cast<XrdOfsFile&>(srcFile);
844  int rc = oh->Select().Clone(ofsFile.oh->Select());
845 
846  if (rc < 0)
847  {char etxt[4096];
848  snprintf(etxt,sizeof(etxt),"%s from %s",oh->Name(),ofsFile.oh->Name());
849  return XrdOfsFS->Emsg(epname, error, rc, "clone", etxt);
850  }
851 
852  return SFS_OK;
853 }

References XrdOssDF::Clone(), XrdOfs::Emsg(), 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 875 of file XrdOfs.cc.

883 {
884  EPNAME("close");
885 
886  class CloseFH : public XrdOfsHanCB
887  {public: void Retired(XrdOfsHandle *hP) {XrdOfsFS->Unpersist(hP);}};
888  static XrdOfsHanCB *hCB = static_cast<XrdOfsHanCB *>(new CloseFH);
889 
890  XrdOfsHandle *hP;
891  int poscNum, retc, cRetc = 0;
892  short theMode;
893 
894 // Trace the call
895 //
896  FTRACE(close, "use=" <<oh->Usage()); // Unreliable trace, no origin lock
897 
898 // Verify the handle (we briefly maintain a global lock)
899 //
900  XrdOfsFS->ocMutex.Lock();
901  if (oh == XrdOfs::dummyHandle)
902  {XrdOfsFS->ocMutex.UnLock(); return SFS_OK;}
903  if ((oh->Inactive()))
904  {XrdOfsFS->ocMutex.UnLock();
905  return XrdOfsFS->Emsg(epname, error, EBADF, "close file");
906  }
907  hP = oh; oh = XrdOfs::dummyHandle;
908  XrdOfsFS->ocMutex.UnLock();
909  hP->Lock();
910 
911 // Delete the tpc object, if any
912 //
913  if (myTPC) {myTPC->Del(); myTPC = 0;}
914 
915 // Maintain statistics
916 //
918  if (!(hP->isRW)) OfsStats.Data.numOpenR--;
919  else {OfsStats.Data.numOpenW--;
921  }
923 
924 // If this file was tagged as a POSC then we need to make sure it will persist
925 // Note that we unpersist the file immediately when it's inactive or if no hold
926 // time is allowed. Also, close events occur only for active handles. If the
927 // entry was via delete then we ignore the close return code as there is no
928 // one to handle it on the other side.
929 //
930  if ((poscNum = hP->PoscGet(theMode, !viaDel)))
931  {if (viaDel)
932  {if (hP->Inactive() || !XrdOfsFS->poscHold)
933  {XrdOfsFS->Unpersist(hP, !hP->Inactive()); hP->Retire(cRetc);}
934  else hP->Retire(hCB, XrdOfsFS->poscHold);
935  return SFS_OK;
936  }
937  if ((retc = hP->Select().Fchmod(theMode)))
938  XrdOfsFS->Emsg(epname, error, retc, "fchmod", hP->Name());
939  else {XrdOfsFS->poscQ->Del(hP->Name(), poscNum);
940  if (XrdOfsFS->Balancer) XrdOfsFS->Balancer->Added(hP->Name());
941  }
942  }
943 
944 // Handle any oustanding checkpoint
945 //
946  if (myCKP)
947  {retc = myCKP->Restore();
948  if (retc) XrdOfsFS->Emsg(epname,error,retc,"restore chkpnt",hP->Name());
949  myCKP->Finished();
950  myCKP = 0;
951  }
952 
953 // We need to handle the cunudrum that an event may have to be sent upon
954 // the final close. However, that would cause the path name to be destroyed.
955 // So, we have two modes of logic where we copy out the pathname if a final
956 // close actually occurs. The path is not copied if it's not final and we
957 // don't bother with any of it if we need not generate an event.
958 //
959  if (XrdOfsFS->evsObject && tident
960  && XrdOfsFS->evsObject->Enabled(hP->isRW ? XrdOfsEvs::Closew
962  {long long FSize, *retsz;
963  char pathbuff[MAXPATHLEN+8];
964  XrdOfsEvs::Event theEvent;
965  if (hP->isRW) {theEvent = XrdOfsEvs::Closew; retsz = &FSize;}
966  else { theEvent = XrdOfsEvs::Closer; retsz = 0; FSize=0;}
967  if (!(hP->Retire(cRetc, retsz, pathbuff, sizeof(pathbuff))))
968  {XrdOfsEvsInfo evInfo(tident, pathbuff, "" , 0, 0, FSize);
969  XrdOfsFS->evsObject->Notify(theEvent, evInfo);
970  }
971  } else hP->Retire(cRetc);
972 
973 // All done
974 //
975  return (cRetc ? XrdOfsFS->Emsg(epname, error, cRetc, "close file") : SFS_OK);
976 }
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)
Definition: XrdOfsPoscq.cc:159
struct XrdOfsStats::StatsData Data
XrdSysMutex sdMutex
Definition: XrdOfsStats.hh:60
virtual void Del()
Definition: XrdOfsTPC.hh:79
void Unpersist(XrdOfsHandle *hP, int xcev=1)
Definition: XrdOfs.cc:2887
virtual int Fchmod(mode_t mode)
Definition: XrdOss.hh:148

References XrdCmsClient::Added(), 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().

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

◆ fctl() [1/4]

virtual int XrdSfsFile::fctl

Execute a special operation on the file (version 1)

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

◆ fctl() [2/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 1114 of file XrdOfs.cc.

1117 {
1118 // See if we can do this
1119 //
1120  if (cmd == SFS_FCTL_GETFD)
1121  {out_error.setErrCode(oh->Select().getFD());
1122  return SFS_OK;
1123  }
1124 
1125 // We don't support this
1126 //
1127  out_error.setErrInfo(ENOTSUP, "fctl operation not supported");
1128 
1129 // Return
1130 //
1131  return SFS_ERROR;
1132 }
#define SFS_ERROR
#define SFS_FCTL_GETFD
virtual int getFD()
Definition: XrdOss.hh:486

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

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.

Definition at line 521 of file XrdSfsInterface.cc.

103 {
104  (void)cmd; (void)alen; (void)args; (void)client;
105  return SFS_OK;
106 }

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

1138 { // 12345678901234
1139  EPNAME("fctl");
1140  static const char *fctlArg = "ofs.tpc cancel";
1141  static const int fctlAsz = 15;
1142 
1143 // For QFINFO we simply pass it to the Oss layer
1144 //
1145  if (cmd == SFS_FCTL_QFINFO)
1146  {char* resp = 0;;
1147  int rc = oh->Select().Fctl(XrdOssDF::Fctl_QFinfo, alen, args, &resp);
1148  if (rc < 0)
1149  {if (resp) delete[] resp;
1150  return XrdOfsFS->Emsg(epname,error,rc,"fctl",oh,false,false);
1151  }
1152  if (resp)
1153  {if ((rc = strlen(resp)))
1154  {error.setErrInfo(rc, resp);
1155  delete[] resp;
1156  return SFS_DATA;
1157  }
1158  delete[] resp;
1159  }
1160  return SFS_OK;
1161  }
1162 
1163 // See if the is a tpc cancellation (the only thing we support here)
1164 //
1165  if (cmd != SFS_FCTL_SPEC1 || !args || alen < fctlAsz || strcmp(fctlArg,args))
1166  return XrdOfsFS->FSctl(*this, cmd, alen, args, client);
1167 
1168 // Check if we have a tpc operation in progress
1169 //
1170  if (!myTPC)
1171  {error.setErrInfo(ESRCH, "tpc operation not found");
1172  return SFS_ERROR;
1173  }
1174 
1175 // Cancel the tpc
1176 //
1177  myTPC->Del();
1178  myTPC = 0;
1179  return SFS_OK;
1180 }
#define SFS_DATA
#define SFS_FCTL_QFINFO
#define SFS_FCTL_SPEC1
int FSctl(const int cmd, XrdSfsFSctl &args, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0)
Definition: XrdOfsFSctl.cc:263
virtual int Fctl(int cmd, int alen, const char *args, char **resp=0)
Definition: XrdOss.cc:150
static const int Fctl_QFinfo
Definition: XrdOss.hh:461
int setErrInfo(int code, const char *emsg)

References XrdOfsTPC::Del(), XrdOfs::Emsg(), EPNAME, XrdSfsFile::error, XrdOssDF::Fctl(), XrdOssDF::Fctl_QFinfo, XrdOfs::FSctl(), myTPC, oh, XrdOfsHandle::Select(), XrdOucErrInfo::setErrInfo(), SFS_DATA, SFS_ERROR, SFS_FCTL_QFINFO, 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 145 of file XrdOfs.hh.

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

1837 {
1838 
1839 // Copy out the info
1840 //
1841  cxrsz = oh->Select().isCompressed(cxtype);
1842  return SFS_OK;
1843 }
virtual int isCompressed(char *cxidp=0)
Definition: XrdOss.hh:215

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

1677 {
1678 
1679 // Perform the function
1680 //
1681  Size = oh->Select().getMmap(Addr);
1682 
1683  return SFS_OK;
1684 }
virtual off_t getMmap(void **addr)
Definition: XrdOss.hh:204

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

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

1237 {
1238  EPNAME("aiopgread");
1239  uint64_t pgOpts;
1240  int rc;
1241 
1242 // If the oss plugin does not support pgRead or if we are doing rawio or the
1243 // file is compressed then revert to using a standard async read. Note that
1244 // the standard async read will generate checksums if a vector is present.
1245 // Note: we set cksVec in the request to nil to indicate simulation!
1246 //
1247  if (!XrdOfsFS->OssHasPGrw || dorawio || oh->isCompressed)
1248  {aioparm->cksVec = 0;
1249  return XrdOfsFile::read(aioparm);
1250  }
1251 
1252 // Perform required tracing
1253 //
1254  FTRACE(aio, aioparm->sfsAio.aio_nbytes <<"@" <<aioparm->sfsAio.aio_offset);
1255 
1256 // Make sure the offset is not too large
1257 //
1258 #if _FILE_OFFSET_BITS!=64
1259  if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1260  return XrdOfsFS->Emsg(epname,error,-EFBIG,"pgRead",oh->Name(),0,false);
1261 #endif
1262 
1263 // Pass through any flags of interest
1264 //
1265  if (opts & XrdSfsFile::Verify) pgOpts = XrdOssDF::Verify;
1266  else pgOpts = 0;
1267 
1268 // Issue the read. Only true errors are returned here.
1269 //
1270  if ((rc = oh->Select().pgRead(aioparm, pgOpts)) < 0)
1271  return XrdOfsFS->Emsg(epname, error, rc, "pgRead", oh, false, false);
1272 
1273 // All done
1274 //
1275  return SFS_OK;
1276 }
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:1401
static const uint64_t Verify
all: Verify checksums
Definition: XrdOss.hh:251
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 1186 of file XrdOfs.cc.

1191 {
1192  EPNAME("pgRead");
1193  XrdSfsXferSize nbytes;
1194  uint64_t pgOpts;
1195 
1196 // If the oss plugin does not support pgRead and we doing rawio then simulate
1197 // the pgread. As this is relatively common we skip the vtable. This means
1198 // this class cannot be a inherited to override the read() method.
1199 //
1200  if (!XrdOfsFS->OssHasPGrw || dorawio)
1201  {if ((nbytes = XrdOfsFile::read(offset, buffer, rdlen)) > 0)
1202  XrdOucPgrwUtils::csCalc(buffer, offset, nbytes, csvec);
1203  return nbytes;
1204  }
1205 
1206 // Perform required tracing
1207 //
1208  FTRACE(read, rdlen <<"@" <<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, "pgRead", oh->Name());
1215 #endif
1216 
1217 // Pass through any flags of interest
1218 //
1219  if (opts & XrdSfsFile::Verify) pgOpts = XrdOssDF::Verify;
1220  else pgOpts = 0;
1221 
1222 // Now read the actual number of bytes
1223 //
1224  nbytes = (XrdSfsXferSize)(oh->Select().pgRead((void *)buffer,
1225  (off_t)offset, (size_t)rdlen, csvec, pgOpts));
1226  if (nbytes < 0)
1227  return XrdOfsFS->Emsg(epname,error,(int)nbytes,"pgRead",oh,false,false);
1228 
1229 // Return number of bytes read
1230 //
1231  return nbytes;
1232 }
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(), 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 1336 of file XrdOfs.cc.

1337 {
1338  EPNAME("aiopgWrite");
1339  uint64_t pgOpts;
1340  int rc;
1341 
1342 // If the oss plugin does not support pgWrite revert to using a standard write.
1343 //
1344  if (!XrdOfsFS->OssHasPGrw)
1345  {if ((opts & XrdSfsFile::Verify)
1346  && !VerPgw((char *)aioparm->sfsAio.aio_buf,
1347  aioparm->sfsAio.aio_offset,
1348  aioparm->sfsAio.aio_nbytes,
1349  aioparm->cksVec, oh, error)) return SFS_ERROR;
1350  return XrdOfsFile::write(aioparm);
1351  }
1352 
1353 // If this is a POSC file, we must convert the async call to a sync call as we
1354 // must trap any errors that unpersist the file. We can't do that via aio i/f.
1355 //
1356  if (oh->isRW == XrdOfsHandle::opPC)
1357  {aioparm->Result = XrdOfsFile::pgWrite(aioparm->sfsAio.aio_offset,
1358  (char *)aioparm->sfsAio.aio_buf,
1359  aioparm->sfsAio.aio_nbytes,
1360  aioparm->cksVec, opts);
1361  aioparm->doneWrite();
1362  return SFS_OK;
1363  }
1364 
1365 // Perform any required tracing
1366 //
1367  FTRACE(aio, aioparm->sfsAio.aio_nbytes <<"@" <<aioparm->sfsAio.aio_offset);
1368 
1369 // Make sure the offset is not too large
1370 //
1371 #if _FILE_OFFSET_BITS!=64
1372  if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1373  return XrdOfsFS->Emsg(epname, error, -EFBIG, "pgwrite", oh, true, false);
1374 #endif
1375 
1376 // Silly Castor stuff
1377 //
1378  if (XrdOfsFS->evsObject && !(oh->isChanged)
1379  && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1380 
1381 // Pass through any flags of interest
1382 //
1383  if (opts & XrdSfsFile::Verify) pgOpts = XrdOssDF::Verify;
1384  else pgOpts = 0;
1385 
1386 // Write the requested bytes
1387 //
1388  oh->isPending = 1;
1389  if ((rc = oh->Select().pgWrite(aioparm, pgOpts)) < 0)
1390  return XrdOfsFS->Emsg(epname, error, rc, "pgwrite", oh, true, false);
1391 
1392 // All done
1393 //
1394  return SFS_OK;
1395 }
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:1282
XrdSfsXferSize write(XrdSfsFileOffset fileOffset, const char *buffer, XrdSfsXferSize buffer_size)
Definition: XrdOfs.cc:1566
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, 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 1282 of file XrdOfs.cc.

1287 {
1288  EPNAME("pgWrite");
1289  XrdSfsXferSize nbytes;
1290  uint64_t pgOpts;
1291 
1292 // If the oss plugin does not support pgWrite revert to using a standard write.
1293 //
1294  if (!XrdOfsFS->OssHasPGrw)
1295  {if ((opts & XrdSfsFile::Verify)
1296  && !VerPgw(buffer, offset, wrlen, csvec, oh, error)) return SFS_ERROR;
1297  return XrdOfsFile::write(offset, buffer, wrlen);
1298  }
1299 
1300 // Perform any required tracing
1301 //
1302  FTRACE(write, wrlen <<"@" <<offset);
1303 
1304 // Make sure the offset is not too large
1305 //
1306 #if _FILE_OFFSET_BITS!=64
1307  if (offset > 0x000000007fffffff)
1308  return XrdOfsFS->Emsg(epname, error, -EFBIG, "pgwrite", oh, true, false);
1309 #endif
1310 
1311 // Silly Castor stuff
1312 //
1313  if (XrdOfsFS->evsObject && !(oh->isChanged)
1314  && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1315 
1316 // Pass through any flags of interest
1317 //
1318  if (opts & XrdSfsFile::Verify) pgOpts = XrdOssDF::Verify;
1319  else pgOpts = 0;
1320 
1321 // Write the requested bytes
1322 //
1323  oh->isPending = 1;
1324  nbytes = (XrdSfsXferSize)(oh->Select().pgWrite((void *)buffer,
1325  (off_t)offset, (size_t)wrlen, csvec, pgOpts));
1326  if (nbytes < 0)
1327  return XrdOfsFS->Emsg(epname,error,(int)nbytes,"pgwrite",oh,true,false);
1328 
1329 // Return number of bytes written
1330 //
1331  return nbytes;
1332 }

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(), 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 1526 of file XrdOfs.cc.

1527 {
1528  EPNAME("aioread");
1529  int rc;
1530 
1531 // Async mode for compressed files is not supported.
1532 //
1533  if (oh->isCompressed)
1534  {aiop->Result = this->read((XrdSfsFileOffset)aiop->sfsAio.aio_offset,
1535  (char *)aiop->sfsAio.aio_buf,
1536  (XrdSfsXferSize)aiop->sfsAio.aio_nbytes);
1537  aiop->doneRead();
1538  return 0;
1539  }
1540 
1541 // Perform required tracing
1542 //
1543  FTRACE(aio, aiop->sfsAio.aio_nbytes <<"@" <<aiop->sfsAio.aio_offset);
1544 
1545 // Make sure the offset is not too large
1546 //
1547 #if _FILE_OFFSET_BITS!=64
1548  if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1549  return XrdOfsFS->Emsg(epname,error,-EFBIG,"read",oh->Name(),0,false);
1550 #endif
1551 
1552 // Issue the read. Only true errors are returned here.
1553 //
1554  if ((rc = oh->Select().Read(aiop)) < 0)
1555  return XrdOfsFS->Emsg(epname, error, rc, "read", oh, false, false);
1556 
1557 // All done
1558 //
1559  return SFS_OK;
1560 }
long long XrdSfsFileOffset
virtual ssize_t Read(off_t offset, size_t size)
Definition: XrdOss.hh:310

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

1454 {
1455  EPNAME("read");
1456  XrdSfsXferSize nbytes;
1457 
1458 // Perform required tracing
1459 //
1460  FTRACE(read, blen <<"@" <<offset);
1461 
1462 // Make sure the offset is not too large
1463 //
1464 #if _FILE_OFFSET_BITS!=64
1465  if (offset > 0x000000007fffffff)
1466  return XrdOfsFS->Emsg(epname,error,-EFBIG,"read",oh->Name(),0,false);
1467 #endif
1468 
1469 // Now read the actual number of bytes
1470 //
1471  nbytes = (dorawio ?
1472  (XrdSfsXferSize)(oh->Select().ReadRaw((void *)buff,
1473  (off_t)offset, (size_t)blen))
1474  : (XrdSfsXferSize)(oh->Select().Read((void *)buff,
1475  (off_t)offset, (size_t)blen)));
1476  if (nbytes < 0)
1477  return XrdOfsFS->Emsg(epname, error, (int)nbytes, "read", oh, 0, false);
1478 
1479 // Return number of bytes read
1480 //
1481  return nbytes;
1482 }
virtual ssize_t ReadRaw(void *buffer, off_t offset, size_t size)
Definition: XrdOss.hh:359

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

1411 {
1412  EPNAME("read");
1413  int retc;
1414 
1415 // Perform required tracing
1416 //
1417  FTRACE(read, "preread " <<blen <<"@" <<offset);
1418 
1419 // Make sure the offset is not too large
1420 //
1421 #if _FILE_OFFSET_BITS!=64
1422  if (offset > 0x000000007fffffff)
1423  return XrdOfsFS->Emsg(epname,error,-EFBIG,"read",oh->Name(),0,false);
1424 #endif
1425 
1426 // Now preread the actual number of bytes
1427 //
1428  if ((retc = oh->Select().Read((off_t)offset, (size_t)blen)) < 0)
1429  return XrdOfsFS->Emsg(epname, error, (int)retc, "preread", oh, 0, false);
1430 
1431 // Return number of bytes read
1432 //
1433  return retc;
1434 }

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

Referenced by pgRead(), 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 1488 of file XrdOfs.cc.

1502 {
1503  EPNAME("readv");
1504 
1505  XrdSfsXferSize nbytes = oh->Select().ReadV(readV, readCount);
1506  if (nbytes < 0)
1507  return XrdOfsFS->Emsg(epname,error,(int)nbytes,"readv",oh,false,false);
1508 
1509  return nbytes;
1510 
1511 }
virtual ssize_t ReadV(XrdOucIOVec *readV, int rdvcnt)
Definition: XrdOss.cc:252

References XrdOfs::Emsg(), EPNAME, XrdSfsFile::error, 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 1690 of file XrdOfs.cc.

1698 {
1699  EPNAME("fstat");
1700  int retc;
1701 
1702 // Perform any required tracing
1703 //
1704  FTRACE(stat, "");
1705 
1706 // Perform the function
1707 //
1708  if ((retc = oh->Select().Fstat(buf)) < 0)
1709  return XrdOfsFS->Emsg(epname,error,retc,"get state for",oh);
1710 
1711  return SFS_OK;
1712 }
int stat(struct stat *buf)
Definition: XrdOfs.cc:1690
virtual int Fstat(struct stat *buf)
Definition: XrdOss.hh:164

References XrdOfs::Emsg(), EPNAME, XrdSfsFile::error, XrdOssDF::Fstat(), FTRACE, oh, XrdOfsHandle::Select(), SFS_OK, 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 1718 of file XrdOfs.cc.

1726 {
1727  EPNAME("sync");
1728  int retc;
1729 
1730 // Perform any required tracing
1731 //
1732  FTRACE(sync, "");
1733 
1734 // If we have a tpc object hanging about, we need to dispatch that first
1735 //
1736  if (myTPC && (retc = myTPC->Sync(&error))) return retc;
1737 
1738 // We can test the pendio flag w/o a lock because the person doing this
1739 // sync must have done the previous write. Causality is the synchronizer.
1740 //
1741  if (!(oh->isPending)) return SFS_OK;
1742 
1743 // We can also skip the sync if the file is closed. However, we need a file
1744 // object lock in order to test the flag. We can also reset the PENDIO flag.
1745 //
1746  oh->Lock();
1747  oh->isPending = 0;
1748  oh->UnLock();
1749 
1750 // Perform the function
1751 //
1752  if ((retc = oh->Select().Fsync()))
1753  {oh->isPending = 1;
1754  return XrdOfsFS->Emsg(epname, error, retc, "synchronize", oh, true);
1755  }
1756 
1757 // Indicate all went well
1758 //
1759  return SFS_OK;
1760 }
int sync()
Definition: XrdOfs.cc:1718
virtual int Sync(XrdOucErrInfo *error)
Definition: XrdOfsTPC.hh:95
virtual int Fsync()
Definition: XrdOss.hh:172

References XrdOfs::Emsg(), EPNAME, XrdSfsFile::error, XrdOssDF::Fsync(), FTRACE, XrdOfsHandle::isPending, XrdOfsHandle::Lock(), myTPC, oh, XrdOfsHandle::Select(), SFS_OK, XrdOfsTPC::Sync(), XrdOfsHandle::UnLock(), and XrdOfsFS.

Referenced by 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 1768 of file XrdOfs.cc.

1769 {
1770  aiop->Result = this->sync();
1771  aiop->doneWrite();
1772  return 0;
1773 }

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

1793 {
1794  EPNAME("trunc");
1795  int retc;
1796 
1797 // Lock the file handle and perform any tracing
1798 //
1799  FTRACE(truncate, "len=" <<flen);
1800 
1801 // Make sure the offset is not too large
1802 //
1803  if (sizeof(off_t) < sizeof(flen) && flen > 0x000000007fffffff)
1804  return XrdOfsFS->Emsg(epname, error, EFBIG, "truncate", oh, true);
1805 
1806 // Silly Castor stuff
1807 //
1808  if (XrdOfsFS->evsObject && !(oh->isChanged)
1809  && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1810 
1811 // Perform the function
1812 //
1813  oh->isPending = 1;
1814  if ((retc = oh->Select().Ftruncate(flen)))
1815  return XrdOfsFS->Emsg(epname, error, retc, "truncate", oh, true);
1816 
1817 // Indicate Success
1818 //
1819  return SFS_OK;
1820 }
int truncate(XrdSfsFileOffset fileOffset)
Definition: XrdOfs.cc:1779
virtual int Ftruncate(unsigned long long flen)
Definition: XrdOss.hh:192

References XrdOfs::Emsg(), XrdOfsEvs::Enabled(), EPNAME, XrdSfsFile::error, FTRACE, XrdOssDF::Ftruncate(), XrdOfsEvs::Fwrite, XrdOfsHandle::isChanged, XrdOfsHandle::isPending, oh, XrdOfsHandle::Select(), SFS_OK, 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 1622 of file XrdOfs.cc.

1623 {
1624  EPNAME("aiowrite");
1625  int rc;
1626 
1627 // Perform any required tracing
1628 //
1629  FTRACE(aio, aiop->sfsAio.aio_nbytes <<"@" <<aiop->sfsAio.aio_offset);
1630 
1631 // If this is a POSC file, we must convert the async call to a sync call as we
1632 // must trap any errors that unpersist the file. We can't do that via aio i/f.
1633 //
1634  if (oh->isRW == XrdOfsHandle::opPC)
1635  {aiop->Result = this->write(aiop->sfsAio.aio_offset,
1636  (const char *)aiop->sfsAio.aio_buf,
1637  aiop->sfsAio.aio_nbytes);
1638  aiop->doneWrite();
1639  return 0;
1640  }
1641 
1642 // Make sure the offset is not too large
1643 //
1644 #if _FILE_OFFSET_BITS!=64
1645  if (aiop->sfsAio.aio_offset > 0x000000007fffffff)
1646  return XrdOfsFS->Emsg(epname, error, -EFBIG, "write", oh, true, false);
1647 #endif
1648 
1649 // Silly Castor stuff
1650 //
1651  if (XrdOfsFS->evsObject && !(oh->isChanged)
1652  && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1653 
1654 // Write the requested bytes
1655 //
1656  oh->isPending = 1;
1657  if ((rc = oh->Select().Write(aiop)) < 0)
1658  return XrdOfsFS->Emsg(epname, error, rc, "write", oh, true, false);
1659 
1660 // All done
1661 //
1662  return SFS_OK;
1663 }
virtual ssize_t Write(const void *buffer, off_t offset, size_t size)
Definition: XrdOss.hh:385

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, oh, XrdOfsHandle::opPC, XrdSfsAio::Result, XrdOfsHandle::Select(), SFS_OK, XrdSfsAio::sfsAio, XrdOssDF::Write(), 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 1566 of file XrdOfs.cc.

1583 {
1584  EPNAME("write");
1585  XrdSfsXferSize nbytes;
1586 
1587 // Perform any required tracing
1588 //
1589  FTRACE(write, blen <<"@" <<offset);
1590 
1591 // Make sure the offset is not too large
1592 //
1593 #if _FILE_OFFSET_BITS!=64
1594  if (offset > 0x000000007fffffff)
1595  return XrdOfsFS->Emsg(epname,error,-EFBIG,"write",oh,true,false);
1596 #endif
1597 
1598 // Silly Castor stuff
1599 //
1600  if (XrdOfsFS->evsObject && !(oh->isChanged)
1601  && XrdOfsFS->evsObject->Enabled(XrdOfsEvs::Fwrite)) GenFWEvent();
1602 
1603 // Write the requested bytes
1604 //
1605  oh->isPending = 1;
1606  nbytes = (XrdSfsXferSize)(oh->Select().Write((const void *)buff,
1607  (off_t)offset, (size_t)blen));
1608  if (nbytes < 0)
1609  return XrdOfsFS->Emsg(epname,error,(int)nbytes,"write",oh,true,false);
1610 
1611 // Return number of bytes written
1612 //
1613  return nbytes;
1614 }

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

Referenced by 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 207 of file XrdOfs.hh.

Referenced by checkpoint().

◆ dorawio

int XrdOfsFile::dorawio
protected

Definition at line 205 of file XrdOfs.hh.

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

◆ myCKP

XrdOucChkPnt* XrdOfsFile::myCKP
protected

Definition at line 204 of file XrdOfs.hh.

Referenced by checkpoint(), and close().

◆ myTPC

XrdOfsTPC* XrdOfsFile::myTPC
protected

Definition at line 203 of file XrdOfs.hh.

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

◆ oh

XrdOfsHandle* XrdOfsFile::oh
protected

◆ tident

const char* XrdOfsFile::tident
protected

Definition at line 201 of file XrdOfs.hh.

Referenced by close(), and open().

◆ viaDel

char XrdOfsFile::viaDel
protected

Definition at line 206 of file XrdOfs.hh.

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


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