ewmscp  ..
Classes | Public Member Functions | Public Attributes | Protected Attributes | List of all members
daosFsCommon Class Reference

#include <daosFsCommon.h>

Inheritance diagram for daosFsCommon:
[legend]
Collaboration diagram for daosFsCommon:
[legend]

Classes

class  attrDataType
 
class  daosOptions
 

Public Member Functions

dfs_obj_t * getDirObj (const std::string &path)
 
 daosFsCommon (daosOptions &aOpt, bool isWriter)
 
 ~daosFsCommon () override
 
bool pathExists (const std::string &path) override
 
std::unique_ptr< const genericStatgetStat (const std::string &path, bool followLink) override
 
std::string getXattr (const std::string &path, const std::string &name) override
 
- Public Member Functions inherited from pathHandler
virtual ~pathHandler ()=default
 

Public Attributes

daos_handle_t poh
 
daos_handle_t coh
 
dfs_t * dfs
 
int flags
 
std::map< std::string, dfs_obj_t * > pathMap
 

Protected Attributes

daosOptionsopt
 

Detailed Description

Definition at line 11 of file daosFsCommon.h.

Constructor & Destructor Documentation

◆ daosFsCommon()

daosFsCommon::daosFsCommon ( daosOptions aOpt,
bool  isWriter 
)

Definition at line 34 of file daosFsCommon.cpp.

34  : flags(isWriter ? O_RDWR : O_RDONLY), opt(aOpt) {
35  throwcall::good0(daos_pool_connect(opt.poolName.c_str(), opt.sysName.empty() ? nullptr : opt.sysName.c_str(), 0,
36  &poh, nullptr, nullptr),
37  "can't connect to pool ", opt.poolName, " on sys ", opt.sysName);
38  throwcall::good0(daos_cont_open(poh, opt.containerName.c_str(), 0,
39  &coh, nullptr, nullptr),
40  "can't open container ", opt.containerName, " in pool ", opt.poolName, " on sys ", opt.sysName);
41  throwcall::good0(dfs_mount(poh, coh, flags, &dfs),
42  "can't mount daos fs in containr ", opt.containerName, " in pool ", opt.poolName, " on sys ", opt.sysName);
43 }

References coh, daosFsCommon::daosOptions::containerName, dfs, flags, throwcall::good0(), opt, poh, daosFsCommon::daosOptions::poolName, and daosFsCommon::daosOptions::sysName.

Here is the call graph for this function:

◆ ~daosFsCommon()

daosFsCommon::~daosFsCommon ( )
override

Definition at line 44 of file daosFsCommon.cpp.

44  {
45  for (auto& item: pathMap) {
46  throwcall::good0(dfs_release(item.second),
47  "can't release dir object for ", item.first);
48  }
49  throwcall::good0(dfs_umount(dfs),
50  "can't umount daos fs in containr ", opt.containerName, " in pool ", opt.poolName, " on sys ", opt.sysName);
51  throwcall::good0(daos_cont_close(coh, nullptr),
52  "can't close container ", opt.containerName, " in pool ", opt.poolName, " on sys ", opt.sysName);
53  throwcall::good0(daos_pool_disconnect(poh, nullptr),
54  "can't disconnect pool ", opt.poolName, " on sys ", opt.sysName);
55 }

References coh, daosFsCommon::daosOptions::containerName, dfs, throwcall::good0(), opt, pathMap, poh, daosFsCommon::daosOptions::poolName, and daosFsCommon::daosOptions::sysName.

Here is the call graph for this function:

Member Function Documentation

◆ getDirObj()

dfs_obj_t * daosFsCommon::getDirObj ( const std::string &  path)

Definition at line 21 of file daosFsCommon.cpp.

21  {
22  auto stripped = path.substr(0,path.find_last_of('/'));
23  auto it = pathMap.find(path);
24  if (it == pathMap.end()) {
25  dfs_obj_t* obj;
26  timerInst(dfs_lookup);
27  throwcall::good0(dfs_lookup(dfs, path.c_str(), flags, &obj, nullptr, nullptr),"can't lookup path", path);
28  auto result = pathMap.emplace(path, obj);
29  it = result.first;
30  }
31  return it->second;
32 }

References dfs, flags, throwcall::good0(), pathMap, and timerInst.

Referenced by inputHandler::daosFs::DaosFsDirectory::DaosFsDirectory(), getStat(), pathExists(), and inputHandler::daosFs::readerDaosFs::readerDaosFs().

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

◆ getStat()

std::unique_ptr< const genericStat > daosFsCommon::getStat ( const std::string &  path,
bool  followLink 
)
overridevirtual

Implements pathHandler.

Definition at line 68 of file daosFsCommon.cpp.

69  {
70  struct stat statBuf;
71  timerInst(stat);
72  auto result = dfs_stat(dfs, getDirObj(path), path.c_str(), &statBuf);
73  if (result && errno == ENOENT) {
74  return nullptr;
75  }
76  throwcall::good0(result, "can't stat", path);
77  if (followLink && S_ISLNK(statBuf.st_mode)) {
78  char buf[4096];
79  daos_size_t size = sizeof(buf);
80  dfs_obj_t* obj;
81  throwcall::good0(dfs_open(dfs, getDirObj(path), path.c_str(), 0x666, O_RDONLY, 0, 0, nullptr, &obj),
82  "can't open link", path);
83  throwcall::good0(dfs_get_symlink_value(obj, buf, &size),
84  "can't get symlink of link ", path);
85  throwcall::good0(dfs_release(obj), "can't relaese ",path);
86  return getStat(buf, true);
87  }
88  return std::unique_ptr<const genericStat>(new genericStat(statBuf, std::chrono::nanoseconds(1)));
89 };

References dfs, getDirObj(), throwcall::good0(), and timerInst.

Here is the call graph for this function:

◆ getXattr()

std::string daosFsCommon::getXattr ( const std::string &  path,
const std::string &  name 
)
overridevirtual

Reimplemented from pathHandler.

Definition at line 92 of file daosFsCommon.cpp.

93  {
94  char buffer[512];
95 
96  dfs_obj_t* obj;
97  throwcall::good0(dfs_lookup(dfs, path.c_str(), flags,
98  &obj, nullptr, nullptr),
99  "can't lookup ", path);
100  timerInst(getxattr);
101  daos_size_t size = sizeof(buffer);
102  auto retval = dfs_getxattr(dfs, obj, name.c_str(), buffer, &size);
103  throwcall::good0(dfs_release(obj),"can't release ", path);
104  if (retval == -1) {
105  if (errno == ENOENT || errno == ENOATTR) {
106  return "";
107  }
108  throwcall::badval(retval, -1, "can't get xattr on ", path);
109  }
110  buffer[size] = '\0';
111  return buffer;
112 };

References throwcall::badval(), dfs, ENOATTR, flags, throwcall::good0(), and timerInst.

Here is the call graph for this function:

◆ pathExists()

bool daosFsCommon::pathExists ( const std::string &  path)
overridevirtual

Implements pathHandler.

Definition at line 58 of file daosFsCommon.cpp.

58  {
59  struct stat statBuf;
60  timerInst(stat);
61  auto result = dfs_stat(dfs, getDirObj(path), path.c_str(), &statBuf);
62  if (result && (errno == ENOENT || errno == ENOTDIR)) {
63  return false;
64  }
65  throwcall::good0(result, "can't stat ", path);
66  return true;
67 };

References dfs, getDirObj(), throwcall::good0(), and timerInst.

Here is the call graph for this function:

Member Data Documentation

◆ coh

daos_handle_t daosFsCommon::coh

Definition at line 14 of file daosFsCommon.h.

Referenced by daosFsCommon(), and ~daosFsCommon().

◆ dfs

dfs_t* daosFsCommon::dfs

◆ flags

int daosFsCommon::flags

Definition at line 16 of file daosFsCommon.h.

Referenced by daosFsCommon(), getDirObj(), and getXattr().

◆ opt

daosOptions& daosFsCommon::opt
protected

Definition at line 28 of file daosFsCommon.h.

Referenced by daosFsCommon(), and ~daosFsCommon().

◆ pathMap

std::map<std::string, dfs_obj_t*> daosFsCommon::pathMap

Definition at line 17 of file daosFsCommon.h.

Referenced by getDirObj(), and ~daosFsCommon().

◆ poh

daos_handle_t daosFsCommon::poh

Definition at line 13 of file daosFsCommon.h.

Referenced by daosFsCommon(), and ~daosFsCommon().


The documentation for this class was generated from the following files:
ENOATTR
#define ENOATTR
Definition: daosFsCommon.cpp:10
daosFsCommon::coh
daos_handle_t coh
Definition: daosFsCommon.h:14
daosFsCommon::flags
int flags
Definition: daosFsCommon.h:16
throwcall::badval
T badval(T call, t badvalue, const Args &... args)
template function to wrap system calls that return a special bad value on failure
Definition: throwcall.h:54
genericStat
generic stat abstraction class Used to abstract the variants of the stat structure.
Definition: genericStat.h:12
daosFsCommon::opt
daosOptions & opt
Definition: daosFsCommon.h:28
daosFsCommon::getDirObj
dfs_obj_t * getDirObj(const std::string &path)
Definition: daosFsCommon.cpp:21
daosFsCommon::poh
daos_handle_t poh
Definition: daosFsCommon.h:13
daosFsCommon::daosOptions::poolName
options::single< std::string > poolName
Definition: daosFsCommon.h:24
daosFsCommon::dfs
dfs_t * dfs
Definition: daosFsCommon.h:15
daosFsCommon::getStat
std::unique_ptr< const genericStat > getStat(const std::string &path, bool followLink) override
Definition: daosFsCommon.cpp:68
daosFsCommon::pathMap
std::map< std::string, dfs_obj_t * > pathMap
Definition: daosFsCommon.h:17
daosFsCommon::daosOptions::containerName
options::single< std::string > containerName
Definition: daosFsCommon.h:23
timerInst
#define timerInst(subfunc)
Definition: timer.h:157
throwcall::good0
void good0(T call, const Args &... args)
template function to wrap system calls that return 0 on success
Definition: throwcall.h:40
daosFsCommon::daosOptions::sysName
options::single< std::string > sysName
Definition: daosFsCommon.h:25