35 #include <sys/param.h>
36 #include <sys/resource.h>
78 std::string dsProperty(
"DataServer");
101 void Done(
int result)
102 {rc = result; pgSem.Post();}
104 int Wait4PGIO() {pgSem.Wait();
return rc;}
106 pgioCB(
const char *who) : pgSem(0, who), rc(0) {}
123 mySize(0), myAtime(0), myCtime(0), myMtime(0), myRdev(0),
124 myInode(0), myMode(0), theCB(cbP), fLoc(0), cOpt(0),
125 isStream(
Opts & isStrm ? 1 : 0)
130 fOpen = strdup(path); aOK =
true;
133 else if (!fPath) fPath = fOpen;
138 {
int n = strlen(path);
169 if (fPath) free(fPath);
170 if (fOpen != fPath) free(fOpen);
171 if (fLoc) free(fLoc);
188 std::string statusMsg;
191 char buff[512], buff2[256];
192 static int ddNumLost = 0;
215 DEBUG(
"DLY destroy of "<<ddCount<<
" objects; "<<ddNumLost <<
" already lost.");
220 int nowLost = ddNumLost;
221 while((fCurr = fNext))
222 {fNext = fCurr->nextFile;
223 if (!(refNum = fCurr->
Refs()))
225 {
delete fCurr; ddCount--;
continue;}
226 else {statusMsg = Status.
ToString();
227 eTxt = statusMsg.c_str();
232 {ddNumLost++; ddCount--;
234 {snprintf(buff2,
sizeof(buff2),
"in use %d", refNum);
238 {snprintf(buff,
sizeof(buff),
"%s timeout closing", eTxt);
241 DMSG(
"DDestroy", eTxt <<
" timeout closing " <<fCurr->
Origin()
242 <<
' ' <<ddNumLost <<
" objects lost");
255 if (
Say && ddNumLost - nowLost >= 3)
256 {snprintf(buff,
sizeof(buff),
"%d objects deferred and %d lost.",
260 DEBUG(
"DLY destroy end; "<<ddCount<<
" objects deferred and "
261 <<ddNumLost <<
" lost.");
298 DEBUG(
"DLY destroy "<<(doPost ?
"post " :
"has ")<<ddCount
299 <<
" objects; added "<<fp->
Origin());
322 if (Status.
IsOK())
return true;
372 if (theSize < 0)
return static_cast<int>(theSize);
377 buf.st_size = theSize;
381 buf.st_blocks = buf.st_size/512 + buf.st_size%512;
416 if (rc < 0)
delete this;
432 if (!fLoc || refresh)
433 {std::string currNode;
435 {
if (!fLoc || strcmp(fLoc, currNode.c_str()))
436 {
if (fLoc) free(fLoc);
437 fLoc = strdup(currNode.c_str());
454 std::vector<uint32_t> &csvec,
460 pgioCB pgrCB(
"Posix pgRead CB");
461 pgRead(pgrCB, buff, offs, rlen, csvec,
opts, csfix);
462 return pgrCB.Wait4PGIO();
471 std::vector<uint32_t> &csvec,
485 if (csfix) *csfix = 0;
491 Status =
clFile.
PgRead((uint64_t)offs,(uint32_t)rlen,buff,rhP);
508 std::vector<uint32_t> &csvec,
516 if (csfix) *csfix = 0;
521 Status =
clFile.
PgWrite((uint64_t)offs, (uint32_t)wlen, buff, csvec);
533 std::vector<uint32_t> &csvec,
555 Status =
clFile.
PgWrite((uint64_t)offs, (uint32_t)wlen, buff, csvec, rhP);
577 {pgioCB pgrCB(
"Posix pgRead CB");
578 Read(pgrCB, Buff, Offs, Len);
579 return pgrCB.Wait4PGIO();
585 Status =
clFile.
Read((uint64_t)Offs, (uint32_t)Len, Buff, bytes);
609 if (doPgRd) Status =
clFile.
PgRead((uint64_t)offs,(uint32_t)rlen,buff,rhP);
610 else Status =
clFile.
Read ((uint64_t)offs,(uint32_t)rlen,buff,rhP);
634 for (
int i = 0; i < n; i++)
635 {nbytes += readV[i].
size;
637 (uint32_t)readV[i].size,
638 (
void *)readV[i].data
666 for (
int i = 0; i < n; i++)
667 {nbytes += readV[i].
size;
669 (uint32_t)readV[i].size,
670 (
void *)readV[i].data
713 myInode =
static_cast<ino_t
>(strtoll(sInfo->
GetId().c_str(), 0, 10));
798 Status =
clFile.
Write((uint64_t)Offs, (uint32_t)Len, Buff);
816 Status =
clFile.
Write((uint64_t)offs, (uint32_t)wlen, buff, rhp);
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.