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 81 of file XrdPss.hh.

Constructor & Destructor Documentation

◆ XrdPssFile()

XrdPssFile::XrdPssFile ( const char *  tid)
inline

Definition at line 111 of file XrdPss.hh.

113  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 115 of file XrdPss.hh.

115  {if (fd >= 0) Close();
116  if (rpInfo) delete(rpInfo);
117  if (tpcPath) free(tpcPath);
118  }
int fd
Definition: XrdOss.hh:455
virtual int Close(long long *retsz=0)
Definition: XrdPss.cc:919

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

920 { int rc;
921 
922 // We don't support returning the size (we really should fix this)
923 //
924  if (retsz) *retsz = 0;
925 
926 // If the file is not open, then this may be OK if it is a 3rd party copy
927 //
928  if (fd < 0)
929  {if (!tpcPath) return -XRDOSS_E8004;
930  free(tpcPath);
931  tpcPath = 0;
932  return XrdOssOK;
933  }
934 
935 // Close the file
936 //
938  fd = -1;
939  return (rc == 0 ? XrdOssOK : -errno);
940 }
#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 91 of file XrdPss.hh.

91 {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 1187 of file XrdPss.cc.

1188 {
1189  EPNAME("fstat");
1190 
1191 // If we have a file descriptor then return a stat for it
1192 //
1193  if (fd >= 0) return (XrdPosixXrootd::Fstat(fd, buff) ? -errno : XrdOssOK);
1194 
1195 // Otherwise, if this is not a tpc of any kind, return an error
1196 //
1197  if (!tpcPath) return -XRDOSS_E8004;
1198 
1199 // If this is a normal tpc then simply issue the stat against the origin
1200 //
1201  if (!rpInfo)
1202  {XrdOucEnv fstatEnv(0, 0, entity);
1203  return XrdProxySS.Stat(tpcPath, buff, 0, &fstatEnv);
1204  }
1205 
1206 // This is a reproxy tpc, if we have not yet dertermined the true dest, do so.
1207 //
1208  struct stat Stat;
1209 
1210  if (rpInfo->dstURL == 0
1211  || !fstatat(rpFD, rpInfo->tprPath, &Stat, AT_SYMLINK_NOFOLLOW))
1212  {char lnkbuff[2048]; int lnklen;
1213  lnklen = readlinkat(rpFD, rpInfo->tprPath, lnkbuff, sizeof(lnkbuff)-1);
1214  if (lnklen <= 0)
1215  {int rc = 0;
1216  if (lnklen < 0) {if (errno != ENOENT) rc = -errno;}
1217  else rc = -EFAULT;
1218  if (rc)
1219  {unlinkat(rpFD, rpInfo->tprPath, 0);
1220  return rc;
1221  }
1222  } else {
1223  unlinkat(rpFD, rpInfo->tprPath, 0);
1224  lnkbuff[lnklen] = 0;
1225  if (rpInfo->dstURL) free(rpInfo->dstURL);
1226  rpInfo->dstURL = strdup(lnkbuff);
1227  rpInfo->fSize = 1;
1228  DEBUG(tident,rpInfo->tprPath<<" maps "<<tpcPath<<" -> "<<lnkbuff);
1229  }
1230  }
1231 
1232 // At this point we may or may not have the final endpoint. An error here could
1233 // be due to write error recovery, so make allowance for that.
1234 //
1235  if (rpInfo->dstURL)
1236  {if (!XrdPosixXrootd::Stat(rpInfo->dstURL, buff))
1237  {if (!(rpInfo->fSize = buff->st_size)) rpInfo->fSize = 1;
1238  return XrdOssOK;
1239  }
1240  free(rpInfo->dstURL);
1241  rpInfo->dstURL = 0;
1242  }
1243 
1244 // We don't have the final endpoint. If we ever had it before, then punt.
1245 //
1246  if (rpInfo->fSize)
1247  {memset(buff, 0, sizeof(struct stat));
1248  buff->st_size = rpInfo->fSize;
1249  return XrdOssOK;
1250  }
1251 
1252 // If we are here then maybe the reproxy option was the wrong config setting.
1253 // Give stat a try on the origin we'll retry resolution on the next stat.
1254 //
1255  XrdOucEnv fstatEnv(0, 0, entity);
1256 
1257  if (XrdProxySS.Stat(tpcPath, buff, 0, &fstatEnv))
1258  memset(buff, 0, sizeof(struct stat));
1259  return XrdOssOK;
1260 }
#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 1273 of file XrdPss.cc.

1274 {
1275  if (fd < 0) return -XRDOSS_E8004;
1276 
1277  return (XrdPosixXrootd::Fsync(fd) ? -errno : XrdOssOK);
1278 }
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 1302 of file XrdPss.cc.

1303 {
1304  if (fd < 0) return -XRDOSS_E8004;
1305 
1306  return (XrdPosixXrootd::Ftruncate(fd, flen) ? -errno : XrdOssOK);
1307 }
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 783 of file XrdPss.cc.

784 {
785  EPNAME("Open");
786  unsigned long long popts = XrdPssSys::XPList.Find(path);
787  const char *Cgi = "";
788  char pbuff[PBsz];
789  int rc;
790  bool tpcMode = (Oflag & O_NOFOLLOW) != 0;
791  bool rwMode = (Oflag & (O_WRONLY | O_RDWR | O_APPEND)) != 0;
792  bool ucgiOK = true;
793  bool ioCache = (Oflag & O_DIRECT);
794 
795 // Record the security environment
796 //
797  entity = Env.secEnv();
798 
799 // Turn off direct flag if set (we record it separately
800 //
801  if (ioCache) Oflag &= ~O_DIRECT;
802 
803 // Return an error if the object is already open
804 //
805  if (fd >= 0 || tpcPath) return -XRDOSS_E8003;
806 
807 // If we are opening this in r/w mode make sure we actually can
808 //
809  if (rwMode)
810  {if (XrdPssSys::fileOrgn) return -EROFS;
811  if (popts & XRDEXP_NOTRW)
812  {if (popts & XRDEXP_FORCERO && !tpcMode) Oflag = O_RDONLY;
813  else return -EROFS;
814  }
815  }
816 
817  // check CGI cache-control paramters
818  if (cacheFSctl)
819  {
820  int elen;
821  char *envcgi = (char *)Env.Env(elen);
822 
823  if (envcgi && strstr(envcgi, "only-if-cached"))
824  {
825  XrdOucErrInfo einfo;
826  XrdSfsFSctl myData;
827  myData.Arg1 = "cached";
828  myData.Arg1Len = 1;
829  myData.Arg2Len = 1;
830  const char *myArgs[1];
831  myArgs[0] = path;
832  myData.ArgP = myArgs;
833  int fsctlRes = cacheFSctl->FSctl(SFS_FSCTL_PLUGXC, myData, einfo);
834  if (fsctlRes == SFS_ERROR)
835  return -einfo.getErrInfo();
836  }
837  }
838 
839 // If this is a third party copy open, then strange rules apply. If this is an
840 // outgoing proxy we let everything pass through as this may be a TPC request
841 // elsewhere. Otherwise, if it's an open for reading, we open the file but
842 // strip off all CGI (technically, we should only remove the "tpc" tokens)
843 // because the source might not support direct TPC mode. If we are opening for
844 // writing, then we skip the open and mark this as a TPC handle which can only
845 // be used for fstat() and close(). Any other actions return an error.
846 //
847  if (tpcMode)
848  {Oflag &= ~O_NOFOLLOW;
849  if (!XrdProxy::outProxy || !IS_FWDPATH(path))
850  {if (rwMode)
851  {tpcPath = strdup(path);
852  if (XrdPssSys::reProxy)
853  {const char *rPath = Env.Get("tpc.reproxy");
854  if (!rPath || *rPath != '/') return -ENOATTR;
855  if (!(rPath = rindex(rPath, '/')) || *(rPath+1) == 0)
856  return -EFAULT;
857  rpInfo = new tprInfo(rPath+1);
858  }
859  return XrdOssOK;
860  }
861  ucgiOK = false;
862  }
863  }
864 
865 // Setup any required cgi information. Don't mess with it if it's an objectid
866 // or if the we are an outgoing proxy server.
867 //
868  if (!XrdProxy::outProxy && *path == '/' && !(XRDEXP_STAGE & popts))
869  Cgi = osslclCGI;
870 
871 // Construct the url info
872 //
873  XrdPssUrlInfo uInfo(&Env, path, Cgi, ucgiOK);
874  uInfo.setID();
875 
876 // Convert path to URL
877 //
878  if ((rc = XrdPssSys::P2URL(pbuff, PBsz, uInfo, XrdPssSys::xLfn2Pfn)))
879  return rc;
880 
881 // Do some tracing
882 //
883  if(DEBUGON) {
884  auto urlObf = obfuscateAuth(pbuff);
885  DEBUG(uInfo.Tident(),"url="<<urlObf);
886  }
887 
888 // Try to open and if we failed, return an error
889 //
890  if (!XrdPssSys::dcaCheck || !ioCache)
891  {if ((fd = XrdPosixXrootd::Open(pbuff,Oflag,Mode)) < 0) return -errno;
892  } else {
894  Info.ffReady = XrdPssSys::dcaWorld;
895  if (XrdPosixConfig::OpenFC(pbuff,Oflag,Mode,Info))
896  {Env.Put("FileURL", Info.cacheURL);
897  return -EDESTADDRREQ;
898  }
899  fd = Info.fileFD;
900  if (fd < 0) return -errno;
901  }
902 
903 // All done
904 //
905  return XrdOssOK;
906 }
#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
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:202
static bool dcaCheck
Definition: XrdPss.hh:212
static bool reProxy
Definition: XrdPss.hh:215
static XrdOucPListAnchor XPList
Definition: XrdPss.hh:198
static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo, bool doN2N=true)
Definition: XrdPss.cc:1414
static bool xLfn2Pfn
Definition: XrdPss.hh:211
static bool dcaWorld
Definition: XrdPss.hh:213
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(), Macaroons::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 960 of file XrdPss.cc.

965 {
966  std::vector<uint32_t> vecCS;
967  uint64_t psxOpts;
968  ssize_t bytes;
969 
970 // Make sure file is open
971 //
972  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
973 
974 // Set options as needed
975 //
976  psxOpts = (csvec ? XrdPosixExtra::forceCS : 0);
977 
978 // Issue the pgread
979 //
980  if ((bytes = XrdPosixExtra::pgRead(fd,buffer,offset,rdlen,vecCS,psxOpts)) < 0)
981  return (ssize_t)-errno;
982 
983 // Copy out the checksum vector
984 //
985  if (vecCS.size() && csvec)
986  memcpy(csvec, vecCS.data(), vecCS.size()*sizeof(uint32_t));
987 
988 // All done
989 //
990  return bytes;
991 }
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 1013 of file XrdPss.cc.

1018 {
1019  std::vector<uint32_t> vecCS;
1020  ssize_t bytes;
1021 
1022 // Make sure we have an open file
1023 //
1024  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1025 
1026 // Check if caller wants to verify the checksums before writing
1027 //
1028  if (csvec && (opts & XrdOssDF::Verify))
1029  {XrdOucPgrwUtils::dataInfo dInfo((const char*)buffer,csvec,offset,wrlen);
1030  off_t bado;
1031  int badc;
1032  if (!XrdOucPgrwUtils::csVer(dInfo, bado, badc)) return -EDOM;
1033  }
1034 
1035 // Check if caller want checksum generated and possibly returned
1036 //
1037  if ((opts & XrdOssDF::doCalc) || csvec == 0)
1038  {XrdOucPgrwUtils::csCalc((const char *)buffer, offset, wrlen, vecCS);
1039  if (csvec) memcpy(csvec, vecCS.data(), vecCS.size()*sizeof(uint32_t));
1040  } else {
1041  int n = XrdOucPgrwUtils::csNum(offset, wrlen);
1042  vecCS.resize(n);
1043  vecCS.assign(n, 0);
1044  memcpy(vecCS.data(), csvec, n*sizeof(uint32_t));
1045  }
1046 
1047 // Issue the pgwrite
1048 //
1049  bytes = XrdPosixExtra::pgWrite(fd, buffer, offset, wrlen, vecCS);
1050 
1051 // Return result
1052 //
1053  return (bytes < 0 ? (ssize_t)-errno : bytes);
1054 }
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 1069 of file XrdPss.cc.

1070 {
1071  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1072 
1073  return 0; // We haven't implemented this yet!
1074 }

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

1094 {
1095  ssize_t retval;
1096 
1097  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1098 
1099  return (retval = XrdPosixXrootd::Pread(fd, buff, blen, offset)) < 0
1100  ? (ssize_t)-errno : retval;
1101 }
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 1145 of file XrdPss.cc.

1146 {
1147  return Read(buff, offset, blen);
1148 }
ssize_t Read(off_t, size_t)
Definition: XrdPss.cc:1069

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

1121 {
1122  ssize_t retval;
1123 
1124  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1125 
1126  return (retval = XrdPosixXrootd::VRead(fd, readV, readCount)) < 0 ? (ssize_t)-errno : retval;;
1127 }
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 1165 of file XrdPss.cc.

1166 {
1167  ssize_t retval;
1168 
1169  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1170 
1171  return (retval = XrdPosixXrootd::Pwrite(fd, buff, blen, offset)) < 0
1172  ? (ssize_t)-errno : retval;
1173 }
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: