36#include <sys/resource.h>
79std::string dsProperty(
"DataServer");
103 {rc = result; pgSem.Post();}
105int Wait4PGIO() {pgSem.Wait();
return rc;}
107 pgioCB(
const char *who) : pgSem(0, who), rc(0) {}
112XrdSysSemaphore pgSem;
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.",
259 Say->Emsg(
"DDestroy", buff);
261 DEBUG(
"DLY destroy end; "<<ddCount<<
" objects deferred and "
262 <<ddNumLost <<
" lost.");
300 DEBUG(
"DLY destroy " << (doPost ?
"post " :
"has ") << ddCount
303 if (doPost)
ddSem.Post();
324 if (Status.
IsOK())
return true;
346 default: resp =
"Unsupported operation code.";
352 uint32_t sz = args.size();
353 if (sz && args[0]) sz++;
355 if (sz) theArgs.
Append(args.c_str(), sz);
362 Status =
clFile.Fcntl(qCode, theArgs, theResp);
368 {
if (theResp)
delete theResp;
374 if (!theResp || !(sz = theResp->
GetSize())) resp =
"";
375 else resp.assign(theResp->
GetBuffer(), sz);
379 if (theResp)
delete theResp;
425 theSize =
XCio->FSize();
426 if (theSize < 0)
return static_cast<int>(theSize);
431 buf.st_size = theSize;
435 buf.st_blocks = buf.st_size/512 + buf.st_size%512;
470 if (rc < 0)
delete this;
482 if (!
clFile.IsOpen())
return "";
486 if (!fLoc || refresh)
487 {std::string currNode;
488 if (
clFile.GetProperty(dsProperty, currNode))
489 {
if (!fLoc || strcmp(fLoc, currNode.c_str()))
490 {
if (fLoc) free(fLoc);
491 fLoc = strdup(currNode.c_str());
508 std::vector<uint32_t> &csvec,
514 pgioCB pgrCB(
"Posix pgRead CB");
515 pgRead(pgrCB, buff, offs, rlen, csvec,
opts, csfix);
516 return pgrCB.Wait4PGIO();
525 std::vector<uint32_t> &csvec,
539 if (csfix) *csfix = 0;
545 Status =
clFile.PgRead((uint64_t)offs,(uint32_t)rlen,buff,rhP);
562 std::vector<uint32_t> &csvec,
570 if (csfix) *csfix = 0;
575 Status =
clFile.PgWrite((uint64_t)offs, (uint32_t)wlen, buff, csvec);
587 std::vector<uint32_t> &csvec,
609 Status =
clFile.PgWrite((uint64_t)offs, (uint32_t)wlen, buff, csvec, rhP);
631 {pgioCB pgrCB(
"Posix pgRead CB");
632 Read(pgrCB, Buff, Offs, Len);
633 return pgrCB.Wait4PGIO();
639 Status =
clFile.Read((uint64_t)Offs, (uint32_t)Len, Buff, bytes);
663 if (doPgRd) Status =
clFile.PgRead((uint64_t)offs,(uint32_t)rlen,buff,rhP);
664 else Status =
clFile.Read ((uint64_t)offs,(uint32_t)rlen,buff,rhP);
688 for (
int i = 0; i < n; i++)
689 {nbytes += readV[i].
size;
691 (uint32_t)readV[i].size,
692 (
void *)readV[i].data
700 Status =
clFile.VectorRead(chunkVec, (
void *)0, vrInfo);
720 for (
int i = 0; i < n; i++)
721 {nbytes += readV[i].
size;
723 (uint32_t)readV[i].size,
724 (
void *)readV[i].data
733 Status =
clFile.VectorRead(chunkVec, (
void *)0, rhp);
754 Status =
clFile.Stat(force, sInfo);
767 myInode =
static_cast<ino_t
>(strtoll(sInfo->
GetId().c_str(), 0, 10));
815 Status =
clFile.Sync(rhp);
852 Status =
clFile.Write((uint64_t)Offs, (uint32_t)Len, Buff);
870 Status =
clFile.Write((uint64_t)offs, (uint32_t)wlen, buff, rhp);
XrdOucPup XrdCmsParser::Pup & Say
std::string obfuscateAuth(const std::string &input)
Binary blob representation.
void Append(const char *buffer, uint32_t size)
Append data at the position pointed to by the append cursor.
const char * GetBuffer(uint32_t offset=0) const
Get the message buffer.
uint32_t GetSize() const
Get the size of the message.
bool IsOpen() const
Check if the file is open.
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).
static const uint64_t forceCS
XrdOucCacheIO()
Construct and Destructor.
static const int optRW
File is read/write (o/w read/only).
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
int Fcntl(XrdOucCacheOp::Code opc, const std::string &args, std::string &resp) 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)
static const char * P2L(const char *who, const char *inP, char *&relP, bool ponly=false)
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.
Code
XRootD query request codes.
@ FInfo
Query op-dependant file information on FD.
bool IsOK() const
We're fine.
std::string ToString() const
Create a string representation.