35 #include <sys/param.h>
36 #include <sys/resource.h>
79 std::string dsProperty(
"DataServer");
102 void Done(
int result)
103 {rc = result; pgSem.Post();}
105 int Wait4PGIO() {pgSem.Wait();
return rc;}
107 pgioCB(
const char *who) : pgSem(0, who), rc(0) {}
124 mySize(0), myAtime(0), myCtime(0), myMtime(0), myRdev(0),
125 myInode(0), myMode(0), theCB(cbP), fLoc(0), cOpt(0),
126 isStream(
Opts & isStrm ? 1 : 0)
131 fOpen = strdup(path); aOK =
true;
134 else if (!fPath) fPath = fOpen;
139 {
int n = strlen(path);
170 if (fPath) free(fPath);
171 if (fOpen != fPath) free(fOpen);
172 if (fLoc) free(fLoc);
189 std::string statusMsg;
192 char buff[512], buff2[256];
193 static int ddNumLost = 0;
216 DEBUG(
"DLY destroy of "<<ddCount<<
" objects; "<<ddNumLost <<
" already lost.");
221 int nowLost = ddNumLost;
222 while((fCurr = fNext))
223 {fNext = fCurr->nextFile;
224 if (!(refNum = fCurr->
Refs()))
226 {
delete fCurr; ddCount--;
continue;}
227 else {statusMsg = Status.
ToString();
228 eTxt = statusMsg.c_str();
233 {ddNumLost++; ddCount--;
235 {snprintf(buff2,
sizeof(buff2),
"in use %d", refNum);
239 {snprintf(buff,
sizeof(buff),
"%s timeout closing", eTxt);
243 <<
' ' <<ddNumLost <<
" objects lost");
256 if (
Say && ddNumLost - nowLost >= 3)
257 {snprintf(buff,
sizeof(buff),
"%d objects deferred and %d lost.",
261 DEBUG(
"DLY destroy end; "<<ddCount<<
" objects deferred and "
262 <<ddNumLost <<
" lost.");
300 DEBUG(
"DLY destroy " << (doPost ?
"post " :
"has ") << ddCount
324 if (Status.
IsOK())
return true;
374 if (theSize < 0)
return static_cast<int>(theSize);
379 buf.st_size = theSize;
383 buf.st_blocks = buf.st_size/512 + buf.st_size%512;
418 if (rc < 0)
delete this;
434 if (!fLoc || refresh)
435 {std::string currNode;
437 {
if (!fLoc || strcmp(fLoc, currNode.c_str()))
438 {
if (fLoc) free(fLoc);
439 fLoc = strdup(currNode.c_str());
456 std::vector<uint32_t> &csvec,
462 pgioCB pgrCB(
"Posix pgRead CB");
463 pgRead(pgrCB, buff, offs, rlen, csvec,
opts, csfix);
464 return pgrCB.Wait4PGIO();
473 std::vector<uint32_t> &csvec,
487 if (csfix) *csfix = 0;
493 Status =
clFile.
PgRead((uint64_t)offs,(uint32_t)rlen,buff,rhP);
510 std::vector<uint32_t> &csvec,
518 if (csfix) *csfix = 0;
523 Status =
clFile.
PgWrite((uint64_t)offs, (uint32_t)wlen, buff, csvec);
535 std::vector<uint32_t> &csvec,
557 Status =
clFile.
PgWrite((uint64_t)offs, (uint32_t)wlen, buff, csvec, rhP);
579 {pgioCB pgrCB(
"Posix pgRead CB");
580 Read(pgrCB, Buff, Offs, Len);
581 return pgrCB.Wait4PGIO();
587 Status =
clFile.
Read((uint64_t)Offs, (uint32_t)Len, Buff, bytes);
611 if (doPgRd) Status =
clFile.
PgRead((uint64_t)offs,(uint32_t)rlen,buff,rhP);
612 else Status =
clFile.
Read ((uint64_t)offs,(uint32_t)rlen,buff,rhP);
636 for (
int i = 0; i < n; i++)
637 {nbytes += readV[i].
size;
639 (uint32_t)readV[i].size,
640 (
void *)readV[i].data
668 for (
int i = 0; i < n; i++)
669 {nbytes += readV[i].
size;
671 (uint32_t)readV[i].size,
672 (
void *)readV[i].data
715 myInode =
static_cast<ino_t
>(strtoll(sInfo->
GetId().c_str(), 0, 10));
800 Status =
clFile.
Write((uint64_t)Offs, (uint32_t)Len, Buff);
818 Status =
clFile.
Write((uint64_t)offs, (uint32_t)wlen, buff, rhp);
std::string obfuscateAuth(const std::string &input)
int stat(const char *path, struct stat *buf)
XRootDStatus Read(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
XRootDStatus Close(ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
bool IsOpen() const
Check if the file is open.
XRootDStatus Truncate(uint64_t size, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
XRootDStatus VectorRead(const ChunkList &chunks, void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
bool GetProperty(const std::string &name, std::string &value) const
XRootDStatus Write(uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
XRootDStatus PgRead(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
XRootDStatus Stat(bool force, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
XRootDStatus Sync(ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
XRootDStatus PgWrite(uint64_t offset, uint32_t size, const void *buffer, std::vector< uint32_t > &cksums, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
uint64_t GetChangeTime() const
Get change time (in seconds since epoch)
uint64_t GetSize() const
Get size (in bytes)
uint32_t GetFlags() const
Get flags.
bool ExtendedFormat() const
Has extended stat information.
const std::string & GetId() const
Get id.
uint64_t GetModTime() const
Get modification time (in seconds since epoch)
uint64_t GetAccessTime() const
Get change time (in seconds since epoch)
virtual void Done(int result)=0
static const uint64_t forceCS
virtual long long FSize()=0
struct XrdOucCacheStats::CacheStats X
void Count(long long &Dest)
void Set(XrdOucCacheStats &S)
static const int optRW
File is read/write (o/w read/only)
virtual XrdOucCacheIO * Attach(XrdOucCacheIO *ioP, int opts=0)=0
XrdOucCacheStats Statistics
static const int optFIS
File is structured (e.g. root file)
An abstract class to define a callback for Open() call.
virtual void Complete(int Result)=0
static void initStat(struct stat *buf)
void setCSVec(std::vector< uint32_t > *csv, int *csf, bool fcs=false)
static XrdPosixFileRH * Alloc(XrdOucCacheIOCB *cbp, XrdPosixFile *fp, long long offs, int xResult, ioType typeIO)
XrdPosixFile(bool &aOK, const char *path, XrdPosixCallBack *cbP=0, int Opts=0)
static XrdSysSemaphore ddSem
static XrdSysMutex ddMutex
int Write(char *Buff, long long Offs, int Len) override
static XrdPosixFile * ddLost
int Read(char *Buff, long long Offs, int Len) override
int Fstat(struct stat &buf) override
int pgRead(char *buff, long long offs, int rdlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0) override
int Trunc(long long Offset) override
const char * Location(bool refresh=false) override
bool Stat(XrdCl::XRootDStatus &Status, bool force=false)
bool Close(XrdCl::XRootDStatus &Status)
static XrdPosixFile * ddList
void HandleResponse(XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override
bool Finalize(XrdCl::XRootDStatus *Status)
int ReadV(const XrdOucIOVec *readV, int n) override
static void * DelayedDestroy(void *)
int pgWrite(char *buff, long long offs, int wrlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0) override
static mode_t Flags2Mode(dev_t *rdv, uint32_t flags)
static int Result(const XrdCl::XRootDStatus &Status, XrdOucECMsg &ecMsg, bool retneg1=false)
void Count(long long &Dest)
static const char * P2L(const char *who, const char *inP, char *&relP, bool ponly=false)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
static void Snooze(int seconds)
std::vector< ChunkInfo > ChunkList
List of chunks.
Describe a data chunk for vector read.
bool IsOK() const
We're fine.
std::string ToString() const
Create a string representation.