Loading...
Searching...
No Matches
XrdOfsChkPnt Class Reference

`#include <XrdOfsChkPnt.hh>`

Inheritance diagram for XrdOfsChkPnt:
Collaboration diagram for XrdOfsChkPnt:

## Public Member Functions

| XrdOfsChkPnt (XrdOssDF &ossfl, const char *lfn, const char *ckpfn=0)
virtual | ~XrdOfsChkPnt ()
int | Create ()
int | Delete ()
void | Finished ()
int | Query (struct iov &range)
int | Restore (bool *readok=0)
int | Truncate (struct iov *&range)
int | Write (struct iov *&range, int rnum)
Public Member Functions inherited from XrdOucChkPnt
| XrdOucChkPnt ()
| Constructor and destructor.
virtual | ~XrdOucChkPnt ()

## Detailed Description

Definition at line 43 of file XrdOfsChkPnt.hh.

## Constructor & Destructor Documentation

## XrdOfsChkPnt()

XrdOfsChkPnt::XrdOfsChkPnt | ( | XrdOssDF & | ossfl,
|  | const char * | lfn,
|  | const char * | ckpfn = 0 )

inline

Constructor and destructor.

Parameters

  ossfl | - reference to the Oss File Object for the source file.
  lfn | - pointer to the source file path.
  ckpfn | - pointer to optional prexisting checkpoint file.

Definition at line 122 of file XrdOfsChkPnt.hh.

: lFN(lfn), cpFile(ckpfn), ossFile(ossfl), fSize(0),
cpUsed(0) {}

## ~XrdOfsChkPnt()

virtual XrdOfsChkPnt::~XrdOfsChkPnt | ( |  | ) |

inline virtual

Definition at line 126 of file XrdOfsChkPnt.hh.

{}

## Member Function Documentation

## Create()

int XrdOfsChkPnt::Create | ( |  | ) |

virtual

Create a checkpoint.

Returns
  0 upon success and -errno upon failure.

Implements XrdOucChkPnt.

Definition at line 81 of file XrdOfsChkPnt.cc.

{
struct stat Stat;
int rc;
// Make sure we don't have a checkpoint outstanding
//
if (cpFile.isActive()) return -EEXIST;
// Get the file size
//
if ((rc = ossFile.Fstat(&Stat))) return rc;
fSize = Stat.st_size;
// Create the actual checkpoint
//
if ((rc = cpFile.Create(lFN, Stat)))
OfsEroute.Emsg("ChkPnt", rc, "create checkpoint for", lFN);
// Return result
//
OfsEroute.Emsg("ChkPnt", cpFile.FName(true), "checkpoint created for", lFN);
return rc;
}
Stat
struct stat Stat
Definition XrdCks.cc:49
OfsEroute
XrdSysError OfsEroute(0)
stat
#define stat(a, b)
Definition XrdPosix.hh:101
XrdSysError::Emsg
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition XrdSysError.cc:95

References OfsEroute, Stat, and stat.

## Delete()

int XrdOfsChkPnt::Delete | ( |  | ) |

virtual

Delete a checkpoint.

Returns
  0 upon success and -errno upon failure.

Implements XrdOucChkPnt.

Definition at line 110 of file XrdOfsChkPnt.cc.

{
int rc = 0;
// Delete the checkpoint file if we have one
//
if (cpFile.isActive() && (rc = cpFile.Destroy()))
OfsEroute.Emsg("ChkPnt", rc, "delete checkpoint", cpFile.FName());
// All done
//
return rc;
}

References OfsEroute.

Referenced by Restore().

Here is the caller graph for this function:

## Finished()

void XrdOfsChkPnt::Finished | ( |  | ) |

inline virtual

Indicate that the checkpointing is finished. Any outstanding checkpoint should be delete and the object should delete itself if necessary.

Implements XrdOucChkPnt.

Definition at line 68 of file XrdOfsChkPnt.hh.

{delete this;}

## Query()

int XrdOfsChkPnt::Query | ( | struct iov & | range | ) |

virtual

Query checkpoint limits.

Parameters

  range | - reference to where limits are placed. range.length - holds maximum checkpoint length allowed.

Returns
  0 upon success and -errno upon failure.

Implements XrdOucChkPnt.

Definition at line 169 of file XrdOfsChkPnt.cc.

{
range.offset = cpUsed;
range.size = XrdOfsConfigCP::MaxSZ;
return 0;
}
XrdOfsConfigCP::MaxSZ
static long long MaxSZ
Definition XrdOfsConfigCP.hh:40
XrdOucIOVec::size
int size
Definition XrdOucIOVec.hh:43
XrdOucIOVec::offset
long long offset
Definition XrdOucIOVec.hh:42

References XrdOfsConfigCP::MaxSZ, XrdOucIOVec::offset, and XrdOucIOVec::size.

## Restore()

int XrdOfsChkPnt::Restore | ( | bool * | readok = 0 | ) |

virtual

Restore a checkpoint.

Parameters

  readok | - When not nil and an error occurs readok is set true if read access is still allowed; otherwise no access should be allowed.

Returns
  0 upon success and -errno upon failure.

Implements XrdOucChkPnt.

Definition at line 180 of file XrdOfsChkPnt.cc.

{
cUp cup;
XrdOfsCPFile::rInfo rinfo;
const char *eWhy = 0;
int rc;
// Make sure we have a checkpoint to restore
//
if (!cpFile.isActive()) return -ENOENT;
// Get the checkpoint information
//
if ((rc = cpFile.RestoreInfo(rinfo, eWhy)))
{if (rc == -ENODATA) {Delete(); return 0;}
XrdOucString eMsg(256);
eMsg = "process chkpnt (";
if (eWhy) eMsg.append(eWhy);
eMsg.append(')');
OfsEroute.Emsg("ChkPnt", rc, eMsg.c_str(), cpFile.FName());
lFN = rinfo.srcLFN;
return Failed(0, rc, readok);
}
// If we don't have a filename then we neeed to open it
//
if (!lFN)
{XrdOucEnv ckpEnv;
lFN = rinfo.srcLFN;
rc = ossFile.Open(lFN, O_RDWR, 0, ckpEnv);
if (rc) return Failed("open", rc, readok);
cup.ossP = &ossFile;
}
// Truncate the file to its original size
//
rc = ossFile.Ftruncate(rinfo.fSize);
if (rc) return Failed("truncate", rc, readok);
// Write back the original contents of the file. It might not have any.
//
if (rinfo.DataVec)
{rc = ossFile.WriteV(rinfo.DataVec, rinfo.DataNum);
if (rc != rinfo.DataLen)
return Failed("write", (rc < 0 ? rc : -EIO), readok);
}
// Sync the data to disk
//
ossFile.Fsync();
// Set file modification time to the original value.
//
struct timeval utArg[2];
utArg[0].tv_sec = utArg[1].tv_sec = rinfo.mTime;
utArg[0].tv_usec = utArg[1].tv_usec = 0;
rc = ossFile.Fctl(XrdOssDF::Fctl_utimes, sizeof(utArg), (const char *)&utArg);
if (rc && rc != -ENOTSUP) OfsEroute.Emsg("ChkPnt", rc, "set mtime for", lFN);
// Now we can delete the checkpoint record
//
if ((rc = Delete()))
{OfsEroute.Emsg("ChkPnt", rc, "delete chkpnt", cpFile.FName());
return Failed(0, rc, readok);
}
// All done
//
OfsEroute.Emsg("ChkPnt", lFN, "successfully restored.");
return 0;
}
ENODATA
#define ENODATA
Definition XrdOfsChkPnt.cc:48
eMsg
#define eMsg(x)
Definition XrdSecsssAdmin.cc:53
XrdOfsCPFile::rInfo::fSize
int64_t fSize
Original size of the source file.
Definition XrdOfsCPFile.hh:127
XrdOfsCPFile::rInfo::srcLFN
const char * srcLFN
Pointer to the source filename.
Definition XrdOfsCPFile.hh:126
XrdOfsCPFile::rInfo::DataVec
XrdOucIOVec * DataVec
A vector of data that must be written back.
Definition XrdOfsCPFile.hh:129
XrdOfsCPFile::rInfo::DataLen
int DataLen
Number of bytes to write back (may be 0).
Definition XrdOfsCPFile.hh:131
XrdOfsCPFile::rInfo::DataNum
int DataNum
Number of elements in DataVec (may be 0).
Definition XrdOfsCPFile.hh:130
XrdOfsCPFile::rInfo::mTime
time_t mTime
Original modification time of the source.
Definition XrdOfsCPFile.hh:128
XrdOfsChkPnt::Delete
int Delete()
Definition XrdOfsChkPnt.cc:110
XrdOssDF::Fctl_utimes
static const int Fctl_utimes
Definition XrdOss.hh:416

References XrdOfsCPFile::rInfo::DataLen, XrdOfsCPFile::rInfo::DataNum, XrdOfsCPFile::rInfo::DataVec, Delete(), eMsg, ENODATA, XrdOssDF::Fctl_utimes, XrdOfsCPFile::rInfo::fSize, XrdOfsCPFile::rInfo::mTime, OfsEroute, and XrdOfsCPFile::rInfo::srcLFN.

Here is the call graph for this function:

## Truncate()

int XrdOfsChkPnt::Truncate | ( | struct iov *& | range | ) |

virtual

Truncate a file to a specific size.

Parameters

  range | - reference to the file truncate size in offset.

Returns
  0 upon success and -errno upon failure.

Implements XrdOucChkPnt.

Definition at line 257 of file XrdOfsChkPnt.cc.

{
cUp cup;
int rc, dlen;
// Make sure we have a checkpoint active
//
if (!cpFile.isActive()) return -ENOENT;
// Make sure offset is not negative
//
if (range[0].offset < 0) return -EINVAL;
// Check if we really need to do something here
//
if (range[0].offset >= fSize) return 0;
// Compute size to save and whether we will exceed our quota
//
dlen = fSize - range[0].offset;
if (dlen + cpUsed > XrdOfsConfigCP::MaxSZ) return -EDQUOT;
// Reserve space for all this data
//
if (!cpFile.Reserve(dlen, 1)) return -ENOSPC;
cpUsed += dlen;
// Allocate a buffer to read in the data
//
if (!(cup.buff = (char *)malloc(dlen))) return -ENOMEM;
// Perform checkpoint
//
rc = ossFile.Read(cup.buff, range[0].offset, dlen);
if (rc < 0 || (rc && (rc = cpFile.Append(cup.buff, range[0].offset, rc))))
return rc;
// Set new file size as it s now smaller
//
// Make sure all of it gets on media
//
if (!(rc = cpFile.Sync())) fSize = range[0].offset;
return rc;
}

References XrdOfsConfigCP::MaxSZ, and XrdOucIOVec::offset.

## Write()

int XrdOfsChkPnt::Write | ( | struct iov *& | range,
|  | int | rnum )

virtual

Write data to a checkpointed file.

Parameters

  range | - reference to the file pieces to write.
  rnum | - number of elements in "range".

Returns
  0 upon success and -errno upon failure.

Implements XrdOucChkPnt.

Definition at line 307 of file XrdOfsChkPnt.cc.

{
cUp cup;
int rc, dlen = 0, buffSZ = 0, numVS = 0;
// Make sure we have a checkpoint active
//
if (!cpFile.isActive()) return -ENOENT;
// Run through the write vector computing what to checkpoint
//
for (int i = 0; i < rnum; i++)
{if (range[i].offset < 0) return -EINVAL;
if (range[i].offset < fSize && range[i].size)
{if (range[i].size + range[i].offset < fSize) dlen = range[i].size;
else dlen = fSize - range[i].offset;
if (dlen > XrdOfsConfigCP::MaxSZ) return -EDQUOT;
if (dlen > buffSZ) buffSZ = dlen;
range[i].info = dlen; numVS++;
} else range[i].info = 0;
}
// If nothing to checkpoint, simply return
//
if (!buffSZ) return 0;
// Check if we will exceed our quota with this checkpoint
//
if (dlen + cpUsed > XrdOfsConfigCP::MaxSZ) return -EDQUOT;
// Allocate a buffer to read in the data
//
if (!(cup.buff = (char *)malloc(buffSZ))) return -ENOMEM;
// Reserve space for all this data
//
if (!cpFile.Reserve(dlen, numVS)) return -ENOSPC;
cpUsed += dlen;
// Perform checkpoint
//
for (int i = 0; i < rnum; i++)
{if (range[i].info)
{rc = ossFile.Read(cup.buff, range[i].offset, range[i].info);
if (rc < 0
|| (rc && (rc = cpFile.Append(cup.buff, range[i].offset, rc))))
return rc;
}
}
// Make sure all of it gets on media
//
return cpFile.Sync();
}
XrdOucIOVec::info
int info
Definition XrdOucIOVec.hh:44

References XrdOucIOVec::info, XrdOfsConfigCP::MaxSZ, XrdOucIOVec::offset, and XrdOucIOVec::size.

The documentation for this class was generated from the following files:

- XrdOfsChkPnt.hh
- XrdOfsChkPnt.cc