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:881

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 881 of file XrdPss.cc.

882 { int rc;
883 
884 // We don't support returning the size (we really should fix this)
885 //
886  if (retsz) *retsz = 0;
887 
888 // If the file is not open, then this may be OK if it is a 3rd party copy
889 //
890  if (fd < 0)
891  {if (!tpcPath) return -XRDOSS_E8004;
892  free(tpcPath);
893  tpcPath = 0;
894  return XrdOssOK;
895  }
896 
897 // Close the file
898 //
900  fd = -1;
901  return (rc == 0 ? XrdOssOK : -errno);
902 }
#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 1149 of file XrdPss.cc.

1150 {
1151  EPNAME("fstat");
1152 
1153 // If we have a file descriptor then return a stat for it
1154 //
1155  if (fd >= 0) return (XrdPosixXrootd::Fstat(fd, buff) ? -errno : XrdOssOK);
1156 
1157 // Otherwise, if this is not a tpc of any kind, return an error
1158 //
1159  if (!tpcPath) return -XRDOSS_E8004;
1160 
1161 // If this is a normal tpc then simply issue the stat against the origin
1162 //
1163  if (!rpInfo)
1164  {XrdOucEnv fstatEnv(0, 0, entity);
1165  return XrdProxySS.Stat(tpcPath, buff, 0, &fstatEnv);
1166  }
1167 
1168 // This is a reproxy tpc, if we have not yet dertermined the true dest, do so.
1169 //
1170  struct stat Stat;
1171 
1172  if (rpInfo->dstURL == 0
1173  || !fstatat(rpFD, rpInfo->tprPath, &Stat, AT_SYMLINK_NOFOLLOW))
1174  {char lnkbuff[2048]; int lnklen;
1175  lnklen = readlinkat(rpFD, rpInfo->tprPath, lnkbuff, sizeof(lnkbuff)-1);
1176  if (lnklen <= 0)
1177  {int rc = 0;
1178  if (lnklen < 0) {if (errno != ENOENT) rc = -errno;}
1179  else rc = -EFAULT;
1180  if (rc)
1181  {unlinkat(rpFD, rpInfo->tprPath, 0);
1182  return rc;
1183  }
1184  } else {
1185  unlinkat(rpFD, rpInfo->tprPath, 0);
1186  lnkbuff[lnklen] = 0;
1187  if (rpInfo->dstURL) free(rpInfo->dstURL);
1188  rpInfo->dstURL = strdup(lnkbuff);
1189  rpInfo->fSize = 1;
1190  DEBUG(tident,rpInfo->tprPath<<" maps "<<tpcPath<<" -> "<<lnkbuff);
1191  }
1192  }
1193 
1194 // At this point we may or may not have the final endpoint. An error here could
1195 // be due to write error recovery, so make allowance for that.
1196 //
1197  if (rpInfo->dstURL)
1198  {if (!XrdPosixXrootd::Stat(rpInfo->dstURL, buff))
1199  {if (!(rpInfo->fSize = buff->st_size)) rpInfo->fSize = 1;
1200  return XrdOssOK;
1201  }
1202  free(rpInfo->dstURL);
1203  rpInfo->dstURL = 0;
1204  }
1205 
1206 // We don't have the final endpoint. If we ever had it before, then punt.
1207 //
1208  if (rpInfo->fSize)
1209  {memset(buff, 0, sizeof(struct stat));
1210  buff->st_size = rpInfo->fSize;
1211  return XrdOssOK;
1212  }
1213 
1214 // If we are here then maybe the reproxy option was the wrong config setting.
1215 // Give stat a try on the origin we'll retry resolution on the next stat.
1216 //
1217  XrdOucEnv fstatEnv(0, 0, entity);
1218 
1219  if (XrdProxySS.Stat(tpcPath, buff, 0, &fstatEnv))
1220  memset(buff, 0, sizeof(struct stat));
1221  return XrdOssOK;
1222 }
#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:479
int rpFD
Definition: XrdPss.cc:120
static XrdPssSys XrdProxySS
Definition: XrdPss.cc:100

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 1235 of file XrdPss.cc.

1236 {
1237  if (fd < 0) return -XRDOSS_E8004;
1238 
1239  return (XrdPosixXrootd::Fsync(fd) ? -errno : XrdOssOK);
1240 }
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 1264 of file XrdPss.cc.

1265 {
1266  if (fd < 0) return -XRDOSS_E8004;
1267 
1268  return (XrdPosixXrootd::Ftruncate(fd, flen) ? -errno : XrdOssOK);
1269 }
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 748 of file XrdPss.cc.

749 {
750  EPNAME("Open");
751  unsigned long long popts = XrdPssSys::XPList.Find(path);
752  const char *Cgi = "";
753  char pbuff[PBsz];
754  int rc;
755  bool tpcMode = (Oflag & O_NOFOLLOW) != 0;
756  bool rwMode = (Oflag & (O_WRONLY | O_RDWR | O_APPEND)) != 0;
757  bool ucgiOK = true;
758  bool ioCache = (Oflag & O_DIRECT);
759 
760 // Record the security environment
761 //
762  entity = Env.secEnv();
763 
764 // Turn off direct flag if set (we record it separately
765 //
766  if (ioCache) Oflag &= ~O_DIRECT;
767 
768 // Return an error if the object is already open
769 //
770  if (fd >= 0 || tpcPath) return -XRDOSS_E8003;
771 
772 // If we are opening this in r/w mode make sure we actually can
773 //
774  if (rwMode)
775  {if (XrdPssSys::fileOrgn) return -EROFS;
776  if (popts & XRDEXP_NOTRW)
777  {if (popts & XRDEXP_FORCERO && !tpcMode) Oflag = O_RDONLY;
778  else return -EROFS;
779  }
780  }
781 
782  // check CGI cache-control paramters
783  if (cacheFSctl)
784  {
785  int elen;
786  char *envcgi = (char *)Env.Env(elen);
787 
788  if (envcgi && strstr(envcgi, "only-if-cached"))
789  {
790  XrdOucErrInfo einfo;
791  XrdSfsFSctl myData;
792  myData.Arg1 = "cached";
793  myData.Arg1Len = 1;
794  myData.Arg2Len = 1;
795  const char *myArgs[1];
796  myArgs[0] = path;
797  myData.ArgP = myArgs;
798  int fsctlRes = cacheFSctl->FSctl(SFS_FSCTL_PLUGXC, myData, einfo);
799  if (fsctlRes == SFS_ERROR)
800  return -einfo.getErrInfo();
801  }
802  }
803 
804 // If this is a third party copy open, then strange rules apply. If this is an
805 // outgoing proxy we let everything pass through as this may be a TPC request
806 // elsewhere. Otherwise, if it's an open for reading, we open the file but
807 // strip off all CGI (technically, we should only remove the "tpc" tokens)
808 // because the source might not support direct TPC mode. If we are opening for
809 // writing, then we skip the open and mark this as a TPC handle which can only
810 // be used for fstat() and close(). Any other actions return an error.
811 //
812  if (tpcMode)
813  {Oflag &= ~O_NOFOLLOW;
814  if (!XrdProxy::outProxy || !IS_FWDPATH(path))
815  {if (rwMode)
816  {tpcPath = strdup(path);
817  if (XrdPssSys::reProxy)
818  {const char *rPath = Env.Get("tpc.reproxy");
819  if (!rPath || *rPath != '/') return -ENOATTR;
820  if (!(rPath = rindex(rPath, '/')) || *(rPath+1) == 0)
821  return -EFAULT;
822  rpInfo = new tprInfo(rPath+1);
823  }
824  return XrdOssOK;
825  }
826  ucgiOK = false;
827  }
828  }
829 
830 // Setup any required cgi information. Don't mess with it if it's an objectid
831 // or if the we are an outgoing proxy server.
832 //
833  if (!XrdProxy::outProxy && *path == '/' && !(XRDEXP_STAGE & popts))
834  Cgi = osslclCGI;
835 
836 // Construct the url info
837 //
838  XrdPssUrlInfo uInfo(&Env, path, Cgi, ucgiOK);
839  uInfo.setID();
840 
841 // Convert path to URL
842 //
843  if ((rc = XrdPssSys::P2URL(pbuff, PBsz, uInfo, XrdPssSys::xLfn2Pfn)))
844  return rc;
845 
846 // Do some tracing
847 //
848  DEBUG(uInfo.Tident(),"url="<<pbuff);
849 
850 // Try to open and if we failed, return an error
851 //
852  if (!XrdPssSys::dcaCheck || !ioCache)
853  {if ((fd = XrdPosixXrootd::Open(pbuff,Oflag,Mode)) < 0) return -errno;
854  } else {
856  Info.ffReady = XrdPssSys::dcaWorld;
857  if (XrdPosixConfig::OpenFC(pbuff,Oflag,Mode,Info))
858  {Env.Put("FileURL", Info.cacheURL);
859  return -EDESTADDRREQ;
860  }
861  fd = Info.fileFD;
862  if (fd < 0) return -errno;
863  }
864 
865 // All done
866 //
867  return XrdOssOK;
868 }
#define XRDOSS_E8003
Definition: XrdOssError.hh:37
#define XRDEXP_NOTRW
Definition: XrdOucExport.hh:45
#define XRDEXP_FORCERO
Definition: XrdOucExport.hh:43
#define XRDEXP_STAGE
Definition: XrdOucExport.hh:52
#define IS_FWDPATH(x)
Definition: XrdPssUtils.hh:64
#define ENOATTR
Definition: XrdPss.cc:79
#define O_DIRECT
Definition: XrdPss.cc:75
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
@ Info
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:1376
static bool xLfn2Pfn
Definition: XrdPss.hh:204
static bool dcaWorld
Definition: XrdPss.hh:206
XrdOfsFSctl_PI * cacheFSctl
Definition: XrdPss.cc:110
static const int PBsz
Definition: XrdPss.cc:118
static const char * osslclCGI
Definition: XrdPss.cc:116
bool outProxy
Definition: XrdPss.cc:124

References XrdSfsFSctl::Arg1, XrdSfsFSctl::Arg1Len, XrdSfsFSctl::Arg2Len, XrdProxy::cacheFSctl, XrdPssSys::dcaCheck, XrdPssSys::dcaWorld, DEBUG, ENOATTR, XrdOucEnv::Env(), EPNAME, XrdOssDF::fd, XrdPssSys::fileOrgn, XrdOucPListAnchor::Find(), XrdOfsFSctl_PI::FSctl(), XrdOucEnv::Get(), XrdOucErrInfo::getErrInfo(), Info, IS_FWDPATH, Mode, O_DIRECT, 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 922 of file XrdPss.cc.

927 {
928  std::vector<uint32_t> vecCS;
929  uint64_t psxOpts;
930  ssize_t bytes;
931 
932 // Make sure file is open
933 //
934  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
935 
936 // Set options as needed
937 //
938  psxOpts = (csvec ? XrdPosixExtra::forceCS : 0);
939 
940 // Issue the pgread
941 //
942  if ((bytes = XrdPosixExtra::pgRead(fd,buffer,offset,rdlen,vecCS,psxOpts)) < 0)
943  return (ssize_t)-errno;
944 
945 // Copy out the checksum vector
946 //
947  if (vecCS.size() && csvec)
948  memcpy(csvec, vecCS.data(), vecCS.size()*sizeof(uint32_t));
949 
950 // All done
951 //
952  return bytes;
953 }
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 975 of file XrdPss.cc.

980 {
981  std::vector<uint32_t> vecCS;
982  ssize_t bytes;
983 
984 // Make sure we have an open file
985 //
986  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
987 
988 // Check if caller wants to verify the checksums before writing
989 //
990  if (csvec && (opts & XrdOssDF::Verify))
991  {XrdOucPgrwUtils::dataInfo dInfo((const char*)buffer,csvec,offset,wrlen);
992  off_t bado;
993  int badc;
994  if (!XrdOucPgrwUtils::csVer(dInfo, bado, badc)) return -EDOM;
995  }
996 
997 // Check if caller want checksum generated and possibly returned
998 //
999  if ((opts & XrdOssDF::doCalc) || csvec == 0)
1000  {XrdOucPgrwUtils::csCalc((const char *)buffer, offset, wrlen, vecCS);
1001  if (csvec) memcpy(csvec, vecCS.data(), vecCS.size()*sizeof(uint32_t));
1002  } else {
1003  int n = XrdOucPgrwUtils::csNum(offset, wrlen);
1004  vecCS.resize(n);
1005  vecCS.assign(n, 0);
1006  memcpy(vecCS.data(), csvec, n*sizeof(uint32_t));
1007  }
1008 
1009 // Issue the pgwrite
1010 //
1011  bytes = XrdPosixExtra::pgWrite(fd, buffer, offset, wrlen, vecCS);
1012 
1013 // Return result
1014 //
1015  return (bytes < 0 ? (ssize_t)-errno : bytes);
1016 }
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 1031 of file XrdPss.cc.

1032 {
1033  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1034 
1035  return 0; // We haven't implemented this yet!
1036 }

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 1055 of file XrdPss.cc.

1056 {
1057  ssize_t retval;
1058 
1059  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1060 
1061  return (retval = XrdPosixXrootd::Pread(fd, buff, blen, offset)) < 0
1062  ? (ssize_t)-errno : retval;
1063 }
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 1107 of file XrdPss.cc.

1108 {
1109  return Read(buff, offset, blen);
1110 }
ssize_t Read(off_t, size_t)
Definition: XrdPss.cc:1031

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 1069 of file XrdPss.cc.

1083 {
1084  ssize_t retval;
1085 
1086  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1087 
1088  return (retval = XrdPosixXrootd::VRead(fd, readV, readCount)) < 0 ? (ssize_t)-errno : retval;;
1089 }
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 1127 of file XrdPss.cc.

1128 {
1129  ssize_t retval;
1130 
1131  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1132 
1133  return (retval = XrdPosixXrootd::Pwrite(fd, buff, blen, offset)) < 0
1134  ? (ssize_t)-errno : retval;
1135 }
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: