Loading...
Searching...
No Matches
XrdPfc::File Class Reference

`#include <XrdPfcFile.hh>`

Collaboration diagram for XrdPfc::File:

## Public Member Functions

void | AddIO (IO *io)
void | BlockRemovedFromWriteQ (Block *)
| Handle removal of a block from Cache's write queue.
void | BlocksRemovedFromWriteQ (std::list< Block * > &)
| Handle removal of a set of blocks from Cache's write queue.
int | dec_ref_cnt ()
bool | FinalizeSyncBeforeExit ()
| Returns true if any of blocks need sync. Called from Cache::dec_ref_cnt on zero ref cnt.
int | Fstat (struct stat &sbuff)
int | get_ref_cnt ()
size_t | GetAccessCnt () const
int | GetBlockSize () const
long long | GetFileSize () const
const Info::AStat * | GetLastAccessStats () const
const std::string & | GetLocalPath () const
XrdSysError * | GetLog () const
int | GetNBlocks () const
int | GetNDownloadedBlocks () const
int | GetPrefetchCountOnIO (IO *io)
long long | GetPrefetchedBytes () const
float | GetPrefetchScore () const
std::string | GetRemoteLocations () const
XrdSysTrace * | GetTrace () const
int | inc_ref_cnt ()
long long | initiate_emergency_shutdown ()
bool | ioActive (IO *io)
| Initiate close. Return true if still IO active. Used in XrdPosixXrootd::Close().
void | ioUpdated (IO *io)
| Notification from IO that it has been updated (remote open).
bool | is_in_emergency_shutdown ()
const char * | lPath () const
| Log path.
void | Prefetch ()
int | Read (IO *io, char *buff, long long offset, int size, ReadReqRH *rh)
| Normal read.
int | ReadV (IO *io, const XrdOucIOVec *readV, int readVnum, ReadReqRH *rh)
| Vector read.
const Stats & | RefStats () const
void | RemoveIO (IO *io)
void | RequestSyncOfDetachStats ()
| Flags that detach stats should be written out in final sync. Called from CacheIO upon Detach.
void | StopPrefetchingOnIO (IO *io)
void | Sync ()
| Sync file cache inf o and output data with disk.
void | WriteBlockToDisk (Block *b)

## Static Public Member Functions

static File * | FileOpen (const std::string &path, long long offset, long long fileSize, XrdOucCacheIO *inputIO)
| Static constructor that also does Open. Returns null ptr if Open fails.

## Friends

class | BlockResponseHandler
class | Cache
class | DirectResponseHandler

## Detailed Description

Definition at line 202 of file XrdPfcFile.hh.

## Member Function Documentation

## AddIO()

void File::AddIO | ( | IO * | io | ) |

Definition at line 349 of file XrdPfcFile.cc.

{
// Called from Cache::GetFile() when a new IO asks for the file.
TRACEF(Debug, "AddIO() io = " << (void*)io);
time_t now = time(0);
std::string loc(io->GetLocation());
m_state_cond.Lock();
IoSet_i mi = m_io_set.find(io);
if (mi == m_io_set.end())
{
m_io_set.insert(io);
io->m_attach_time = now;
m_delta_stats.IoAttach();
insert_remote_location(loc);
if (m_prefetch_state == kStopped)
{
m_prefetch_state = kOn;
cache()->RegisterPrefetchFile(this);
}
}
else
{
TRACEF(Error, "AddIO() io = " << (void*)io << " already registered.");
}
m_state_cond.UnLock();
}
TRACEF
#define TRACEF(act, x)
Definition XrdPfcTrace.hh:67
Debug
bool Debug
Definition XrdSecgsiProxy.cc:95
Error
@ Error
Definition XrdTlsNotaryUtils.hh:42
XrdPfc::IO::GetLocation
const char * GetLocation()
Definition XrdPfcIO.hh:44

References Debug, Error, XrdPfc::IO::GetLocation(), and TRACEF.

Referenced by XrdPfc::Cache::GetFile().

Here is the call graph for this function:
Here is the caller graph for this function:

## BlockRemovedFromWriteQ()

void File::BlockRemovedFromWriteQ | ( | Block * | b | ) |

Handle removal of a block from Cache's write queue.

Definition at line 211 of file XrdPfcFile.cc.

{
TRACEF(Dump, "BlockRemovedFromWriteQ() block = " << (void*) b << " idx= " << b->m_offset/m_block_size);
XrdSysCondVarHelper _lck(m_state_cond);
dec_ref_count(b);
}
XrdPfc::Block::m_offset
long long m_offset
Definition XrdPfcFile.hh:114

References XrdPfc::Block::m_offset, and TRACEF.

## BlocksRemovedFromWriteQ()

void File::BlocksRemovedFromWriteQ | ( | std::list< Block * > & | blocks | ) |

Handle removal of a set of blocks from Cache's write queue.

Definition at line 219 of file XrdPfcFile.cc.

{
TRACEF(Dump, "BlocksRemovedFromWriteQ() n_blocks = " << blocks.size());
XrdSysCondVarHelper _lck(m_state_cond);
for (std::list<Block*>::iterator i = blocks.begin(); i != blocks.end(); ++i)
{
dec_ref_count(*i);
}
}

References TRACEF.

Referenced by XrdPfc::Cache::RemoveWriteQEntriesFor().

Here is the caller graph for this function:

## dec_ref_cnt()

int XrdPfc::File::dec_ref_cnt | ( |  | ) |

inline

Definition at line 288 of file XrdPfcFile.hh.

{ return --m_ref_cnt; }

## FileOpen()

File * File::FileOpen | ( | const std::string & | path,
|  | long long | offset,
|  | long long | fileSize,
|  | XrdOucCacheIO * | inputIO )

static

Static constructor that also does Open. Returns null ptr if Open fails.

Definition at line 141 of file XrdPfcFile.cc.

{
File *file = new File(path, offset, fileSize);
if ( ! file->Open(inputIO))
{
delete file;
file = 0;
}
return file;
}
File
XrdOucString File
Definition XrdSecpwdSrvAdmin.cc:159

References File.

Referenced by XrdPfc::Cache::GetFile().

Here is the caller graph for this function:

## FinalizeSyncBeforeExit()

bool File::FinalizeSyncBeforeExit | ( |  | ) |

Returns true if any of blocks need sync. Called from Cache::dec_ref_cnt on zero ref cnt.

Definition at line 325 of file XrdPfcFile.cc.

{
// Returns true if sync is required.
// This method is called after corresponding IO is detached from PosixCache.
XrdSysCondVarHelper _lck(m_state_cond);
if ( ! m_in_shutdown)
{
if ( ! m_writes_during_sync.empty() || m_non_flushed_cnt > 0 || ! m_detach_time_logged)
{
report_and_merge_delta_stats();
m_cfi.WriteIOStatDetach(m_stats);
m_detach_time_logged = true;
m_in_sync = true;
TRACEF(Debug, "FinalizeSyncBeforeExit requesting sync to write detach stats");
return true;
}
}
TRACEF(Debug, "FinalizeSyncBeforeExit sync not required");
return false;
}

References Debug, and TRACEF.

## Fstat()

int File::Fstat | ( | struct stat & | sbuff | ) |

Definition at line 629 of file XrdPfcFile.cc.

{
// Stat on an open file.
// Corrects size to actual full size of the file.
// Sets atime to 0 if the file is only partially downloaded, in accordance
// with pfc.onlyifcached settings.
// Called from IO::Fstat() and Cache::Stat() when the file is active.
// Returns 0 on success, -errno on error.
int res;
if ((res = m_data_file->Fstat(&sbuff))) return res;
sbuff.st_size = m_file_size;
bool is_cached = cache()->DecideIfConsideredCached(m_file_size, sbuff.st_blocks * 512ll);
if ( ! is_cached)
sbuff.st_atime = 0;
return 0;
}

References stat.

Referenced by XrdPfc::Cache::ConsiderCached(), and XrdPfc::Cache::Stat().

Here is the caller graph for this function:

## get_ref_cnt()

int XrdPfc::File::get_ref_cnt | ( |  | ) |

inline

Definition at line 286 of file XrdPfcFile.hh.

{ return m_ref_cnt; }

## GetAccessCnt()

size_t XrdPfc::File::GetAccessCnt | ( |  | ) | const

inline

Definition at line 276 of file XrdPfcFile.hh.

{ return m_cfi.GetAccessCnt(); }

## GetBlockSize()

int XrdPfc::File::GetBlockSize | ( |  | ) | const

inline

Definition at line 277 of file XrdPfcFile.hh.

{ return m_cfi.GetBufferSize(); }

## GetFileSize()

long long XrdPfc::File::GetFileSize | ( |  | ) | const

inline

Definition at line 267 of file XrdPfcFile.hh.

{ return m_file_size; }

## GetLastAccessStats()

const Info::AStat * XrdPfc::File::GetLastAccessStats | ( |  | ) | const

inline

Definition at line 275 of file XrdPfcFile.hh.

{ return m_cfi.GetLastAccessStats(); }

## GetLocalPath()

const std::string & XrdPfc::File::GetLocalPath | ( |  | ) | const

inline

Definition at line 262 of file XrdPfcFile.hh.

{ return m_filename; }

Referenced by XrdPfc::Cache::AddWriteTask(), and XrdPfc::Cache::ReleaseFile().

Here is the caller graph for this function:

## GetLog()

XrdSysError * File::GetLog | ( |  | ) | const

Definition at line 1699 of file XrdPfcFile.cc.

{
return Cache::TheOne().GetLog();
}
XrdPfc::Cache::GetLog
XrdSysError * GetLog() const
Definition XrdPfc.hh:294
XrdPfc::Cache::TheOne
static const Cache & TheOne()
Definition XrdPfc.cc:133

References XrdPfc::Cache::GetLog(), and XrdPfc::Cache::TheOne().

Here is the call graph for this function:

## GetNBlocks()

int XrdPfc::File::GetNBlocks | ( |  | ) | const

inline

Definition at line 278 of file XrdPfcFile.hh.

{ return m_cfi.GetNBlocks(); }

## GetNDownloadedBlocks()

int XrdPfc::File::GetNDownloadedBlocks | ( |  | ) | const

inline

Definition at line 279 of file XrdPfcFile.hh.

{ return m_cfi.GetNDownloadedBlocks(); }

## GetPrefetchCountOnIO()

int XrdPfc::File::GetPrefetchCountOnIO | ( | IO * | io | ) |

## GetPrefetchedBytes()

long long XrdPfc::File::GetPrefetchedBytes | ( |  | ) | const

inline

Definition at line 280 of file XrdPfcFile.hh.

{ return m_prefetch_bytes; }

## GetPrefetchScore()

float File::GetPrefetchScore | ( |  | ) | const

Definition at line 1694 of file XrdPfcFile.cc.

{
return m_prefetch_score;
}

## GetRemoteLocations()

std::string File::GetRemoteLocations | ( |  | ) | const

Definition at line 1718 of file XrdPfcFile.cc.

{
std::string s;
if ( ! m_remote_locations.empty())
{
size_t sl = 0;
int nl = 0;
for (std::set<std::string>::iterator i = m_remote_locations.begin(); i != m_remote_locations.end(); ++i, ++nl)
{
sl += i->size();
}
s.reserve(2 + sl + 2*nl + nl - 1 + 1);
s = '[';
int j = 1;
for (std::set<std::string>::iterator i = m_remote_locations.begin(); i != m_remote_locations.end(); ++i, ++j)
{
s += '"'; s += *i; s += '"';
if (j < nl) s += ',';
}
s += ']';
}
else
{
s = "[]";
}
return s;
}

## GetTrace()

XrdSysTrace * File::GetTrace | ( |  | ) | const

Definition at line 1704 of file XrdPfcFile.cc.

{
return Cache::TheOne().GetTrace();
}
XrdPfc::Cache::GetTrace
XrdSysTrace * GetTrace() const
Definition XrdPfc.hh:295

References XrdPfc::Cache::GetTrace(), and XrdPfc::Cache::TheOne().

Here is the call graph for this function:

## inc_ref_cnt()

int XrdPfc::File::inc_ref_cnt | ( |  | ) |

inline

Definition at line 287 of file XrdPfcFile.hh.

{ return ++m_ref_cnt; }

## initiate_emergency_shutdown()

long long File::initiate_emergency_shutdown | ( |  | ) |

Definition at line 154 of file XrdPfcFile.cc.

{
// Called from Cache::Unlink() when the file is currently open.
// Cache::Unlink is also called on FSync error and when wrong number of bytes
// is received from a remote read.
//
// From this point onward the file will not be written to, cinfo file will
// not be updated, and all new read requests will return -ENOENT.
//
// File's entry in the Cache's active map is set to nullptr and will be
// removed from there shortly, in any case, well before this File object
// shuts down. Cache::Unlink() also reports the appropriate purge event.
XrdSysCondVarHelper _lck(m_state_cond);
m_in_shutdown = true;
if (m_prefetch_state != kStopped && m_prefetch_state != kComplete)
{
m_prefetch_state = kStopped;
cache()->DeRegisterPrefetchFile(this);
}
report_and_merge_delta_stats();
return m_st_blocks;
}

Referenced by XrdPfc::Cache::UnlinkFile().

Here is the caller graph for this function:

## ioActive()

bool File::ioActive | ( | IO * | io | ) |

Initiate close. Return true if still IO active. Used in XrdPosixXrootd::Close().

Definition at line 242 of file XrdPfcFile.cc.

{
// Returns true if delay is needed.
TRACEF(Debug, "ioActive start for io " << io);
std::string loc(io->GetLocation());
{
XrdSysCondVarHelper _lck(m_state_cond);
IoSet_i mi = m_io_set.find(io);
if (mi != m_io_set.end())
{
unsigned int n_active_reads = io->m_active_read_reqs;
TRACE(Info, "ioActive for io " << io <<
", active_reads " << n_active_reads <<
", active_prefetches " << io->m_active_prefetches <<
", allow_prefetching " << io->m_allow_prefetching <<
", ios_in_detach " << m_ios_in_detach);
TRACEF(Info,
"\tio_map.size() " << m_io_set.size() <<
", block_map.size() " << m_block_map.size() << ", file");
insert_remote_location(loc);
io->m_allow_prefetching = false;
io->m_in_detach = true;
// Check if any IO is still available for prfetching. If not, stop it.
if (m_prefetch_state == kOn || m_prefetch_state == kHold)
{
if ( ! select_current_io_or_disable_prefetching(false) )
{
TRACEF(Debug, "ioActive stopping prefetching after io " << io << " retreat.");
}
}
// On last IO, consider write queue blocks. Note, this also contains
// blocks being prefetched.
bool io_active_result;
if (n_active_reads > 0)
{
io_active_result = true;
}
else if (m_io_set.size() - m_ios_in_detach == 1)
{
io_active_result = ! m_block_map.empty();
}
else
{
io_active_result = io->m_active_prefetches > 0;
}
if ( ! io_active_result)
{
++m_ios_in_detach;
}
TRACEF(Info, "ioActive for io " << io << " returning " << io_active_result << ", file");
return io_active_result;
}
else
{
TRACEF(Error, "ioActive io " << io <<" not found in IoSet. This should not happen.");
return false;
}
}
}
TRACE
#define TRACE(act, x)
Definition XrdTrace.hh:63
XrdPfc::IO::m_active_read_reqs
RAtomic_int m_active_read_reqs
number of active read requests
Definition XrdPfcIO.hh:70

References Debug, Error, XrdPfc::IO::GetLocation(), XrdPfc::IO::m_active_read_reqs, TRACE, and TRACEF.

Here is the call graph for this function:

## ioUpdated()

void File::ioUpdated | ( | IO * | io | ) |

Notification from IO that it has been updated (remote open).

Definition at line 233 of file XrdPfcFile.cc.

{
std::string loc(io->GetLocation());
XrdSysCondVarHelper _lck(m_state_cond);
insert_remote_location(loc);
}

References XrdPfc::IO::GetLocation().

Here is the call graph for this function:

## is_in_emergency_shutdown()

bool XrdPfc::File::is_in_emergency_shutdown | ( |  | ) |

inline

Definition at line 291 of file XrdPfcFile.hh.

{ return m_in_shutdown; }

## lPath()

const char * File::lPath | ( |  | ) | const

Log path.

Definition at line 1606 of file XrdPfcFile.cc.

{
return m_filename.c_str();
}

Referenced by XrdPfc::Cache::ProcessWriteTasks(), and XrdPfc::Cache::RemoveWriteQEntriesFor().

Here is the caller graph for this function:

## Prefetch()

void File::Prefetch | ( |  | ) |

Definition at line 1621 of file XrdPfcFile.cc.

{
// Check that block is not on disk and not in RAM.
// TODO: Could prefetch several blocks at once!
// blks_max could be an argument
BlockList_t blks;
TRACEF(DumpXL, "Prefetch() entering.");
{
XrdSysCondVarHelper _lck(m_state_cond);
if (m_prefetch_state != kOn)
{
return;
}
if ( ! select_current_io_or_disable_prefetching(true) )
{
TRACEF(Error, "Prefetch no available IO object found, prefetching stopped. This should not happen, i.e., prefetching should be stopped before.");
return;
}
// Select block(s) to fetch.
for (int f = 0; f < m_num_blocks; ++f)
{
if ( ! m_cfi.TestBitWritten(f))
{
int f_act = f + m_offset / m_block_size;
BlockMap_i bi = m_block_map.find(f_act);
if (bi == m_block_map.end())
{
Block *b = PrepareBlockRequest(f_act, *m_current_io, nullptr, true);
if (b)
{
TRACEF(Dump, "Prefetch take block " << f_act);
blks.push_back(b);
// Note: block ref_cnt not increased, it will be when placed into write queue.
inc_prefetch_read_cnt(1);
}
else
{
// This shouldn't happen as prefetching stops when RAM is 70% full.
TRACEF(Warning, "Prefetch allocation failed for block " << f_act);
}
break;
}
}
}
if (blks.empty())
{
TRACEF(Debug, "Prefetch file is complete, stopping prefetch.");
m_prefetch_state = kComplete;
cache()->DeRegisterPrefetchFile(this);
}
else
{
(*m_current_io)->m_active_prefetches += (int) blks.size();
}
}
if ( ! blks.empty())
{
ProcessBlockRequests(blks);
}
}
XrdPfc::BlockList_t
std::list< Block * > BlockList_t
Definition XrdPfcFile.hh:166

References Debug, Error, and TRACEF.

Referenced by XrdPfc::Cache::Prefetch().

Here is the caller graph for this function:

## Read()

int File::Read | ( | IO * | io,
|  | char * | buff,
|  | long long | offset,
|  | int | size,
|  | ReadReqRH * | rh )

Normal read.

Definition at line 814 of file XrdPfcFile.cc.

{
// rrc_func is ONLY called from async processing.
// If this function returns anything other than -EWOULDBLOCK, rrc_func needs to be called by the caller.
// This streamlines implementation of synchronous IO::Read().
TRACEF(Dump, "Read() sid: " << Xrd::hex1 << rh->m_seq_id << " size: " << iUserSize);
m_state_cond.Lock();
if (m_in_shutdown || io->m_in_detach)
{
m_state_cond.UnLock();
return m_in_shutdown ? -ENOENT : -EBADF;
}
// Shortcut -- file is fully downloaded.
if (m_cfi.IsComplete())
{
m_state_cond.UnLock();
int ret = m_data_file->Read(iUserBuff, iUserOff, iUserSize);
if (ret > 0) {
XrdSysCondVarHelper _lck(m_state_cond);
m_delta_stats.AddBytesHit(ret);
check_delta_stats();
}
return ret;
}
XrdOucIOVec readV( { iUserOff, iUserSize, 0, iUserBuff } );
return ReadOpusCoalescere(io, &readV, 1, rh, "Read() ");
}
Xrd::hex1
@ hex1
Definition XrdSysTrace.hh:42
XrdPfc::ReadReqRH::m_seq_id
unsigned short m_seq_id
Definition XrdPfcFile.hh:53

References Xrd::hex1, XrdPfc::ReadReqRH::m_seq_id, and TRACEF.

Referenced by XrdPfc::IOFileBlock::Read().

Here is the caller graph for this function:

## ReadV()

int File::ReadV | ( | IO * | io,
|  | const XrdOucIOVec * | readV,
|  | int | readVnum,
|  | ReadReqRH * | rh )

Vector read.

Definition at line 851 of file XrdPfcFile.cc.

{
TRACEF(Dump, "ReadV() for " << readVnum << " chunks.");
m_state_cond.Lock();
if (m_in_shutdown || io->m_in_detach)
{
m_state_cond.UnLock();
return m_in_shutdown ? -ENOENT : -EBADF;
}
// Shortcut -- file is fully downloaded.
if (m_cfi.IsComplete())
{
m_state_cond.UnLock();
int ret = m_data_file->ReadV(const_cast<XrdOucIOVec*>(readV), readVnum);
if (ret > 0) {
XrdSysCondVarHelper _lck(m_state_cond);
m_delta_stats.AddBytesHit(ret);
check_delta_stats();
}
return ret;
}
return ReadOpusCoalescere(io, readV, readVnum, rh, "ReadV() ");
}

References TRACEF.

## RefStats()

const Stats & XrdPfc::File::RefStats | ( |  | ) | const

inline

Definition at line 281 of file XrdPfcFile.hh.

{ return m_stats; }

## RemoveIO()

void File::RemoveIO | ( | IO * | io | ) |

Definition at line 386 of file XrdPfcFile.cc.

{
// Called from Cache::ReleaseFile.
TRACEF(Debug, "RemoveIO() io = " << (void*)io);
time_t now = time(0);
m_state_cond.Lock();
IoSet_i mi = m_io_set.find(io);
if (mi != m_io_set.end())
{
if (mi == m_current_io)
{
++m_current_io;
}
m_delta_stats.IoDetach(now - io->m_attach_time);
m_io_set.erase(mi);
--m_ios_in_detach;
if (m_io_set.empty() && m_prefetch_state != kStopped && m_prefetch_state != kComplete)
{
TRACEF(Error, "RemoveIO() io = " << (void*)io << " Prefetching is not stopped/complete -- it should be by now.");
m_prefetch_state = kStopped;
cache()->DeRegisterPrefetchFile(this);
}
}
else
{
TRACEF(Error, "RemoveIO() io = " << (void*)io << " is NOT registered.");
}
m_state_cond.UnLock();
}

References Debug, Error, and TRACEF.

Referenced by XrdPfc::Cache::ReleaseFile().

Here is the caller graph for this function:

## RequestSyncOfDetachStats()

void File::RequestSyncOfDetachStats | ( |  | ) |

Flags that detach stats should be written out in final sync. Called from CacheIO upon Detach.

Definition at line 319 of file XrdPfcFile.cc.

{
XrdSysCondVarHelper _lck(m_state_cond);
m_detach_time_logged = false;
}

## StopPrefetchingOnIO()

void XrdPfc::File::StopPrefetchingOnIO | ( | IO * | io | ) |

## Sync()

void File::Sync | ( |  | ) |

Sync file cache inf o and output data with disk.

Definition at line 1220 of file XrdPfcFile.cc.

{
TRACEF(Dump, "Sync()");
int ret = m_data_file->Fsync();
bool errorp = false;
if (ret == XrdOssOK)
{
Stats loc_stats;
{
XrdSysCondVarHelper _lck(&m_state_cond);
report_and_merge_delta_stats();
loc_stats = m_stats;
}
m_cfi.WriteIOStat(loc_stats);
m_cfi.Write(m_info_file, m_filename.c_str());
int cret = m_info_file->Fsync();
if (cret != XrdOssOK)
{
TRACEF(Error, "Sync cinfo file sync error " << cret);
errorp = true;
}
}
else
{
TRACEF(Error, "Sync data file sync error " << ret << ", cinfo file has not been updated");
errorp = true;
}
if (errorp)
{
TRACEF(Error, "Sync failed, unlinking local files and initiating shutdown of File object");
// Unlink will also call this->initiate_emergency_shutdown()
Cache::GetInstance().UnlinkFile(m_filename, false);
XrdSysCondVarHelper _lck(&m_state_cond);
m_writes_during_sync.clear();
m_in_sync = false;
return;
}
int written_while_in_sync;
bool resync = false;
{
XrdSysCondVarHelper _lck(&m_state_cond);
for (std::vector<int>::iterator i = m_writes_during_sync.begin(); i != m_writes_during_sync.end(); ++i)
{
m_cfi.SetBitSynced(*i);
}
written_while_in_sync = m_non_flushed_cnt = (int) m_writes_during_sync.size();
m_writes_during_sync.clear();
// If there were writes during sync and the file is now complete,
// let us call Sync again without resetting the m_in_sync flag.
if (written_while_in_sync > 0 && m_cfi.IsComplete() && ! m_in_shutdown)
resync = true;
else
m_in_sync = false;
}
TRACEF(Dump, "Sync "<< written_while_in_sync << " blocks written during sync." << (resync ? " File is now complete - resyncing." : ""));
if (resync)
Sync();
}
XrdOssOK
#define XrdOssOK
Definition XrdOss.hh:50
XrdPfc::Cache::GetInstance
static Cache & GetInstance()
Singleton access.
Definition XrdPfc.cc:132
XrdPfc::Cache::UnlinkFile
int UnlinkFile(const std::string &f_name, bool fail_if_open)
Remove cinfo and data files from cache.
Definition XrdPfc.cc:1188
XrdPfc::File::Sync
void Sync()
Sync file cache inf o and output data with disk.
Definition XrdPfcFile.cc:1220
XrdPosixGlobals::Stats
XrdPosixStats Stats
Definition XrdPosixFile.cc:64

References Error, XrdPfc::Cache::GetInstance(), Sync(), TRACEF, XrdPfc::Cache::UnlinkFile(), and XrdOssOK.

Referenced by Sync().

Here is the call graph for this function:
Here is the caller graph for this function:

## WriteBlockToDisk()

void File::WriteBlockToDisk | ( | Block * | b | ) |

Definition at line 1134 of file XrdPfcFile.cc.

{
// write block buffer into disk file
long long offset = b->m_offset - m_offset;
long long size = b->get_size();
ssize_t retval;
if (m_cfi.IsCkSumCache())
if (b->has_cksums())
retval = m_data_file->pgWrite(b->get_buff(), offset, size, b->ref_cksum_vec().data(), 0);
else
retval = m_data_file->pgWrite(b->get_buff(), offset, size, 0, 0);
else
retval = m_data_file->Write(b->get_buff(), offset, size);
if (retval < size)
{
if (retval < 0) {
TRACEF(Error, "WriteToDisk() write error " << retval);
} else {
TRACEF(Error, "WriteToDisk() incomplete block write ret=" << retval << " (should be " << size << ")");
}
XrdSysCondVarHelper _lck(m_state_cond);
dec_ref_count(b);
return;
}
const int blk_idx = (b->m_offset - m_offset) / m_block_size;
// Set written bit.
TRACEF(Dump, "WriteToDisk() success set bit for block " << b->m_offset << " size=" << size);
bool schedule_sync = false;
{
XrdSysCondVarHelper _lck(m_state_cond);
m_cfi.SetBitWritten(blk_idx);
if (b->m_prefetch)
{
m_cfi.SetBitPrefetch(blk_idx);
}
if (b->req_cksum_net() && ! b->has_cksums() && m_cfi.IsCkSumNet())
{
m_cfi.ResetCkSumNet();
}
// Set synced bit or stash block index if in actual sync.
// Synced state is only written out to cinfo file when data file is synced.
if (m_in_sync)
{
m_writes_during_sync.push_back(blk_idx);
}
else
{
m_cfi.SetBitSynced(blk_idx);
++m_non_flushed_cnt;
if ((m_cfi.IsComplete() || m_non_flushed_cnt >= Cache::GetInstance().RefConfiguration().m_flushCnt) &&
! m_in_shutdown)
{
schedule_sync = true;
m_in_sync = true;
m_non_flushed_cnt = 0;
}
}
// As soon as the reference count is decreased on the block, the
// file object may be deleted. Thus, to avoid holding both locks at a time,
// we defer the ref count decrease until later if a sync is needed
if (!schedule_sync) {
dec_ref_count(b);
}
}
if (schedule_sync)
{
cache()->ScheduleFileSync(this);
XrdSysCondVarHelper _lck(m_state_cond);
dec_ref_count(b);
}
}
XrdPfc::Block::get_size
int get_size() const
Definition XrdPfcFile.hh:136
XrdPfc::Block::ref_cksum_vec
vCkSum_t & ref_cksum_vec()
Definition XrdPfcFile.hh:161
XrdPfc::Block::m_prefetch
bool m_prefetch
Definition XrdPfcFile.hh:120
XrdPfc::Block::req_cksum_net
bool req_cksum_net() const
Definition XrdPfcFile.hh:159
XrdPfc::Block::get_buff
char * get_buff() const
Definition XrdPfcFile.hh:135
XrdPfc::Block::has_cksums
bool has_cksums() const
Definition XrdPfcFile.hh:160
XrdPfc::Cache::RefConfiguration
const Configuration & RefConfiguration() const
Reference XrdPfc configuration.
Definition XrdPfc.hh:215
XrdPfc::Configuration::m_flushCnt
long long m_flushCnt
nuber of unsynced blcoks on disk before flush is called
Definition XrdPfc.hh:122

References Error, XrdPfc::Block::get_buff(), XrdPfc::Block::get_size(), XrdPfc::Cache::GetInstance(), XrdPfc::Block::has_cksums(), XrdPfc::Block::m_offset, XrdPfc::Block::m_prefetch, XrdPfc::Block::ref_cksum_vec(), XrdPfc::Block::req_cksum_net(), and TRACEF.

Referenced by XrdPfc::Cache::ProcessWriteTasks().

Here is the call graph for this function:
Here is the caller graph for this function:

## Friends And Related Symbol Documentation

## BlockResponseHandler

friend class BlockResponseHandler

friend

Definition at line 205 of file XrdPfcFile.hh.

References BlockResponseHandler.

Referenced by BlockResponseHandler.

## Cache

friend class Cache

friend

Definition at line 204 of file XrdPfcFile.hh.

References Cache.

Referenced by Cache.

## DirectResponseHandler

friend class DirectResponseHandler

friend

Definition at line 206 of file XrdPfcFile.hh.

References DirectResponseHandler.

Referenced by DirectResponseHandler.

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

- XrdPfcFile.hh
- XrdPfcFile.cc