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