XRootD
XrdPssFile Class Reference

#include <XrdPss.hh>

+ Inheritance diagram for XrdPssFile:
+ Collaboration diagram for XrdPssFile:

Public Member Functions

 XrdPssFile (const char *tid)
 
virtual ~XrdPssFile ()
 
virtual int Close (long long *retsz=0)
 
int Fchmod (mode_t mode)
 
int Fstat (struct stat *)
 
int Fsync ()
 
int Fsync (XrdSfsAio *aiop)
 
int Ftruncate (unsigned long long)
 
virtual int Open (const char *, int, mode_t, XrdOucEnv &)
 
ssize_t pgRead (void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
 
int pgRead (XrdSfsAio *aioparm, uint64_t opts)
 
ssize_t pgWrite (void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts)
 
int pgWrite (XrdSfsAio *aioparm, uint64_t opts)
 
ssize_t Read (off_t, size_t)
 
ssize_t Read (void *, off_t, size_t)
 
int Read (XrdSfsAio *aiop)
 
ssize_t ReadRaw (void *, off_t, size_t)
 
ssize_t ReadV (XrdOucIOVec *readV, int n)
 
ssize_t Write (const void *, off_t, size_t)
 
int Write (XrdSfsAio *aiop)
 
- Public Member Functions inherited from XrdOssDF
 XrdOssDF (const char *tid="", uint16_t dftype=0, int fdnum=-1)
 
virtual ~XrdOssDF ()
 
uint16_t DFType ()
 
virtual int Fctl (int cmd, int alen, const char *args, char **resp=0)
 
virtual void Flush ()
 Flush filesystem cached pages for this file (used for checksums). More...
 
virtual int getFD ()
 
virtual off_t getMmap (void **addr)
 
virtual const char * getTID ()
 
virtual int isCompressed (char *cxidp=0)
 
virtual int Opendir (const char *path, XrdOucEnv &env)
 
virtual int Readdir (char *buff, int blen)
 
virtual int StatRet (struct stat *buff)
 
virtual ssize_t WriteV (XrdOucIOVec *writeV, int wrvcnt)
 

Additional Inherited Members

- Static Public Attributes inherited from XrdOssDF
static const uint16_t DF_isDir = 0x0001
 Object is for a directory. More...
 
static const uint16_t DF_isFile = 0x0002
 Object is for a file. More...
 
static const uint16_t DF_isProxy = 0x0010
 Object is a proxy object. More...
 
static const uint64_t doCalc = 0x4000000000000000ULL
 pgw: Calculate checksums More...
 
static const int Fctl_ckpObj = 0
 
static const int Fctl_utimes = 1
 
static const uint64_t Verify = 0x8000000000000000ULL
 all: Verify checksums More...
 
- Protected Attributes inherited from XrdOssDF
uint16_t dfType
 
int fd
 
off_t pgwEOF
 
short rsvd
 
const char * tident
 

Detailed Description

Definition at line 74 of file XrdPss.hh.

Constructor & Destructor Documentation

◆ XrdPssFile()

XrdPssFile::XrdPssFile ( const char *  tid)
inline

Definition at line 104 of file XrdPss.hh.

106  rpInfo(0), tpcPath(0), entity(0) {}
static const uint16_t DF_isFile
Object is for a file.
Definition: XrdOss.hh:393
XrdOssDF(const char *tid="", uint16_t dftype=0, int fdnum=-1)
Definition: XrdOss.hh:444
static const uint16_t DF_isProxy
Object is a proxy object.
Definition: XrdOss.hh:394

◆ ~XrdPssFile()

virtual XrdPssFile::~XrdPssFile ( )
inlinevirtual

Definition at line 108 of file XrdPss.hh.

108  {if (fd >= 0) Close();
109  if (rpInfo) delete(rpInfo);
110  if (tpcPath) free(tpcPath);
111  }
int fd
Definition: XrdOss.hh:455
virtual int Close(long long *retsz=0)
Definition: XrdPss.cc:907

References Close(), and XrdOssDF::fd.

+ Here is the call graph for this function:

Member Function Documentation

◆ Close()

int XrdPssFile::Close ( long long *  retsz = 0)
virtual

Close a directory or file.

Parameters
retszIf not nil, where the size of the file is to be returned.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Implements XrdOssDF.

Definition at line 907 of file XrdPss.cc.

908 { int rc;
909 
910 // We don't support returning the size (we really should fix this)
911 //
912  if (retsz) *retsz = 0;
913 
914 // If the file is not open, then this may be OK if it is a 3rd party copy
915 //
916  if (fd < 0)
917  {if (!tpcPath) return -XRDOSS_E8004;
918  free(tpcPath);
919  tpcPath = 0;
920  return XrdOssOK;
921  }
922 
923 // Close the file
924 //
926  fd = -1;
927  return (rc == 0 ? XrdOssOK : -errno);
928 }
#define XRDOSS_E8004
Definition: XrdOssError.hh:38
#define XrdOssOK
Definition: XrdOss.hh:50
static int Close(int fildes)
Close() conforms to POSIX.1-2001 close()

References XrdPosixXrootd::Close(), XrdOssDF::fd, XRDOSS_E8004, and XrdOssOK.

Referenced by ~XrdPssFile().

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

◆ Fchmod()

int XrdPssFile::Fchmod ( mode_t  mode)
inlinevirtual

Change file mode settings.

Parameters
mode- The new file mode setting.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 84 of file XrdPss.hh.

84 {return XrdOssOK;}

References XrdOssOK.

◆ Fstat()

int XrdPssFile::Fstat ( struct stat buf)
virtual

Return state information for this file.

Parameters
buf- Pointer to the structure where info it to be returned.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1175 of file XrdPss.cc.

1176 {
1177  EPNAME("fstat");
1178 
1179 // If we have a file descriptor then return a stat for it
1180 //
1181  if (fd >= 0) return (XrdPosixXrootd::Fstat(fd, buff) ? -errno : XrdOssOK);
1182 
1183 // Otherwise, if this is not a tpc of any kind, return an error
1184 //
1185  if (!tpcPath) return -XRDOSS_E8004;
1186 
1187 // If this is a normal tpc then simply issue the stat against the origin
1188 //
1189  if (!rpInfo)
1190  {XrdOucEnv fstatEnv(0, 0, entity);
1191  return XrdProxySS.Stat(tpcPath, buff, 0, &fstatEnv);
1192  }
1193 
1194 // This is a reproxy tpc, if we have not yet dertermined the true dest, do so.
1195 //
1196  struct stat Stat;
1197 
1198  if (rpInfo->dstURL == 0
1199  || !fstatat(rpFD, rpInfo->tprPath, &Stat, AT_SYMLINK_NOFOLLOW))
1200  {char lnkbuff[2048]; int lnklen;
1201  lnklen = readlinkat(rpFD, rpInfo->tprPath, lnkbuff, sizeof(lnkbuff)-1);
1202  if (lnklen <= 0)
1203  {int rc = 0;
1204  if (lnklen < 0) {if (errno != ENOENT) rc = -errno;}
1205  else rc = -EFAULT;
1206  if (rc)
1207  {unlinkat(rpFD, rpInfo->tprPath, 0);
1208  return rc;
1209  }
1210  } else {
1211  unlinkat(rpFD, rpInfo->tprPath, 0);
1212  lnkbuff[lnklen] = 0;
1213  if (rpInfo->dstURL) free(rpInfo->dstURL);
1214  rpInfo->dstURL = strdup(lnkbuff);
1215  rpInfo->fSize = 1;
1216  DEBUG(tident,rpInfo->tprPath<<" maps "<<tpcPath<<" -> "<<lnkbuff);
1217  }
1218  }
1219 
1220 // At this point we may or may not have the final endpoint. An error here could
1221 // be due to write error recovery, so make allowance for that.
1222 //
1223  if (rpInfo->dstURL)
1224  {if (!XrdPosixXrootd::Stat(rpInfo->dstURL, buff))
1225  {if (!(rpInfo->fSize = buff->st_size)) rpInfo->fSize = 1;
1226  return XrdOssOK;
1227  }
1228  free(rpInfo->dstURL);
1229  rpInfo->dstURL = 0;
1230  }
1231 
1232 // We don't have the final endpoint. If we ever had it before, then punt.
1233 //
1234  if (rpInfo->fSize)
1235  {memset(buff, 0, sizeof(struct stat));
1236  buff->st_size = rpInfo->fSize;
1237  return XrdOssOK;
1238  }
1239 
1240 // If we are here then maybe the reproxy option was the wrong config setting.
1241 // Give stat a try on the origin we'll retry resolution on the next stat.
1242 //
1243  XrdOucEnv fstatEnv(0, 0, entity);
1244 
1245  if (XrdProxySS.Stat(tpcPath, buff, 0, &fstatEnv))
1246  memset(buff, 0, sizeof(struct stat));
1247  return XrdOssOK;
1248 }
#define DEBUG(x)
Definition: XrdBwmTrace.hh:54
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
struct stat Stat
Definition: XrdCks.cc:49
int stat(const char *path, struct stat *buf)
const char * tident
Definition: XrdOss.hh:453
static int Stat(const char *path, struct stat *buf)
Stat() conforms to POSIX.1-2001 stat()
static int Fstat(int fildes, struct stat *buf)
Fstat() conforms to POSIX.1-2001 fstat()
int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0) override
Definition: XrdPss.cc:490
int rpFD
Definition: XrdPss.cc:121
static XrdPssSys XrdProxySS
Definition: XrdPss.cc:101

References DEBUG, EPNAME, XrdOssDF::fd, XrdPosixXrootd::Fstat(), XrdProxy::rpFD, Stat, XrdPssSys::Stat(), stat(), XrdPosixXrootd::Stat(), XrdOssDF::tident, XRDOSS_E8004, XrdOssOK, and XrdProxy::XrdProxySS.

+ Here is the call graph for this function:

◆ Fsync() [1/2]

int XrdPssFile::Fsync ( void  )
virtual

Synchronize associated file with media (synchronous).

Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1261 of file XrdPss.cc.

1262 {
1263  if (fd < 0) return -XRDOSS_E8004;
1264 
1265  return (XrdPosixXrootd::Fsync(fd) ? -errno : XrdOssOK);
1266 }
static int Fsync(int fildes)
Fsync() conforms to POSIX.1-2001 fsync()

References XrdOssDF::fd, XrdPosixXrootd::Fsync(), XRDOSS_E8004, and XrdOssOK.

+ Here is the call graph for this function:

◆ Fsync() [2/2]

int XrdPssFile::Fsync ( XrdSfsAio aiop)
virtual

Synchronize associated file with media (asynchronous).

Parameters
aiop- Pointer to async I/O request object.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 53 of file XrdPssAio.cc.

54 {
55 
56 // Execute this request in an asynchronous fashion
57 //
59  return 0;
60 }
static XrdPssAioCB * Alloc(XrdSfsAio *aiop, bool isWr, bool pgrw=false)
Definition: XrdPssAioCB.cc:49

References XrdPssAioCB::Alloc(), XrdOssDF::fd, and XrdPosixXrootd::Fsync().

+ Here is the call graph for this function:

◆ Ftruncate()

int XrdPssFile::Ftruncate ( unsigned long long  flen)
virtual

Set the size of the associated file.

Parameters
flen- The new size of the file.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1290 of file XrdPss.cc.

1291 {
1292  if (fd < 0) return -XRDOSS_E8004;
1293 
1294  return (XrdPosixXrootd::Ftruncate(fd, flen) ? -errno : XrdOssOK);
1295 }
static int Ftruncate(int fildes, off_t offset)
Ftruncate() conforms to POSIX.1-2001 ftruncate()

References XrdOssDF::fd, XrdPosixXrootd::Ftruncate(), XRDOSS_E8004, and XrdOssOK.

+ Here is the call graph for this function:

◆ Open()

int XrdPssFile::Open ( const char *  path,
int  Oflag,
mode_t  Mode,
XrdOucEnv env 
)
virtual

Open a file.

Parameters
path- Pointer to the path of the file to be opened.
Oflag- Standard open flags.
Mode- File open mode (ignored unless creating a file).
env- Reference to environmental information.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 771 of file XrdPss.cc.

772 {
773  EPNAME("Open");
774  unsigned long long popts = XrdPssSys::XPList.Find(path);
775  const char *Cgi = "";
776  char pbuff[PBsz];
777  int rc;
778  bool tpcMode = (Oflag & O_NOFOLLOW) != 0;
779  bool rwMode = (Oflag & (O_WRONLY | O_RDWR | O_APPEND)) != 0;
780  bool ucgiOK = true;
781  bool ioCache = (Oflag & O_DIRECT);
782 
783 // Record the security environment
784 //
785  entity = Env.secEnv();
786 
787 // Turn off direct flag if set (we record it separately
788 //
789  if (ioCache) Oflag &= ~O_DIRECT;
790 
791 // Return an error if the object is already open
792 //
793  if (fd >= 0 || tpcPath) return -XRDOSS_E8003;
794 
795 // If we are opening this in r/w mode make sure we actually can
796 //
797  if (rwMode)
798  {if (XrdPssSys::fileOrgn) return -EROFS;
799  if (popts & XRDEXP_NOTRW)
800  {if (popts & XRDEXP_FORCERO && !tpcMode) Oflag = O_RDONLY;
801  else return -EROFS;
802  }
803  }
804 
805  // check CGI cache-control paramters
806  if (cacheFSctl)
807  {
808  int elen;
809  char *envcgi = (char *)Env.Env(elen);
810 
811  if (envcgi && strstr(envcgi, "only-if-cached"))
812  {
813  XrdOucErrInfo einfo;
814  XrdSfsFSctl myData;
815  myData.Arg1 = "cached";
816  myData.Arg1Len = 1;
817  myData.Arg2Len = 1;
818  const char *myArgs[1];
819  myArgs[0] = path;
820  myData.ArgP = myArgs;
821  int fsctlRes = cacheFSctl->FSctl(SFS_FSCTL_PLUGXC, myData, einfo);
822  if (fsctlRes == SFS_ERROR)
823  return -einfo.getErrInfo();
824  }
825  }
826 
827 // If this is a third party copy open, then strange rules apply. If this is an
828 // outgoing proxy we let everything pass through as this may be a TPC request
829 // elsewhere. Otherwise, if it's an open for reading, we open the file but
830 // strip off all CGI (technically, we should only remove the "tpc" tokens)
831 // because the source might not support direct TPC mode. If we are opening for
832 // writing, then we skip the open and mark this as a TPC handle which can only
833 // be used for fstat() and close(). Any other actions return an error.
834 //
835  if (tpcMode)
836  {Oflag &= ~O_NOFOLLOW;
837  if (!XrdProxy::outProxy || !IS_FWDPATH(path))
838  {if (rwMode)
839  {tpcPath = strdup(path);
840  if (XrdPssSys::reProxy)
841  {const char *rPath = Env.Get("tpc.reproxy");
842  if (!rPath || *rPath != '/') return -ENOATTR;
843  if (!(rPath = rindex(rPath, '/')) || *(rPath+1) == 0)
844  return -EFAULT;
845  rpInfo = new tprInfo(rPath+1);
846  }
847  return XrdOssOK;
848  }
849  ucgiOK = false;
850  }
851  }
852 
853 // Setup any required cgi information. Don't mess with it if it's an objectid
854 // or if the we are an outgoing proxy server.
855 //
856  if (!XrdProxy::outProxy && *path == '/' && !(XRDEXP_STAGE & popts))
857  Cgi = osslclCGI;
858 
859 // Construct the url info
860 //
861  XrdPssUrlInfo uInfo(&Env, path, Cgi, ucgiOK);
862  uInfo.setID();
863 
864 // Convert path to URL
865 //
866  if ((rc = XrdPssSys::P2URL(pbuff, PBsz, uInfo, XrdPssSys::xLfn2Pfn)))
867  return rc;
868 
869 // Do some tracing
870 //
871  if(DEBUGON) {
872  auto urlObf = obfuscateAuth(pbuff);
873  DEBUG(uInfo.Tident(),"url="<<urlObf);
874  }
875 
876 // Try to open and if we failed, return an error
877 //
878  if (!XrdPssSys::dcaCheck || !ioCache)
879  {if ((fd = XrdPosixXrootd::Open(pbuff,Oflag,Mode)) < 0) return -errno;
880  } else {
882  Info.ffReady = XrdPssSys::dcaWorld;
883  if (XrdPosixConfig::OpenFC(pbuff,Oflag,Mode,Info))
884  {Env.Put("FileURL", Info.cacheURL);
885  return -EDESTADDRREQ;
886  }
887  fd = Info.fileFD;
888  if (fd < 0) return -errno;
889  }
890 
891 // All done
892 //
893  return XrdOssOK;
894 }
#define XRDOSS_E8003
Definition: XrdOssError.hh:37
@ Info
#define XRDEXP_NOTRW
Definition: XrdOucExport.hh:45
#define XRDEXP_FORCERO
Definition: XrdOucExport.hh:43
#define XRDEXP_STAGE
Definition: XrdOucExport.hh:52
std::string obfuscateAuth(const std::string &input)
#define DEBUGON
#define IS_FWDPATH(x)
Definition: XrdPssUtils.hh:64
#define ENOATTR
Definition: XrdPss.cc:80
#define O_DIRECT
Definition: XrdPss.cc:76
int Mode
const char * Arg1
PLUGINO, PLUGION, PLUGXC.
int Arg2Len
Length or -count of args in extension.
#define SFS_ERROR
int Arg1Len
Length.
#define SFS_FSCTL_PLUGXC
< SFS_FSCTL_PLUGIN/PLUGIO/PLUGXC parms
virtual int FSctl(const int cmd, int alen, const char *args, XrdSfsFile &file, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0)=0
unsigned long long Find(const char *pathname)
Definition: XrdOucPList.hh:112
static bool OpenFC(const char *path, int oflag, mode_t mode, XrdPosixInfo &Info)
static int Open(const char *path, int oflag, mode_t mode=0, XrdPosixCallBack *cbP=0)
static char * fileOrgn
Definition: XrdPss.hh:195
static bool dcaCheck
Definition: XrdPss.hh:205
static bool reProxy
Definition: XrdPss.hh:208
static XrdOucPListAnchor XPList
Definition: XrdPss.hh:191
static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo, bool doN2N=true)
Definition: XrdPss.cc:1402
static bool xLfn2Pfn
Definition: XrdPss.hh:204
static bool dcaWorld
Definition: XrdPss.hh:206
XrdOfsFSctl_PI * cacheFSctl
Definition: XrdPss.cc:111
static const int PBsz
Definition: XrdPss.cc:119
static const char * osslclCGI
Definition: XrdPss.cc:117
bool outProxy
Definition: XrdPss.cc:125

References XrdSfsFSctl::Arg1, XrdSfsFSctl::Arg1Len, XrdSfsFSctl::Arg2Len, XrdProxy::cacheFSctl, XrdPssSys::dcaCheck, XrdPssSys::dcaWorld, DEBUG, DEBUGON, ENOATTR, XrdOucEnv::Env(), EPNAME, XrdOssDF::fd, XrdPssSys::fileOrgn, XrdOucPListAnchor::Find(), XrdOfsFSctl_PI::FSctl(), XrdOucEnv::Get(), XrdOucErrInfo::getErrInfo(), Info, IS_FWDPATH, Mode, O_DIRECT, obfuscateAuth(), XrdPosixXrootd::Open(), XrdPosixConfig::OpenFC(), XrdProxy::osslclCGI, XrdProxy::outProxy, XrdPssSys::P2URL(), XrdProxy::PBsz, XrdOucEnv::Put(), XrdPssSys::reProxy, XrdOucEnv::secEnv(), XrdPssUrlInfo::setID(), SFS_ERROR, SFS_FSCTL_PLUGXC, XrdPssUrlInfo::Tident(), XrdPssSys::xLfn2Pfn, XrdPssSys::XPList, XRDEXP_FORCERO, XRDEXP_NOTRW, XRDEXP_STAGE, XRDOSS_E8003, and XrdOssOK.

+ Here is the call graph for this function:

◆ pgRead() [1/2]

ssize_t XrdPssFile::pgRead ( void *  buffer,
off_t  offset,
size_t  rdlen,
uint32_t *  csvec,
uint64_t  opts 
)
virtual

Reimplemented from XrdOssDF.

Definition at line 948 of file XrdPss.cc.

953 {
954  std::vector<uint32_t> vecCS;
955  uint64_t psxOpts;
956  ssize_t bytes;
957 
958 // Make sure file is open
959 //
960  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
961 
962 // Set options as needed
963 //
964  psxOpts = (csvec ? XrdPosixExtra::forceCS : 0);
965 
966 // Issue the pgread
967 //
968  if ((bytes = XrdPosixExtra::pgRead(fd,buffer,offset,rdlen,vecCS,psxOpts)) < 0)
969  return (ssize_t)-errno;
970 
971 // Copy out the checksum vector
972 //
973  if (vecCS.size() && csvec)
974  memcpy(csvec, vecCS.data(), vecCS.size()*sizeof(uint32_t));
975 
976 // All done
977 //
978  return bytes;
979 }
static const uint64_t forceCS
static ssize_t pgRead(int fildes, void *buffer, off_t offset, size_t rdlen, std::vector< uint32_t > &csvec, uint64_t opts=0, XrdPosixCallBackIO *cbp=0)

References XrdOssDF::fd, XrdPosixExtra::forceCS, XrdPosixExtra::pgRead(), and XRDOSS_E8004.

+ Here is the call graph for this function:

◆ pgRead() [2/2]

int XrdPssFile::pgRead ( XrdSfsAio aioparm,
uint64_t  opts 
)
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
0 upon if request started success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 77 of file XrdPssAio.cc.

78 {
79  XrdPssAioCB *aioCB = XrdPssAioCB::Alloc(aiop, false, true);
80  uint64_t psxOpts = (aiop->cksVec ? XrdPosixExtra::forceCS : 0);
81 
82 // Execute this request in an asynchronous fashion
83 //
84  XrdPosixExtra::pgRead(fd, (void *)aiop->sfsAio.aio_buf,
85  (off_t)aiop->sfsAio.aio_offset,
86  (size_t)aiop->sfsAio.aio_nbytes,
87  aioCB->csVec, psxOpts, aioCB);
88  return 0;
89 }
std::vector< uint32_t > csVec
Definition: XrdPssAioCB.hh:53

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, XrdPssAioCB::Alloc(), XrdSfsAio::cksVec, XrdPssAioCB::csVec, XrdOssDF::fd, XrdPosixExtra::forceCS, XrdPosixExtra::pgRead(), and XrdSfsAio::sfsAio.

+ Here is the call graph for this function:

◆ pgWrite() [1/2]

ssize_t XrdPssFile::pgWrite ( void *  buffer,
off_t  offset,
size_t  wrlen,
uint32_t *  csvec,
uint64_t  opts 
)
virtual

Write file pages into a file with corresponding checksums.

Parameters
buffer- pointer to buffer containing the bytes to write.
offset- The offset where the write is to start.
wrlen- The number of bytes to write.
csvec- A vector which contains the corresponding CRC32 checksum for each page. See XrdOucPgrwUtils::csNum() for sizing.
opts- Processing options (see above).
Returns
>= 0 The number of bytes written upon success. or -errno or -osserr upon failure. (see XrdOssError.hh).
< 0 -errno or -osserr upon failure. (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1001 of file XrdPss.cc.

1006 {
1007  std::vector<uint32_t> vecCS;
1008  ssize_t bytes;
1009 
1010 // Make sure we have an open file
1011 //
1012  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1013 
1014 // Check if caller wants to verify the checksums before writing
1015 //
1016  if (csvec && (opts & XrdOssDF::Verify))
1017  {XrdOucPgrwUtils::dataInfo dInfo((const char*)buffer,csvec,offset,wrlen);
1018  off_t bado;
1019  int badc;
1020  if (!XrdOucPgrwUtils::csVer(dInfo, bado, badc)) return -EDOM;
1021  }
1022 
1023 // Check if caller want checksum generated and possibly returned
1024 //
1025  if ((opts & XrdOssDF::doCalc) || csvec == 0)
1026  {XrdOucPgrwUtils::csCalc((const char *)buffer, offset, wrlen, vecCS);
1027  if (csvec) memcpy(csvec, vecCS.data(), vecCS.size()*sizeof(uint32_t));
1028  } else {
1029  int n = XrdOucPgrwUtils::csNum(offset, wrlen);
1030  vecCS.resize(n);
1031  vecCS.assign(n, 0);
1032  memcpy(vecCS.data(), csvec, n*sizeof(uint32_t));
1033  }
1034 
1035 // Issue the pgwrite
1036 //
1037  bytes = XrdPosixExtra::pgWrite(fd, buffer, offset, wrlen, vecCS);
1038 
1039 // Return result
1040 //
1041  return (bytes < 0 ? (ssize_t)-errno : bytes);
1042 }
struct myOpts opts
static const uint64_t doCalc
pgw: Calculate checksums
Definition: XrdOss.hh:225
static const uint64_t Verify
all: Verify checksums
Definition: XrdOss.hh:223
static void csCalc(const char *data, off_t offs, size_t count, uint32_t *csval)
static bool csVer(dataInfo &dInfo, off_t &bado, int &badc)
static int csNum(off_t offs, int count)
Compute the required size of a checksum vector based on offset & length.
static ssize_t pgWrite(int fildes, void *buffer, off_t offset, size_t wrlen, std::vector< uint32_t > &csvec, uint64_t opts=0, XrdPosixCallBackIO *cbp=0)

References XrdOucPgrwUtils::csCalc(), XrdOucPgrwUtils::csNum(), XrdOucPgrwUtils::csVer(), XrdOssDF::doCalc, XrdOssDF::fd, opts, XrdPosixExtra::pgWrite(), XrdOssDF::Verify, and XRDOSS_E8004.

+ Here is the call graph for this function:

◆ pgWrite() [2/2]

int XrdPssFile::pgWrite ( XrdSfsAio aioparm,
uint64_t  opts 
)
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
0 upon if request started success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 106 of file XrdPssAio.cc.

107 {
108 
109 // Check if caller wants to verify the checksums before writing
110 //
111  if (aiop->cksVec && (opts & XrdOssDF::Verify))
112  {XrdOucPgrwUtils::dataInfo dInfo((const char *)(aiop->sfsAio.aio_buf),
113  aiop->cksVec, aiop->sfsAio.aio_offset,
114  aiop->sfsAio.aio_nbytes);
115  off_t bado;
116  int badc;
117  if (!XrdOucPgrwUtils::csVer(dInfo, bado, badc)) return -EDOM;
118  }
119 
120 // Get a callback object as no errors can error here
121 //
122  XrdPssAioCB *aioCB = XrdPssAioCB::Alloc(aiop, true, true);
123 
124 // Check if caller want checksum generated and possibly returned
125 //
126  if ((opts & XrdOssDF::doCalc) || aiop->cksVec == 0)
127  {XrdOucPgrwUtils::csCalc((const char *)(aiop->sfsAio.aio_buf),
128  (off_t)(aiop->sfsAio.aio_offset),
129  (size_t)(aiop->sfsAio.aio_nbytes),
130  aioCB->csVec);
131  if (aiop->cksVec) memcpy(aiop->cksVec, aioCB->csVec.data(),
132  aioCB->csVec.size()*sizeof(uint32_t));
133  } else {
134  int n = XrdOucPgrwUtils::csNum(aiop->sfsAio.aio_offset,
135  aiop->sfsAio.aio_nbytes);
136  aioCB->csVec.resize(n);
137  aioCB->csVec.assign(n, 0);
138  memcpy(aioCB->csVec.data(), aiop->cksVec, n*sizeof(uint32_t));
139  }
140 
141 // Issue the pgWrite
142 //
143  XrdPosixExtra::pgWrite(fd, (void *)aiop->sfsAio.aio_buf,
144  (off_t)aiop->sfsAio.aio_offset,
145  (size_t)aiop->sfsAio.aio_nbytes,
146  aioCB->csVec, 0, aioCB);
147  return 0;
148 }

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, XrdPssAioCB::Alloc(), XrdSfsAio::cksVec, XrdOucPgrwUtils::csCalc(), XrdOucPgrwUtils::csNum(), XrdPssAioCB::csVec, XrdOucPgrwUtils::csVer(), XrdOssDF::doCalc, XrdOssDF::fd, opts, XrdPosixExtra::pgWrite(), XrdSfsAio::sfsAio, and XrdOssDF::Verify.

+ Here is the call graph for this function:

◆ Read() [1/3]

ssize_t XrdPssFile::Read ( off_t  offset,
size_t  size 
)
virtual

Preread file blocks into the file system cache.

Parameters
offset- The offset where the read is to start.
size- The number of bytes to pre-read.
Returns
0 upon success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1057 of file XrdPss.cc.

1058 {
1059  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1060 
1061  return 0; // We haven't implemented this yet!
1062 }

References XrdOssDF::fd, and XRDOSS_E8004.

Referenced by ReadRaw().

+ Here is the caller graph for this function:

◆ Read() [2/3]

ssize_t XrdPssFile::Read ( void *  buffer,
off_t  offset,
size_t  size 
)
virtual

Read file bytes into a buffer.

Parameters
buffer- pointer to buffer where the bytes are to be placed.
offset- The offset where the read is to start.
size- The number of bytes to read.
Returns
>= 0 The number of bytes that placed in buffer.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1081 of file XrdPss.cc.

1082 {
1083  ssize_t retval;
1084 
1085  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1086 
1087  return (retval = XrdPosixXrootd::Pread(fd, buff, blen, offset)) < 0
1088  ? (ssize_t)-errno : retval;
1089 }
static ssize_t Pread(int fildes, void *buf, size_t nbyte, off_t offset)
Pread() conforms to POSIX.1-2001 pread()

References XrdOssDF::fd, XrdPosixXrootd::Pread(), and XRDOSS_E8004.

+ Here is the call graph for this function:

◆ Read() [3/3]

int XrdPssFile::Read ( XrdSfsAio aiop)
virtual

Read file bytes using asynchronous I/O.

Parameters
aiop- Pointer to async I/O object controlling the I/O.
Returns
0 upon if request started success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 165 of file XrdPssAio.cc.

166 {
167 
168 // Execute this request in an asynchronous fashion
169 //
170  XrdPosixXrootd::Pread(fd, (void *)aiop->sfsAio.aio_buf,
171  (size_t)aiop->sfsAio.aio_nbytes,
172  (off_t)aiop->sfsAio.aio_offset,
173  XrdPssAioCB::Alloc(aiop, false));
174  return 0;
175 }
off_t aio_offset
Definition: XrdSfsAio.hh:49
size_t aio_nbytes
Definition: XrdSfsAio.hh:48
void * aio_buf
Definition: XrdSfsAio.hh:47
struct aiocb sfsAio
Definition: XrdSfsAio.hh:62

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, XrdPssAioCB::Alloc(), XrdOssDF::fd, XrdPosixXrootd::Pread(), and XrdSfsAio::sfsAio.

+ Here is the call graph for this function:

◆ ReadRaw()

ssize_t XrdPssFile::ReadRaw ( void *  buffer,
off_t  offset,
size_t  size 
)
virtual

Read uncompressed file bytes into a buffer.

Parameters
buffer- pointer to buffer where the bytes are to be placed.
offset- The offset where the read is to start.
size- The number of bytes to read.
Returns
>= 0 The number of bytes that placed in buffer.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1133 of file XrdPss.cc.

1134 {
1135  return Read(buff, offset, blen);
1136 }
ssize_t Read(off_t, size_t)
Definition: XrdPss.cc:1057

References Read().

+ Here is the call graph for this function:

◆ ReadV()

ssize_t XrdPssFile::ReadV ( XrdOucIOVec readV,
int  rdvcnt 
)
virtual

Read file bytes as directed by the read vector.

Parameters
readVpointer to the array of read requests.
rdvcntthe number of elements in readV.
Returns
>=0 The numbe of bytes read.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1095 of file XrdPss.cc.

1109 {
1110  ssize_t retval;
1111 
1112  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1113 
1114  return (retval = XrdPosixXrootd::VRead(fd, readV, readCount)) < 0 ? (ssize_t)-errno : retval;;
1115 }
static void VRead(int fildes, const XrdOucIOVec *readV, int n, XrdPosixCallBackIO *cbp)

References XrdOssDF::fd, XrdPosixXrootd::VRead(), and XRDOSS_E8004.

+ Here is the call graph for this function:

◆ Write() [1/2]

ssize_t XrdPssFile::Write ( const void *  buffer,
off_t  offset,
size_t  size 
)
virtual

Write file bytes from a buffer.

Parameters
buffer- pointer to buffer where the bytes reside.
offset- The offset where the write is to start.
size- The number of bytes to write.
Returns
>= 0 The number of bytes that were written.
< 0 -errno or -osserr upon failure (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 1153 of file XrdPss.cc.

1154 {
1155  ssize_t retval;
1156 
1157  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1158 
1159  return (retval = XrdPosixXrootd::Pwrite(fd, buff, blen, offset)) < 0
1160  ? (ssize_t)-errno : retval;
1161 }
static ssize_t Pwrite(int fildes, const void *buf, size_t nbyte, off_t offset)
Pwrite() conforms to POSIX.1-2001 pwrite()

References XrdOssDF::fd, XrdPosixXrootd::Pwrite(), and XRDOSS_E8004.

+ Here is the call graph for this function:

◆ Write() [2/2]

int XrdPssFile::Write ( XrdSfsAio aiop)
virtual

Write file bytes using asynchronous I/O.

Parameters
aiop- Pointer to async I/O object controlling the I/O.
Returns
0 upon if request started success or -errno or -osserr (see XrdOssError.hh).

Reimplemented from XrdOssDF.

Definition at line 192 of file XrdPssAio.cc.

193 {
194 
195 // Execute this request in an asynchronous fashion
196 //
197  XrdPosixXrootd::Pwrite(fd, (const void *)aiop->sfsAio.aio_buf,
198  (size_t)aiop->sfsAio.aio_nbytes,
199  (off_t)aiop->sfsAio.aio_offset,
200  XrdPssAioCB::Alloc(aiop, true));
201  return 0;
202 }

References aiocb::aio_buf, aiocb::aio_nbytes, aiocb::aio_offset, XrdPssAioCB::Alloc(), XrdOssDF::fd, XrdPosixXrootd::Pwrite(), and XrdSfsAio::sfsAio.

+ Here is the call graph for this function:

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