XRootD
XrdPosixFile.cc
Go to the documentation of this file.
1 /******************************************************************************/
2 /* */
3 /* X r d P o s i x F i l e . c c */
4 /* */
5 /* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */
6 /* All Rights Reserved */
7 /* Produced by Andrew Hanushevsky for Stanford University under contract */
8 /* DE-AC02-76-SFO0515 with the Department of Energy */
9 /* */
10 /* This file is part of the XRootD software suite. */
11 /* */
12 /* XRootD is free software: you can redistribute it and/or modify it under */
13 /* the terms of the GNU Lesser General Public License as published by the */
14 /* Free Software Foundation, either version 3 of the License, or (at your */
15 /* option) any later version. */
16 /* */
17 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20 /* License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25 /* */
26 /* The copyright holder's institutional names and contributor's names may not */
27 /* be used to endorse or promote products derived from this software without */
28 /* specific prior written permission of the institution or contributor. */
29 /******************************************************************************/
30 
31 #include <cerrno>
32 #include <fcntl.h>
33 #include <cstdio>
34 #include <sys/time.h>
35 #include <sys/param.h>
36 #include <sys/resource.h>
37 #include <sys/uio.h>
38 #include <sys/stat.h>
39 
43 #include "XrdPosix/XrdPosixFile.hh"
49 
50 #include "XrdSys/XrdSysError.hh"
51 #include "XrdSys/XrdSysPageSize.hh"
52 #include "XrdSys/XrdSysTimer.hh"
53 
54 /******************************************************************************/
55 /* S t a t i c M e m b e r s */
56 /******************************************************************************/
57 
58 namespace XrdPosixGlobals
59 {
60 extern XrdOucCache *theCache;
64 extern int ddInterval;
65 extern int ddMaxTries;
66 extern bool autoPGRD;
67 };
68 
69 namespace
70 {
71 XrdPosixFile *InitDDL()
72 {
73 pthread_t tid;
74 XrdSysThread::Run(&tid, XrdPosixFile::DelayedDestroy, 0, 0, "PosixFileDestroy");
75 return (XrdPosixFile *)0;
76 }
77 
78 std::string dsProperty("DataServer");
79 };
80 
85 
86 char *XrdPosixFile::sfSFX = 0;
87 short XrdPosixFile::sfSLN = 0;
88 bool XrdPosixFile::ddPosted = false;
89 int XrdPosixFile::ddNum = 0;
90 
91 /******************************************************************************/
92 /* L o c a l C l a s s e s */
93 /******************************************************************************/
94 
95 namespace
96 {
97 class pgioCB : public XrdOucCacheIOCB
98 {
99 public:
100 
101 void Done(int result)
102  {rc = result; pgSem.Post();}
103 
104 int Wait4PGIO() {pgSem.Wait(); return rc;}
105 
106  pgioCB(const char *who) : pgSem(0, who), rc(0) {}
107  ~pgioCB() {}
108 
109 private:
110 
111 XrdSysSemaphore pgSem;
112 int rc;
113 };
114 }
115 
116 /******************************************************************************/
117 /* C o n s t r u c t o r */
118 /******************************************************************************/
119 
120 XrdPosixFile::XrdPosixFile(bool &aOK, const char *path, XrdPosixCallBack *cbP,
121  int Opts)
122  : XCio((XrdOucCacheIO *)this), PrepIO(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)
126 {
127 // Handle path generation. This is trickt as we may have two namespaces. One
128 // for the origin and one for the cache.
129 //
130  fOpen = strdup(path); aOK = true;
131  if (!XrdPosixGlobals::theN2N || !XrdPosixGlobals::theCache) fPath = fOpen;
132  else if (!XrdPosixXrootPath::P2L("file",path,fPath)) aOK = false;
133  else if (!fPath) fPath = fOpen;
134 
135 // Check for structured file check
136 //
137  if (sfSFX)
138  {int n = strlen(path);
139  if (n > sfSLN && !strcmp(sfSFX, path + n - sfSLN))
140  cOpt = XrdOucCache::optFIS;
141  }
142 
143 // Set cache update option
144 //
145  if (Opts & isUpdt) cOpt |= XrdOucCache::optRW;
146 }
147 
148 /******************************************************************************/
149 /* D e s t r u c t o r */
150 /******************************************************************************/
151 
153 {
154 // Close the remote connection
155 //
156  if (clFile.IsOpen())
158  XrdCl::XRootDStatus status = clFile.Close();
159  if (!status.IsOK())
161  }
162 
163 // Get rid of deferred open object
164 //
165  if (PrepIO) delete PrepIO;
166 
167 // Free the path and location information
168 //
169  if (fPath) free(fPath);
170  if (fOpen != fPath) free(fOpen);
171  if (fLoc) free(fLoc);
172 }
173 
174 /******************************************************************************/
175 /* D e l a y e d D e s t r o y */
176 /******************************************************************************/
177 
179 {
180 // Static function.
181 // Called within a dedicated thread if there is a reference outstanding to the
182 // file or the file cannot be closed in a clean fashion for some reason.
183 //
184  EPNAME("DDestroy");
185 
187  XrdCl::XRootDStatus Status;
188  std::string statusMsg;
189  const char *eTxt;
190  XrdPosixFile *fCurr, *fNext;
191  char buff[512], buff2[256];
192  static int ddNumLost = 0;
193  int ddCount, refNum;
194  bool doWait = false;
195 
196 // Wait for active I/O to complete
197 //
198 do{if (doWait)
200  doWait = false;
201  } else {
202  ddSem.Wait();
203  doWait = true;
204  continue;
205  }
206 
207 // Grab the delayed delete list
208 //
209  ddMutex.Lock();
210  fNext=ddList; ddList=0; ddPosted=false; ddCount = ddNum; ddNum = 0;
211  ddMutex.UnLock();
212 
213 // Do some debugging
214 //
215  DEBUG("DLY destroy of "<<ddCount<<" objects; "<<ddNumLost <<" already lost.");
216 
217 // Try to delete all the files on the list. If we exceeded the try limit,
218 // remove the file from the list and let it sit forever.
219 //
220  int nowLost = ddNumLost;
221  while((fCurr = fNext))
222  {fNext = fCurr->nextFile;
223  if (!(refNum = fCurr->Refs()))
224  {if (fCurr->Close(Status) || !fCurr->clFile.IsOpen())
225  {delete fCurr; ddCount--; continue;}
226  else {statusMsg = Status.ToString();
227  eTxt = statusMsg.c_str();
228  }
229  } else eTxt = 0;
230 
231  if (fCurr->numTries > XrdPosixGlobals::ddMaxTries)
232  {ddNumLost++; ddCount--;
233  if (!eTxt)
234  {snprintf(buff2, sizeof(buff2), "in use %d", refNum);
235  eTxt = buff2;
236  }
237  if (Say)
238  {snprintf(buff, sizeof(buff), "%s timeout closing", eTxt);
239  Say->Emsg("DDestroy", buff, fCurr->Origin());
240  } else {
241  DMSG("DDestroy", eTxt <<" timeout closing " <<fCurr->Origin()
242  <<' ' <<ddNumLost <<" objects lost");
243  }
244  fCurr->nextFile = ddLost;
245  ddLost = fCurr;
246  } else {
247  fCurr->numTries++;
248  doWait = true;
249  ddMutex.Lock();
250  fCurr->nextFile = ddList; ddList = fCurr;
251  ddNum++; ddPosted = true;
252  ddMutex.UnLock();
253  }
254  }
255  if (Say && ddNumLost - nowLost >= 3)
256  {snprintf(buff, sizeof(buff), "%d objects deferred and %d lost.",
257  ddCount, ddNumLost);
258  Say->Emsg("DDestroy", buff);
259  } else {
260  DEBUG("DLY destroy end; "<<ddCount<<" objects deferred and "
261  <<ddNumLost <<" lost.");
262  }
263  if (XrdPosixGlobals::theCache && ddNumLost != nowLost)
265  (XrdPosixGlobals::theCache->Statistics.X.ClosedLost), ddNumLost);
266  } while(true);
267 
268  return 0;
269 }
270 
271 /******************************************************************************/
272 
274 {
275  EPNAME("DDestroyFP");
276  int ddCount;
277  bool doPost;
278 
279 // Count number of times this has happened (we should have a cache)
280 //
283  (XrdPosixGlobals::theCache->Statistics.X.ClosDefers));
284 
285 // Place this file on the delayed delete list
286 //
287  ddMutex.Lock();
288  fp->nextFile = ddList;
289  ddList = fp;
290  ddNum++; ddCount = ddNum;
291  if (ddPosted) doPost = false;
292  else {doPost = true;
293  ddPosted = true;
294  }
295  fp->numTries = 0;
296  ddMutex.UnLock();
297 
298  DEBUG("DLY destroy "<<(doPost ? "post " : "has ")<<ddCount
299  <<" objects; added "<<fp->Origin());
300 
301  if (doPost) ddSem.Post();
302 }
303 
304 /******************************************************************************/
305 /* C l o s e */
306 /******************************************************************************/
307 
309 {
310 // If this is a deferred open, disable any future calls as we are ready to
311 // shutdown this beast!
312 //
313  if (PrepIO) PrepIO->Disable();
314 
315 // If we don't need to close the file, then return success. Otherwise, do the
316 // actual close and return the status. We should have already been removed
317 // from the file table at this point and should be unlocked.
318 //
319  if (clFile.IsOpen())
321  Status = clFile.Close();
322  if (Status.IsOK()) return true;
324  return false;
325  }
326  return true;
327 }
328 
329 /******************************************************************************/
330 /* F i n a l i z e */
331 /******************************************************************************/
332 
334 {
335  XrdOucCacheIO *ioP;
336 
337 // Indicate that we are at the start of the file
338 //
339  currOffset = 0;
340 
341 // Complete initialization. If the stat() fails, the caller will unwind the
342 // whole open process (ick). In the process get correct I/O vector.
343 
344  if (!Status) ioP = (XrdOucCacheIO *)PrepIO;
345  else if (Stat(*Status)) ioP = (XrdOucCacheIO *)this;
346  else return false;
347 
348 // Setup the cache if it is to be used
349 //
351  {XCio = XrdPosixGlobals::theCache->Attach(ioP, cOpt);
352  if (ioP == (XrdOucCacheIO *)PrepIO)
353  XrdPosixGlobals::theCache->Statistics.Add(
355  }
356 
357  return true;
358 }
359 
360 /******************************************************************************/
361 /* F s t a t */
362 /******************************************************************************/
363 
364 int XrdPosixFile::Fstat(struct stat &buf)
365 {
366  long long theSize;
367 
368 // The size is treated differently here as it may come from a cache and may
369 // actually trigger a file open if the open was deferred.
370 //
371  theSize = XCio->FSize();
372  if (theSize < 0) return static_cast<int>(theSize);
373 
374 // Return what little we can
375 //
377  buf.st_size = theSize;
378  buf.st_atime = myAtime;
379  buf.st_ctime = myCtime;
380  buf.st_mtime = myMtime;
381  buf.st_blocks = buf.st_size/512 + buf.st_size%512;
382  buf.st_ino = myInode;
383  buf.st_rdev = myRdev;
384  buf.st_mode = myMode;
385  return 0;
386 }
387 
388 /******************************************************************************/
389 /* H a n d l e R e s p o n s e */
390 /******************************************************************************/
391 
392 // Note: This response handler is only used for async open requests!
393 
395  XrdCl::AnyObject *response)
396 {
397  XrdCl::XRootDStatus Status;
398  XrdPosixCallBack *xeqCB = theCB;
399  int rc = fdNum;
400 
401 // If no errors occurred, complete the open
402 //
403  if (!(status->IsOK())) rc = XrdPosixMap::Result(*status,ecMsg,false);
404  else if (!Finalize(&Status)) rc = XrdPosixMap::Result( Status,ecMsg,false);
405 
406 // Issue XrdPosixCallBack callback with the correct result. Errors are indicated
407 // by result set < 0 (typically -1) and errno set to the error number. In our
408 // case, rc is -errno if an error occured and that is what the callback gets.
409 //
410  xeqCB->Complete(rc);
411 
412 // Finish up
413 //
414  delete status;
415  delete response;
416  if (rc < 0) delete this;
417 }
418 
419 /******************************************************************************/
420 /* L o c a t i o n */
421 /******************************************************************************/
422 
423 const char *XrdPosixFile::Location(bool refresh)
424 {
425 
426 // If the file is not open, then we have no location
427 //
428  if (!clFile.IsOpen()) return "";
429 
430 // If we have no location info, get it
431 //
432  if (!fLoc || refresh)
433  {std::string currNode;
434  if (clFile.GetProperty(dsProperty, currNode))
435  {if (!fLoc || strcmp(fLoc, currNode.c_str()))
436  {if (fLoc) free(fLoc);
437  fLoc = strdup(currNode.c_str());
438  }
439  } else return "";
440  }
441 
442 // Return location information
443 //
444  return fLoc;
445 }
446 
447 /******************************************************************************/
448 /* p g R e a d */
449 /******************************************************************************/
450 
451 int XrdPosixFile::pgRead(char *buff,
452  long long offs,
453  int rlen,
454  std::vector<uint32_t> &csvec,
455  uint64_t opts,
456  int *csfix)
457 {
458 // Do a sync call using the async interface
459 //
460  pgioCB pgrCB("Posix pgRead CB");
461  pgRead(pgrCB, buff, offs, rlen, csvec, opts, csfix);
462  return pgrCB.Wait4PGIO();
463 }
464 
465 /******************************************************************************/
466 
468  char *buff,
469  long long offs,
470  int rlen,
471  std::vector<uint32_t> &csvec,
472  uint64_t opts,
473  int *csfix)
474 {
475  XrdCl::XRootDStatus Status;
476  XrdPosixFileRH *rhP;
477 
478 // Allocate callback object. Note the response handler may do additional post
479 // processing.
480 //
481  rhP = XrdPosixFileRH::Alloc(&iocb, this, offs, rlen, XrdPosixFileRH::isReadP);
482 
483 // Set the destination checksum vector
484 //
485  if (csfix) *csfix = 0;
486  rhP->setCSVec(&csvec, csfix, (opts & XrdOucCacheIO::forceCS) != 0);
487 
488 // Issue read
489 //
490  Ref();
491  Status = clFile.PgRead((uint64_t)offs,(uint32_t)rlen,buff,rhP);
492 
493 // Check status, upon error we pass -errno as the result.
494 //
495  if (!Status.IsOK())
496  {rhP->Sched(XrdPosixMap::Result(Status, ecMsg, false));
497  unRef();
498  }
499 }
500 
501 /******************************************************************************/
502 /* p g W r i t e */
503 /******************************************************************************/
504 
505 int XrdPosixFile::pgWrite(char *buff,
506  long long offs,
507  int wlen,
508  std::vector<uint32_t> &csvec,
509  uint64_t opts,
510  int *csfix)
511 {
512  XrdCl::XRootDStatus Status;
513 
514 // Preset checksum error count
515 //
516  if (csfix) *csfix = 0;
517 
518 // Issue write and return appropriately. An error returns -1.
519 //
520  Ref();
521  Status = clFile.PgWrite((uint64_t)offs, (uint32_t)wlen, buff, csvec);
522  unRef();
523 
524  return (Status.IsOK() ? wlen : XrdPosixMap::Result(Status,ecMsg,true));
525 }
526 
527 /******************************************************************************/
528 
530  char *buff,
531  long long offs,
532  int wlen,
533  std::vector<uint32_t> &csvec,
534  uint64_t opts,
535  int *csfix)
536 {
537  XrdCl::XRootDStatus Status;
538  XrdPosixFileRH *rhP;
539 
540 // Allocate callback object. Note that a pgWrite is essentially a normal write
541 // as far as the response handler is concerned.
542 //
543  rhP = XrdPosixFileRH::Alloc(&iocb,this,offs,wlen,XrdPosixFileRH::isWrite);
544 
545 // Set checksum info
546 //
547  if (csfix)
548  {*csfix = 0;
549  rhP->setCSVec(0, csfix);
550  }
551 
552 // Issue write
553 //
554  Ref();
555  Status = clFile.PgWrite((uint64_t)offs, (uint32_t)wlen, buff, csvec, rhP);
556 
557 // Check status, if error pass along -errno as the result.
558 //
559  if (!Status.IsOK())
560  {rhP->Sched(XrdPosixMap::Result(Status,ecMsg,false));
561  unRef();
562  }
563 }
564 
565 /******************************************************************************/
566 /* R e a d */
567 /******************************************************************************/
568 
569 int XrdPosixFile::Read (char *Buff, long long Offs, int Len)
570 {
571  XrdCl::XRootDStatus Status;
572  uint32_t bytes;
573 
574 // Handle automatic pgread
575 //
577  {pgioCB pgrCB("Posix pgRead CB");
578  Read(pgrCB, Buff, Offs, Len);
579  return pgrCB.Wait4PGIO();
580  }
581 
582 // Issue read and return appropriately.
583 //
584  Ref();
585  Status = clFile.Read((uint64_t)Offs, (uint32_t)Len, Buff, bytes);
586  unRef();
587 
588  return (Status.IsOK() ? (int)bytes : XrdPosixMap::Result(Status,ecMsg,false));
589 }
590 
591 /******************************************************************************/
592 
593 void XrdPosixFile::Read (XrdOucCacheIOCB &iocb, char *buff, long long offs,
594  int rlen)
595 {
596  XrdCl::XRootDStatus Status;
597  XrdPosixFileRH *rhP;
599  bool doPgRd = XrdPosixGlobals::autoPGRD;
600 
601 // Allocate correct callback object
602 //
604  rhP = XrdPosixFileRH::Alloc(&iocb, this, offs, rlen, rhT);
605 
606 // Issue read
607 //
608  Ref();
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);
611 
612 // Check status. Upon error pass along -errno as the result.
613 //
614  if (!Status.IsOK())
615  {rhP->Sched(XrdPosixMap::Result(Status, ecMsg, false));
616  unRef();
617  }
618 }
619 
620 /******************************************************************************/
621 /* R e a d V */
622 /******************************************************************************/
623 
624 int XrdPosixFile::ReadV (const XrdOucIOVec *readV, int n)
625 {
626  XrdCl::XRootDStatus Status;
627  XrdCl::ChunkList chunkVec;
628  XrdCl::VectorReadInfo *vrInfo = 0;
629  int nbytes = 0;
630 
631 // Copy in the vector (would be nice if we didn't need to do this)
632 //
633  chunkVec.reserve(n);
634  for (int i = 0; i < n; i++)
635  {nbytes += readV[i].size;
636  chunkVec.push_back(XrdCl::ChunkInfo((uint64_t)readV[i].offset,
637  (uint32_t)readV[i].size,
638  (void *)readV[i].data
639  ));
640  }
641 
642 // Issue the readv. We immediately delete the vrInfo as w don't need it as a
643 // readv will succeed only if actually read the number of bytes requested.
644 //
645  Ref();
646  Status = clFile.VectorRead(chunkVec, (void *)0, vrInfo);
647  unRef();
648  delete vrInfo;
649 
650 // Return appropriate result (here we return -errno as the result)
651 //
652  return (Status.IsOK() ? nbytes : XrdPosixMap::Result(Status, ecMsg, false));
653 }
654 
655 /******************************************************************************/
656 
657 void XrdPosixFile::ReadV(XrdOucCacheIOCB &iocb, const XrdOucIOVec *readV, int n)
658 {
659  XrdCl::XRootDStatus Status;
660  XrdCl::ChunkList chunkVec;
661  int nbytes = 0;
662 
663 // Copy in the vector (would be nice if we didn't need to do this)
664 //
665  chunkVec.reserve(n);
666  for (int i = 0; i < n; i++)
667  {nbytes += readV[i].size;
668  chunkVec.push_back(XrdCl::ChunkInfo((uint64_t)readV[i].offset,
669  (uint32_t)readV[i].size,
670  (void *)readV[i].data
671  ));
672  }
673 
674 // Issue the readv.
675 //
676  XrdPosixFileRH *rhp = XrdPosixFileRH::Alloc(&iocb, this, 0, nbytes,
678  Ref();
679  Status = clFile.VectorRead(chunkVec, (void *)0, rhp);
680 
681 // Return appropriate result
682 //
683  if (!Status.IsOK())
684  {rhp->Sched(XrdPosixMap::Result(Status, ecMsg, false));
685  unRef();
686  }
687 }
688 
689 /******************************************************************************/
690 /* S t a t */
691 /******************************************************************************/
692 
693 bool XrdPosixFile::Stat(XrdCl::XRootDStatus &Status, bool force)
694 {
695  XrdCl::StatInfo *sInfo = 0;
696 
697 // Get the stat information from the open file
698 //
699  Ref();
700  Status = clFile.Stat(force, sInfo);
701  if (!Status.IsOK())
702  {unRef();
703  delete sInfo;
704  return false;
705  }
706 
707 // Copy over the relevant fields, the stat structure must have been
708 // properly pre-initialized.
709 //
711  myMtime = static_cast<time_t>(sInfo->GetModTime());
712  mySize = static_cast<size_t>(sInfo->GetSize());
713  myInode = static_cast<ino_t>(strtoll(sInfo->GetId().c_str(), 0, 10));
714 
715 // If this is an extended stat then we can get some more info
716 //
717  if (sInfo->ExtendedFormat())
718  {myCtime = static_cast<time_t>(sInfo->GetChangeTime());
719  myAtime = static_cast<time_t>(sInfo->GetAccessTime());
720  } else {
721  myCtime = myMtime;
722  myAtime = time(0);
723  }
724 
725 // Delete our status information and return final result
726 //
727  unRef();
728  delete sInfo;
729  return true;
730 }
731 
732 /******************************************************************************/
733 /* S y n c */
734 /******************************************************************************/
735 
737 {
738  XrdCl::XRootDStatus Status;
739 
740 // Issue the Sync
741 //
742  Ref();
743  Status = clFile.Sync();
744  unRef();
745 
746 // Return result
747 //
748  return XrdPosixMap::Result(Status, ecMsg, false);
749 }
750 
751 /******************************************************************************/
752 
754 {
755  XrdCl::XRootDStatus Status;
756  XrdPosixFileRH *rhp = XrdPosixFileRH::Alloc(&iocb, this, 0, 0,
758 
759 // Issue read
760 //
761  Status = clFile.Sync(rhp);
762 
763 // Check status
764 //
765  if (!Status.IsOK()) rhp->Sched(XrdPosixMap::Result(Status, ecMsg, false));
766 }
767 
768 /******************************************************************************/
769 /* T r u n c */
770 /******************************************************************************/
771 
772 int XrdPosixFile::Trunc(long long Offset)
773 {
774  XrdCl::XRootDStatus Status;
775 
776 // Issue truncate request
777 //
778  Ref();
779  Status = clFile.Truncate((uint64_t)Offset);
780  unRef();
781 
782 // Return results
783 //
784  return XrdPosixMap::Result(Status,ecMsg,false);
785 }
786 
787 /******************************************************************************/
788 /* W r i t e */
789 /******************************************************************************/
790 
791 int XrdPosixFile::Write(char *Buff, long long Offs, int Len)
792 {
793  XrdCl::XRootDStatus Status;
794 
795 // Issue write and return appropriately
796 //
797  Ref();
798  Status = clFile.Write((uint64_t)Offs, (uint32_t)Len, Buff);
799  unRef();
800 
801  return (Status.IsOK() ? Len : XrdPosixMap::Result(Status,ecMsg,false));
802 }
803 
804 /******************************************************************************/
805 
806 void XrdPosixFile::Write(XrdOucCacheIOCB &iocb, char *buff, long long offs,
807  int wlen)
808 {
809  XrdCl::XRootDStatus Status;
810  XrdPosixFileRH *rhp = XrdPosixFileRH::Alloc(&iocb, this, offs, wlen,
812 
813 // Issue write
814 //
815  Ref();
816  Status = clFile.Write((uint64_t)offs, (uint32_t)wlen, buff, rhp);
817 
818 // Check status
819 //
820  if (!Status.IsOK())
821  {rhp->Sched(XrdPosixMap::Result(Status,ecMsg,false));
822  unRef();
823  }
824 }
#define DEBUG(x)
Definition: XrdBwmTrace.hh:54
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
int stat(const char *path, struct stat *buf)
#define DMSG(x, y)
struct myOpts opts
XRootDStatus Read(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Definition: XrdClFile.cc:206
XRootDStatus Close(ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Definition: XrdClFile.cc:151
bool IsOpen() const
Check if the file is open.
Definition: XrdClFile.cc:846
XRootDStatus Truncate(uint64_t size, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Definition: XrdClFile.cc:440
XRootDStatus VectorRead(const ChunkList &chunks, void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Definition: XrdClFile.cc:468
bool GetProperty(const std::string &name, std::string &value) const
Definition: XrdClFile.cc:878
XRootDStatus Write(uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Definition: XrdClFile.cc:286
XRootDStatus PgRead(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Definition: XrdClFile.cc:245
XRootDStatus Stat(bool force, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Definition: XrdClFile.cc:177
XRootDStatus Sync(ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Definition: XrdClFile.cc:414
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
Definition: XrdClFile.cc:380
Object stat info.
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
Definition: XrdOucCache.hh:188
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)
Definition: XrdOucCache.hh:517
virtual XrdOucCacheIO * Attach(XrdOucCacheIO *ioP, int opts=0)=0
XrdOucCacheStats Statistics
Definition: XrdOucCache.hh:686
static const int optFIS
File is structured (e.g. root file)
Definition: XrdOucCache.hh:516
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)
void Sched(int result)
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
static char * sfSFX
int Write(char *Buff, long long Offs, int Len) override
static const int isUpdt
int Sync() override
static XrdPosixFile * ddLost
XrdPosixPrepIO * PrepIO
Definition: XrdPosixFile.hh:66
int Read(char *Buff, long long Offs, int Len) override
static bool ddPosted
int Fstat(struct stat &buf) override
static int ddNum
const char * Origin()
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 short sfSLN
XrdCl::File clFile
Definition: XrdPosixFile.hh:67
XrdOucCacheIO * XCio
Definition: XrdPosixFile.hh:65
static XrdPosixFile * ddList
long long Offset()
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)
Definition: XrdPosixMap.cc:62
static int Result(const XrdCl::XRootDStatus &Status, XrdOucECMsg &ecMsg, bool retneg1=false)
Definition: XrdPosixMap.cc:150
XrdOucECMsg ecMsg
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)
Definition: XrdSysError.cc:95
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
static void Snooze(int seconds)
Definition: XrdSysTimer.cc:168
std::vector< ChunkInfo > ChunkList
List of chunks.
XrdSysError Say
int Opts
Definition: XrdMpxStats.cc:58
XrdPosixStats Stats
Definition: XrdPosixFile.cc:63
XrdSysError * eDest
Definition: XrdPosixFile.cc:62
XrdOucCache * theCache
XrdOucName2Name * theN2N
Definition: XrdPosixFile.cc:61
Describe a data chunk for vector read.
bool IsOK() const
We're fine.
Definition: XrdClStatus.hh:124
std::string ToString() const
Create a string representation.
Definition: XrdClStatus.cc:97