XRootD
Loading...
Searching...
No Matches
XrdPfc::FPurgeState Class Reference

#include <XrdPfcFPurgeState.hh>

+ Collaboration diagram for XrdPfc::FPurgeState:

Classes

struct  PurgeCandidate
 

Public Types

using list_i = list_t::iterator
 
using list_t = std::list<PurgeCandidate>
 
using map_i = map_t::iterator
 
using map_t = std::multimap<time_t, PurgeCandidate>
 

Public Member Functions

 FPurgeState (long long iNBytesReq, XrdOss &oss)
 Constructor.
 
void CheckFile (const FsTraversal &fst, const char *fname, time_t atime, struct stat &fstat)
 
time_t getMinTime () const
 
long long getNBytesTotal () const
 
long long getNStBlocksTotal () const
 
void MoveListEntriesToMap ()
 
void ProcessDirAndRecurse (FsTraversal &fst)
 
list_trefList ()
 
map_trefMap ()
 
void setMinTime (time_t min_time)
 
void setUVKeepMinTime (time_t min_time)
 
bool TraverseNamespace (const char *root_path)
 

Detailed Description

Definition at line 22 of file XrdPfcFPurgeState.hh.

Member Typedef Documentation

◆ list_i

using XrdPfc::FPurgeState::list_i = list_t::iterator

Definition at line 37 of file XrdPfcFPurgeState.hh.

◆ list_t

Definition at line 36 of file XrdPfcFPurgeState.hh.

◆ map_i

using XrdPfc::FPurgeState::map_i = map_t::iterator

Definition at line 39 of file XrdPfcFPurgeState.hh.

◆ map_t

using XrdPfc::FPurgeState::map_t = std::multimap<time_t, PurgeCandidate>

Definition at line 38 of file XrdPfcFPurgeState.hh.

Constructor & Destructor Documentation

◆ FPurgeState()

FPurgeState::FPurgeState ( long long iNBytesReq,
XrdOss & oss )

Constructor.

Definition at line 24 of file XrdPfcFPurgeState.cc.

24 :
25 m_oss(oss),
26 m_nStBlocksReq((iNBytesReq >> 9) + 1ll), m_nStBlocksAccum(0), m_nStBlocksTotal(0),
27 m_tMinTimeStamp(0), m_tMinUVKeepTimeStamp(0)
28{
29
30}

Member Function Documentation

◆ CheckFile()

void FPurgeState::CheckFile ( const FsTraversal & fst,
const char * fname,
time_t atime,
struct stat & fstat )

Open info file. Look at the UV stams and last access time. Store the file in sorted map or in a list.s

Parameters
fnamename of cache-info file
Infoobject
statof the given file

Definition at line 53 of file XrdPfcFPurgeState.cc.

54{
55 long long nblocks = fstat.st_blocks;
56 // TRACE(Dump, trc_pfx << "FPurgeState::CheckFile checking " << fname << " accessTime " << atime);
57
58 m_nStBlocksTotal += nblocks;
59
60 // Could remove aged-out / uv-keep-failed files here ... or in the calling function that
61 // can aggreagate info for all files in the directory.
62
63 // For now keep using 0 time as this is used in the purge loop to make sure we continue even if enough
64 // disk-space has been freed.
65
66 if (m_tMinTimeStamp > 0 && atime < m_tMinTimeStamp)
67 {
68 m_flist.push_back(PurgeCandidate(fst.m_current_path, fname, nblocks, 0));
69 m_nStBlocksAccum += nblocks;
70 }
71 else if (m_nStBlocksAccum < m_nStBlocksReq || (!m_fmap.empty() && atime < m_fmap.rbegin()->first))
72 {
73 m_fmap.insert(std::make_pair(atime, PurgeCandidate(fst.m_current_path, fname, nblocks, atime)));
74 m_nStBlocksAccum += nblocks;
75
76 // remove newest files from map if necessary
77 while (!m_fmap.empty() && m_nStBlocksAccum - m_fmap.rbegin()->second.nStBlocks >= m_nStBlocksReq)
78 {
79 m_nStBlocksAccum -= m_fmap.rbegin()->second.nStBlocks;
80 m_fmap.erase(--(m_fmap.rbegin().base()));
81 }
82 }
83}
#define fstat(a, b)
Definition XrdPosix.hh:62

References fstat, and XrdPfc::FsTraversal::m_current_path.

Referenced by ProcessDirAndRecurse().

+ Here is the caller graph for this function:

◆ getMinTime()

time_t XrdPfc::FPurgeState::getMinTime ( ) const
inline

Definition at line 62 of file XrdPfcFPurgeState.hh.

62{ return m_tMinTimeStamp; }

◆ getNBytesTotal()

long long XrdPfc::FPurgeState::getNBytesTotal ( ) const
inline

Definition at line 65 of file XrdPfcFPurgeState.hh.

65{ return 512ll * m_nStBlocksTotal; }

Referenced by XrdPfc::OldStylePurgeDriver().

+ Here is the caller graph for this function:

◆ getNStBlocksTotal()

long long XrdPfc::FPurgeState::getNStBlocksTotal ( ) const
inline

Definition at line 64 of file XrdPfcFPurgeState.hh.

64{ return m_nStBlocksTotal; }

◆ MoveListEntriesToMap()

void FPurgeState::MoveListEntriesToMap ( )

Move remaing entires to the member map. This is used for cold files and for files collected from purge plugin (really?).

Definition at line 36 of file XrdPfcFPurgeState.cc.

37{
38 for (list_i i = m_flist.begin(); i != m_flist.end(); ++i)
39 {
40 m_fmap.insert(std::make_pair(i->time, *i));
41 }
42 m_flist.clear();
43}
list_t::iterator list_i

Referenced by XrdPfc::OldStylePurgeDriver().

+ Here is the caller graph for this function:

◆ ProcessDirAndRecurse()

void FPurgeState::ProcessDirAndRecurse ( FsTraversal & fst)

Definition at line 85 of file XrdPfcFPurgeState.cc.

86{
87 for (auto it = fst.m_current_files.begin(); it != fst.m_current_files.end(); ++it)
88 {
89 // Check if the file is currently opened / purge-protected is done before unlinking of the file.
90 const std::string &f_name = it->first;
91 const std::string i_name = f_name + Info::s_infoExtension;
92
93 // XXX Note, the initial scan now uses stat information only!
94
95 if (! it->second.has_both()) {
96 // cinfo or data file is missing. What do we do? Erase?
97 // Should really be checked in some other "consistency" traversal.
98 continue;
99 }
100
101 time_t atime = it->second.stat_cinfo.st_mtime;
102 CheckFile(fst, i_name.c_str(), atime, it->second.stat_data);
103
104 // Protected top-directories are skipped.
105 }
106
107 std::vector<std::string> dirs;
108 dirs.swap(fst.m_current_dirs);
109 for (auto &dname : dirs)
110 {
111 if (fst.cd_down(dname))
112 {
114 fst.cd_up();
115 }
116 }
117}
void CheckFile(const FsTraversal &fst, const char *fname, time_t atime, struct stat &fstat)
void ProcessDirAndRecurse(FsTraversal &fst)
std::vector< std::string > m_current_dirs
bool cd_down(const std::string &dir_name)
std::map< std::string, FilePairStat > m_current_files
static const char * s_infoExtension

References XrdPfc::FsTraversal::cd_down(), XrdPfc::FsTraversal::cd_up(), CheckFile(), XrdPfc::FsTraversal::m_current_dirs, XrdPfc::FsTraversal::m_current_files, ProcessDirAndRecurse(), and XrdPfc::Info::s_infoExtension.

Referenced by ProcessDirAndRecurse(), and TraverseNamespace().

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

◆ refList()

list_t & XrdPfc::FPurgeState::refList ( )
inline

Definition at line 59 of file XrdPfcFPurgeState.hh.

59{ return m_flist; }

◆ refMap()

map_t & XrdPfc::FPurgeState::refMap ( )
inline

Definition at line 58 of file XrdPfcFPurgeState.hh.

58{ return m_fmap; }

Referenced by XrdPfc::UnlinkPurgeStateFilesInMap().

+ Here is the caller graph for this function:

◆ setMinTime()

void XrdPfc::FPurgeState::setMinTime ( time_t min_time)
inline

Definition at line 61 of file XrdPfcFPurgeState.hh.

61{ m_tMinTimeStamp = min_time; }

Referenced by XrdPfc::OldStylePurgeDriver().

+ Here is the caller graph for this function:

◆ setUVKeepMinTime()

void XrdPfc::FPurgeState::setUVKeepMinTime ( time_t min_time)
inline

Definition at line 63 of file XrdPfcFPurgeState.hh.

63{ m_tMinUVKeepTimeStamp = min_time; }

Referenced by XrdPfc::OldStylePurgeDriver().

+ Here is the caller graph for this function:

◆ TraverseNamespace()

bool FPurgeState::TraverseNamespace ( const char * root_path)

Definition at line 119 of file XrdPfcFPurgeState.cc.

120{
121 bool success_p = true;
122
123 FsTraversal fst(m_oss);
124 fst.m_protected_top_dirs.insert("pfc-stats"); // XXXX This should come from config. Also: N2N?
125 // Also ... this onoly applies to /, not any root_path
126 if (fst.begin_traversal(root_path))
127 {
129 }
130 else
131 {
132 // Fail startup, can't open /.
133 success_p = false;
134 }
135 fst.end_traversal();
136
137 return success_p;
138}

References XrdPfc::FsTraversal::begin_traversal(), XrdPfc::FsTraversal::end_traversal(), XrdPfc::FsTraversal::m_protected_top_dirs, and ProcessDirAndRecurse().

Referenced by XrdPfc::OldStylePurgeDriver().

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

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