ewmscp  ..
inputHandlerGpfs.cpp
Go to the documentation of this file.
1 #include "inputHandlerGpfs.h"
2 #include "block.h"
3 #include "copyRequestTypes.h"
4 #include "ewmscp.h"
5 #include "timer.h"
6 
7 #include <fcntl.h>
8 #include <throwcall.h>
9 #include <unistd.h>
10 
11 #include <memory>
12 
13 namespace inputHandler {
14  decltype(Gpfs::factory) Gpfs::factory("Gpfs");
15  std::unique_ptr<base::reader> Gpfs::newReader(const std::string& aPath,
17  const genericStat& inititalStat) {
18  return std::unique_ptr<base::reader>(new readerGpfs(aPath,
19  state,
20  inititalStat));
21  }
22  static options::single<bool> useRange('\0', "gpfsInUseRange", "use range hint in gpfs input", false);
23  static options::single<bool> freeRange('\0', "gpfsInFreeRange", "use range free in gpfs input", false);
24  static options::single<bool> doClearCache('\0', "gpfsInClearCache", "clear cache in gpfs input", false);
25 
26 
27  Gpfs::readerGpfs::readerGpfs(const std::string& aPath,
29  const genericStat&inititalStat):
30  posixFileIoCommon(aPath),
31  gpfsIoCommon(aPath),
32  posixFile::readerPosixFile(aPath, state, inititalStat) {
33  if (fd != -1 && useRange) { // we have an open file
34  gpfs_fcntl_handler fcntl;
35  auto& range = fcntl.buffer.add<gpfsAccessRange_t>(GPFS_ACCESS_RANGE);
36  range.start = 0;
37  range.length = inititalStat.size;
38  range.isWrite = 0;
39  timerInst(gpfsAccessRange);
40  fcntl.call(fd, path);
41  }
42  }
44  if (fd != -1 && doClearCache) { // we have an open file
45  gpfs_fcntl_handler fcntl;
46  fcntl.buffer.add<gpfsClearFileCache_t>(GPFS_CLEAR_FILE_CACHE);
47  timerInst(gpfsClearFileCache);
48  fcntl.call(fd, path);
49  }
50  }
51 
52  std::unique_ptr<acl::list> Gpfs::getAclData(const std::string& path) {
53  gpfs_acl_handler aclHandler;
54  aclHandler.get(-1, path);
55  return gpfsIoCommon::aclFromGpfs(aclHandler, path);
56  };
57 
59  auto lastblock = readerPosixFile::readBlock(b);
60  // we read sequentially anyway so keep tracking simple
61  leastRecentlyAccessedBlock = b.offset();
62  if (freeRange) {
63  releaseUsedBlocks(b.max_size());
64  }
65  return lastblock;
66  };
67  void Gpfs::readerGpfs::readBlockP(block& b, size_t bytesToRead, off_t offset) {
68  readerPosixFile::readBlockP(b, bytesToRead, offset);
69  if (freeRange) {
70  handleParallelUsedBlocks(b.max_size(), offset);
71  }
72  };
73 
74 } //end namespace inputHandler
block.h
inputHandler::posixFile::readerPosixFile::readBlock
bool readBlock(block &b) override
read one block from the file
Definition: inputHandlerPosixFile.cpp:154
inputHandler::posixFile::readerPosixFile::readBlockP
void readBlockP(block &b, size_t bytesToRead, off_t offset) override
read one block from the file, starting at offset.
Definition: inputHandlerPosixFile.cpp:226
block::max_size
size_t max_size() const
Definition: block.h:22
inputHandler::Gpfs::newReader
std::unique_ptr< reader > newReader(const std::string &aPath, copyRequest::stateType &state, const genericStat &inititalStat) override
get a reader for the file at path
Definition: inputHandlerGpfs.cpp:15
inputHandler::useRange
static options::single< bool > useRange('\0', "gpfsInUseRange", "use range hint in gpfs input", false)
inputHandler
Definition: inputHandler.h:29
block::offset
size_t offset() const
Definition: block.h:25
options::single< bool >
class specialisation for options of type bool
Definition: Options.h:595
genericStat
generic stat abstraction class Used to abstract the variants of the stat structure.
Definition: genericStat.h:12
inputHandler::Gpfs::factory
static factoryTemplate< Gpfs > factory
Definition: inputHandlerGpfs.h:15
copyRequestTypes.h
gpfsIoCommon
Definition: gpfsCommon.h:8
posixFileIoCommon::fd
int fd
Definition: posixFileCommon.h:21
gpfs_acl_handler
class for handling non-opaque gpfs acls
Definition: gpfsFcntlHandler.h:33
gpfsIoCommon::aclFromGpfs
static std::unique_ptr< acl::list > aclFromGpfs(const gpfs_acl_handler &acl, const std::string &aPath)
Definition: gpfsCommon.cpp:83
copyRequest::stateType
Definition: copyRequestTypes.h:66
inputHandler::Gpfs::readerGpfs::readerGpfs
readerGpfs(const std::string &aPath, copyRequest::stateType &state, const genericStat &inititalStat)
Definition: inputHandlerGpfs.cpp:27
gpfs_fcntl_handler
class for handling gpfs_fcnt calls with their very special parameter handling
Definition: gpfsFcntlHandler.h:6
inputHandler::Gpfs::getAclData
std::unique_ptr< acl::list > getAclData(const std::string &path) override
Definition: inputHandlerGpfs.cpp:52
inputHandler::posixFile::readerPosixFile
Definition: inputHandlerPosixFile.h:44
gpfs_acl_handler::get
void get(int fd, const std::string &path)
Definition: gpfsFcntlHandler.cpp:99
genericStat::size
size_t size
Definition: genericStat.h:16
inputHandlerGpfs.h
inputHandler::Gpfs::readerGpfs::readBlockP
void readBlockP(block &b, size_t bytesToRead, off_t offset) override
read one block from the file, starting at offset.
Definition: inputHandlerGpfs.cpp:67
timer.h
throwcall.h
block
data block, used to hold the data that are being copied (or checksummed).
Definition: block.h:7
inputHandler::posixFile
Definition: inputHandlerPosixFile.h:15
gpfs_fcntl_handler::buffer
union gpfs_fcntl_handler::@2 buffer
inputHandler::freeRange
static options::single< bool > freeRange('\0', "gpfsInFreeRange", "use range free in gpfs input", false)
timerInst
#define timerInst(subfunc)
Definition: timer.h:157
posixFileIoCommon
base class for posixFile reader and writer class with the common stuff like fd, path and xattr handli...
Definition: posixFileCommon.h:17
gpfs_fcntl_handler::call
void call(int fd, const std::string &path)
Definition: gpfsFcntlHandler.cpp:15
inputHandler::Gpfs::readerGpfs
Definition: inputHandlerGpfs.h:17
inputHandler::doClearCache
static options::single< bool > doClearCache('\0', "gpfsInClearCache", "clear cache in gpfs input", false)
inputHandler::Gpfs::readerGpfs::~readerGpfs
~readerGpfs() override
Definition: inputHandlerGpfs.cpp:43
inputHandler::Gpfs::readerGpfs::readBlock
bool readBlock(block &b) override
read one block from the file
Definition: inputHandlerGpfs.cpp:58
posixFileIoCommon::path
const std::string & path
Definition: posixFileCommon.h:20
ewmscp.h