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

`#include <XrdPfcFsTraversal.hh>`

Collaboration diagram for XrdPfc::FsTraversal:

## Classes

struct | FilePairStat

## Public Member Functions

| FsTraversal (XrdOss &oss)
| ~FsTraversal ()
bool | begin_traversal (const char *root_path)
bool | begin_traversal (DirState *root, const char *root_path)
bool | cd_down (const std::string &dir_name)
void | cd_up ()
int | close_delete (XrdOssDF *&ossDF)
XrdOucEnv & | default_env ()
void | end_traversal ()
int | open_at_ro (const char *fname, XrdOssDF *&ossDF)
void | slurp_current_dir ()
void | slurp_dir_ll (XrdOssDF &dh, int dir_level, const char *path, const char *trc_pfx)
int | unlink_at (const char *fname)

## Public Attributes

std::vector< std::string > | m_current_dirs
std::map< std::string, FilePairStat > | m_current_files
std::string | m_current_path
std::vector< XrdOssDF * > | m_dir_handle_stack
DirState * | m_dir_state = nullptr
std::set< std::string > | m_protected_top_dirs
int | m_rel_dir_level = -1
DirState * | m_root_dir_state = nullptr

## Static Public Attributes

static const char * | m_traceID = "FsTraversal"

## Protected Attributes

XrdOucEnv | m_env
bool | m_maintain_dirstate = false
XrdOss & | m_oss
XrdOssAt | m_oss_at

## Detailed Description

Definition at line 20 of file XrdPfcFsTraversal.hh.

## Constructor & Destructor Documentation

## FsTraversal()

FsTraversal::FsTraversal | ( | XrdOss & | oss | ) |

Definition at line 23 of file XrdPfcFsTraversal.cc.

:
m_oss(oss), m_oss_at(oss)
{}
XrdPfc::FsTraversal::m_oss
XrdOss & m_oss
Definition XrdPfcFsTraversal.hh:34
XrdPfc::FsTraversal::m_oss_at
XrdOssAt m_oss_at
Definition XrdPfcFsTraversal.hh:35

References m_oss, and m_oss_at.

## ~FsTraversal()

FsTraversal::~FsTraversal | ( |  | ) |

Definition at line 27 of file XrdPfcFsTraversal.cc.

{}

## Member Function Documentation

## begin_traversal() [1/2]

bool FsTraversal::begin_traversal | ( | const char * | root_path | ) |

Definition at line 53 of file XrdPfcFsTraversal.cc.

{
static const char *trc_pfx = "FsTraversal::begin_traversal ";
assert(root_path && strlen(root_path) > 0 && root_path[0] == '/');
m_rel_dir_level = 0;
m_current_path = root_path;
XrdOssDF* dhp = m_oss.newDir("PfcFsTraversal");
if (dhp->Opendir(root_path, m_env) != XrdOssOK) {
delete dhp;
TRACE(Error, trc_pfx << "could not opendir [" << root_path << "], " << XrdSysE2T(errno));
return false;
}
m_dir_handle_stack.push_back(dhp);
TRACE_PURGE("FPurgeState::begin_traversal cur_path '" << m_current_path << "', rel_level=" << m_rel_dir_level);
slurp_current_dir();
return true;
}
XrdOssOK
#define XrdOssOK
Definition XrdOss.hh:50
TRACE_PURGE
#define TRACE_PURGE(x)
Definition XrdPfcFPurgeState.cc:15
XrdSysE2T
const char * XrdSysE2T(int errcode)
Definition XrdSysE2T.cc:104
Error
@ Error
Definition XrdTlsNotaryUtils.hh:42
TRACE
#define TRACE(act, x)
Definition XrdTrace.hh:63
XrdOssDF::Opendir
virtual int Opendir(const char *path, XrdOucEnv &env)
Definition XrdOss.hh:79
XrdPfc::FsTraversal::slurp_current_dir
void slurp_current_dir()
Definition XrdPfcFsTraversal.cc:137
XrdPfc::FsTraversal::m_current_path
std::string m_current_path
Definition XrdPfcFsTraversal.hh:45
XrdPfc::FsTraversal::m_dir_handle_stack
std::vector< XrdOssDF * > m_dir_handle_stack
Definition XrdPfcFsTraversal.hh:49
XrdPfc::FsTraversal::m_rel_dir_level
int m_rel_dir_level
Definition XrdPfcFsTraversal.hh:44
XrdPfc::FsTraversal::m_env
XrdOucEnv m_env
Definition XrdPfcFsTraversal.hh:36

References Error, m_current_path, m_dir_handle_stack, m_env, m_oss, m_rel_dir_level, XrdOssDF::Opendir(), slurp_current_dir(), TRACE, TRACE_PURGE, XrdOssOK, and XrdSysE2T().

Here is the call graph for this function:

## begin_traversal() [2/2]

bool FsTraversal::begin_traversal | ( | DirState * | root,
|  | const char * | root_path )

Definition at line 43 of file XrdPfcFsTraversal.cc.

{
m_maintain_dirstate = true;
m_root_dir_state = m_dir_state = root;
bool ret = begin_traversal(root_path);
return ret;
}
XrdPfc::FsTraversal::m_maintain_dirstate
bool m_maintain_dirstate
Definition XrdPfcFsTraversal.hh:38
XrdPfc::FsTraversal::begin_traversal
bool begin_traversal(DirState *root, const char *root_path)
Definition XrdPfcFsTraversal.cc:43
XrdPfc::FsTraversal::m_dir_state
DirState * m_dir_state
Definition XrdPfcFsTraversal.hh:42
XrdPfc::FsTraversal::m_root_dir_state
DirState * m_root_dir_state
Definition XrdPfcFsTraversal.hh:41

References begin_traversal(), m_dir_state, m_maintain_dirstate, and m_root_dir_state.

Referenced by begin_traversal(), XrdPfc::ResourceMonitor::perform_initial_scan(), and XrdPfc::FPurgeState::TraverseNamespace().

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

## cd_down()

bool FsTraversal::cd_down | ( | const std::string & | dir_name | ) |

Definition at line 96 of file XrdPfcFsTraversal.cc.

{
static const char *trc_pfx = "FsTraversal::cd_down ";
XrdOssDF *dhp = 0;
if (m_oss_at.Opendir(*m_dir_handle_stack.back(), dir_name.c_str(), m_env, dhp) != XrdOssOK) {
delete dhp;
TRACE(Error, trc_pfx << "could not opendir [" << m_current_path << dir_name << "], " << XrdSysE2T(errno));
return false;
}
m_dir_handle_stack.push_back(dhp);
++m_rel_dir_level;
m_current_path.append(dir_name);
m_current_path.append("/");
if (m_maintain_dirstate)
m_dir_state = m_dir_state->find_dir(dir_name, true);
slurp_current_dir();
return true;
}

References Error, m_current_path, m_dir_handle_stack, m_dir_state, m_env, m_maintain_dirstate, m_oss_at, m_rel_dir_level, slurp_current_dir(), TRACE, XrdOssOK, and XrdSysE2T().

Referenced by XrdPfc::FPurgeState::ProcessDirAndRecurse(), and XrdPfc::ResourceMonitor::scan_dir_and_recurse().

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

## cd_up()

void FsTraversal::cd_up | ( |  | ) |

Definition at line 119 of file XrdPfcFsTraversal.cc.

{
m_current_dirs.clear();
m_current_files.clear();
m_dir_handle_stack.back()->Close();
delete m_dir_handle_stack.back();
m_dir_handle_stack.pop_back();
if (m_maintain_dirstate)
m_dir_state = m_dir_state->get_parent();
m_current_path.erase(m_current_path.find_last_of('/', m_current_path.size() - 2) + 1);
--m_rel_dir_level;
}
XrdPfc::FsTraversal::m_current_dirs
std::vector< std::string > m_current_dirs
Definition XrdPfcFsTraversal.hh:51
XrdPfc::FsTraversal::m_current_files
std::map< std::string, FilePairStat > m_current_files
Definition XrdPfcFsTraversal.hh:52

References m_current_dirs, m_current_files, m_current_path, m_dir_handle_stack, m_dir_state, m_maintain_dirstate, and m_rel_dir_level.

Referenced by XrdPfc::FPurgeState::ProcessDirAndRecurse(), and XrdPfc::ResourceMonitor::scan_dir_and_recurse().

Here is the caller graph for this function:

## close_delete()

int FsTraversal::close_delete | ( | XrdOssDF *& | ossDF | ) |

Definition at line 30 of file XrdPfcFsTraversal.cc.

{
int ret = 0;
if (ossDF) {
ret = ossDF->Close();
delete ossDF;
}
ossDF = nullptr;
return ret;
}
XrdOssDF::Close
virtual int Close(long long *retsz=0)=0

References XrdOssDF::Close().

Here is the call graph for this function:

## default_env()

XrdOucEnv & XrdPfc::FsTraversal::default_env | ( |  | ) |

inline

Definition at line 80 of file XrdPfcFsTraversal.hh.

{ return m_env; }

References m_env.

## end_traversal()

void FsTraversal::end_traversal | ( |  | ) |

Definition at line 76 of file XrdPfcFsTraversal.cc.

{
TRACE_PURGE("FPurgeState::end_traversal reporting for '" << m_current_path << "', re_level=" << m_rel_dir_level);
for (auto &dhp : m_dir_handle_stack) {
dhp->Close();
delete dhp;
}
m_dir_handle_stack.clear();
m_current_path.clear();
m_current_dirs.clear();
m_current_files.clear();
m_rel_dir_level = -1;
m_root_dir_state = m_dir_state = nullptr;
m_maintain_dirstate = false;
}

References m_current_dirs, m_current_files, m_current_path, m_dir_handle_stack, m_dir_state, m_maintain_dirstate, m_rel_dir_level, m_root_dir_state, and TRACE_PURGE.

Referenced by XrdPfc::ResourceMonitor::perform_initial_scan(), and XrdPfc::FPurgeState::TraverseNamespace().

Here is the caller graph for this function:

## open_at_ro()

int XrdPfc::FsTraversal::open_at_ro | ( | const char * | fname,
|  | XrdOssDF *& | ossDF )

inline

Definition at line 72 of file XrdPfcFsTraversal.hh.

{
return m_oss_at.OpenRO(*m_dir_handle_stack.back(), fname, m_env, ossDF);
}

References m_dir_handle_stack, m_env, and m_oss_at.

## slurp_current_dir()

void FsTraversal::slurp_current_dir | ( |  | ) |

Definition at line 137 of file XrdPfcFsTraversal.cc.

{
static const char *trc_pfx = "FsTraversal::slurp_current_dir ";
XrdOssDF &dh = *m_dir_handle_stack.back();
slurp_dir_ll(dh, m_rel_dir_level, m_current_path.c_str(), trc_pfx);
}
XrdPfc::FsTraversal::slurp_dir_ll
void slurp_dir_ll(XrdOssDF &dh, int dir_level, const char *path, const char *trc_pfx)
Definition XrdPfcFsTraversal.cc:147

References m_current_path, m_dir_handle_stack, m_rel_dir_level, and slurp_dir_ll().

Referenced by begin_traversal(), and cd_down().

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

## slurp_dir_ll()

void FsTraversal::slurp_dir_ll | ( | XrdOssDF & | dh,
|  | int | dir_level,
|  | const char * | path,
|  | const char * | trc_pfx )

Definition at line 147 of file XrdPfcFsTraversal.cc.

{
// Low-level implementation of slurp dir.
char fname[256];
struct stat fstat;
dh.StatRet(&fstat);
const char *info_ext = Info::s_infoExtension;
const size_t info_ext_len = Info::s_infoExtensionLen;
m_current_dirs.clear();
m_current_files.clear();
while (true)
{
int rc = dh.Readdir(fname, 256);
if (rc == -ENOENT)
{
TRACE_PURGE(" Skipping ENOENT dir entry [" << fname << "].");
continue;
}
if (rc != XrdOssOK)
{
TRACE(Error, trc_pfx << "Readdir error at " << path << ", err " << XrdSysE2T(-rc) << ".");
break;
}
TRACE_PURGE(" Readdir [" << fname << "]");
if (fname[0] == 0)
{
TRACE_PURGE(" Finished reading dir [" << path << "]. Break loop.");
break;
}
if (fname[0] == '.' && (fname[1] == 0 || (fname[1] == '.' && fname[2] == 0)))
{
TRACE_PURGE(" Skipping here or parent dir [" << fname << "]. Continue loop.");
continue;
}
if (S_ISDIR(fstat.st_mode))
{
if (dir_level == 0 && m_protected_top_dirs.find(fname) != m_protected_top_dirs.end())
{
// Skip protected top-directories.
continue;
}
m_current_dirs.push_back(fname);
}
else
{
size_t fname_len = strlen(fname);
if (fname_len > info_ext_len && strncmp(&fname[fname_len - info_ext_len], info_ext, info_ext_len) == 0)
{
// truncate ".cinfo" away
fname[fname_len - info_ext_len] = 0;
m_current_files[fname].set_cinfo(fstat);
}
else
{
m_current_files[fname].set_data(fstat);
}
}
}
}
fstat
#define fstat(a, b)
Definition XrdPosix.hh:62
stat
#define stat(a, b)
Definition XrdPosix.hh:101
XrdOssDF::StatRet
virtual int StatRet(struct stat *buff)
Definition XrdOss.hh:107
XrdOssDF::Readdir
virtual int Readdir(char *buff, int blen)
Definition XrdOss.hh:92
XrdPfc::FsTraversal::m_protected_top_dirs
std::set< std::string > m_protected_top_dirs
Definition XrdPfcFsTraversal.hh:54
XrdPfc::Info::s_infoExtension
static const char * s_infoExtension
Definition XrdPfcInfo.hh:309
XrdPfc::Info::s_infoExtensionLen
static const size_t s_infoExtensionLen
Definition XrdPfcInfo.hh:310

References Error, fstat, m_current_dirs, m_current_files, m_protected_top_dirs, XrdOssDF::Readdir(), XrdPfc::Info::s_infoExtension, XrdPfc::Info::s_infoExtensionLen, stat, XrdOssDF::StatRet(), TRACE, TRACE_PURGE, XrdOssOK, and XrdSysE2T().

Referenced by slurp_current_dir().

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

## unlink_at()

int XrdPfc::FsTraversal::unlink_at | ( | const char * | fname | ) |

inline

Definition at line 75 of file XrdPfcFsTraversal.hh.

{
return m_oss_at.Unlink(*m_dir_handle_stack.back(), fname);
}

References m_dir_handle_stack, and m_oss_at.

## Member Data Documentation

## m_current_dirs

std::vector<std::string> XrdPfc::FsTraversal::m_current_dirs

Definition at line 51 of file XrdPfcFsTraversal.hh.

Referenced by cd_up(), end_traversal(), XrdPfc::FPurgeState::ProcessDirAndRecurse(), XrdPfc::ResourceMonitor::scan_dir_and_recurse(), and slurp_dir_ll().

## m_current_files

std::map<std::string, FilePairStat> XrdPfc::FsTraversal::m_current_files

Definition at line 52 of file XrdPfcFsTraversal.hh.

Referenced by cd_up(), end_traversal(), XrdPfc::FPurgeState::ProcessDirAndRecurse(), XrdPfc::ResourceMonitor::scan_dir_and_recurse(), and slurp_dir_ll().

## m_current_path

std::string XrdPfc::FsTraversal::m_current_path

Definition at line 45 of file XrdPfcFsTraversal.hh.

Referenced by begin_traversal(), cd_down(), cd_up(), XrdPfc::FPurgeState::CheckFile(), end_traversal(), XrdPfc::ResourceMonitor::scan_dir_and_recurse(), and slurp_current_dir().

## m_dir_handle_stack

std::vector<XrdOssDF*> XrdPfc::FsTraversal::m_dir_handle_stack

Definition at line 49 of file XrdPfcFsTraversal.hh.

Referenced by begin_traversal(), cd_down(), cd_up(), end_traversal(), open_at_ro(), slurp_current_dir(), and unlink_at().

## m_dir_state

DirState* XrdPfc::FsTraversal::m_dir_state = nullptr

Definition at line 42 of file XrdPfcFsTraversal.hh.

Referenced by begin_traversal(), cd_down(), cd_up(), end_traversal(), and XrdPfc::ResourceMonitor::scan_dir_and_recurse().

## m_env

XrdOucEnv XrdPfc::FsTraversal::m_env

protected

Definition at line 36 of file XrdPfcFsTraversal.hh.

Referenced by begin_traversal(), cd_down(), default_env(), and open_at_ro().

## m_maintain_dirstate

bool XrdPfc::FsTraversal::m_maintain_dirstate = false

protected

Definition at line 38 of file XrdPfcFsTraversal.hh.

Referenced by begin_traversal(), cd_down(), cd_up(), and end_traversal().

## m_oss

XrdOss& XrdPfc::FsTraversal::m_oss

protected

Definition at line 34 of file XrdPfcFsTraversal.hh.

Referenced by FsTraversal(), and begin_traversal().

## m_oss_at

XrdOssAt XrdPfc::FsTraversal::m_oss_at

protected

Definition at line 35 of file XrdPfcFsTraversal.hh.

Referenced by FsTraversal(), cd_down(), open_at_ro(), and unlink_at().

## m_protected_top_dirs

std::set<std::string> XrdPfc::FsTraversal::m_protected_top_dirs

Definition at line 54 of file XrdPfcFsTraversal.hh.

Referenced by XrdPfc::ResourceMonitor::perform_initial_scan(), slurp_dir_ll(), and XrdPfc::FPurgeState::TraverseNamespace().

## m_rel_dir_level

int XrdPfc::FsTraversal::m_rel_dir_level = -1

Definition at line 44 of file XrdPfcFsTraversal.hh.

Referenced by begin_traversal(), cd_down(), cd_up(), end_traversal(), and slurp_current_dir().

## m_root_dir_state

DirState* XrdPfc::FsTraversal::m_root_dir_state = nullptr

Definition at line 41 of file XrdPfcFsTraversal.hh.

Referenced by begin_traversal(), and end_traversal().

## m_traceID

const char * FsTraversal::m_traceID = "FsTraversal"

static

Definition at line 56 of file XrdPfcFsTraversal.hh.

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

- XrdPfcFsTraversal.hh
- XrdPfcFsTraversal.cc