10#define DO_LOADSHED if (m_throttle.CheckLoadShed(m_loadshed)) \
14 m_throttle.PerformLoadShed(m_loadshed, host, port); \
15 m_eroute.Emsg("File", "Performing load-shed for client", m_connection_id.c_str()); \
16 error.setErrInfo(port, host.c_str()); \
17 return SFS_REDIRECT; \
20#define DO_THROTTLE(amount) \
22m_throttle.Apply(amount, 1, m_uid); \
24auto xtimer = m_throttle.StartIOTimer(m_uid, ok); \
26 error.setErrInfo(EMFILE, "I/O limit exceeded and wait time hit"); \
31File::File(
const char *user,
36#
if __cplusplus >= 201103L
37 m_sfs(std::move(sfs)),
42 m_connection_id(user ? user :
""),
55File::open(
const char *fileName,
61 std::tie(m_user, m_uid) = m_throttle.
GetUserInfo(client);
63 std::string open_error_message;
64 if (!m_throttle.
OpenFile(m_user, open_error_message)) {
65 error.setErrInfo(EMFILE, open_error_message.c_str());
68 auto retval = m_sfs->open(fileName, openMode, createMode, client, opaque);
82 return m_sfs->close();
85int File::checkpoint(
cpAct act,
struct iov *range,
int n)
86{
return m_sfs->checkpoint(act, range, n);}
89File::fctl(
const int cmd,
96 error.setErrInfo(ENOTSUP,
"Sendfile not supported by throttle plugin.");
99 else return m_sfs->fctl(cmd, args, out_error);
105 return m_sfs->FName();
109File::getMmap(
void **Addr, off_t &Size)
111 error.setErrInfo(ENOTSUP,
"Mmap not supported by throttle plugin.");
123 return m_sfs->pgRead(offset, buffer, rdlen, csvec,
opts);
145 return m_sfs->pgWrite(offset, buffer, rdlen, csvec,
opts);
164 return m_sfs->read(fileOffset, amount);
173 return m_sfs->read(fileOffset, buffer, buffer_size);
192 return m_sfs->write(fileOffset, buffer, buffer_size);
208 return m_sfs->sync();
214 return m_sfs->sync(aiop);
220 return m_sfs->stat(buf);
226 return m_sfs->truncate(fileOffset);
230File::getCXinfo(
char cxtype[4],
int &cxrsz)
232 return m_sfs->getCXinfo(cxtype, cxrsz);
241 return m_sfs->SendData(sfDio, offset, size);
long long XrdSfsFileOffset
#define DO_THROTTLE(amount)
virtual void doneRead()=0
virtual void doneWrite()=0
std::tuple< std::string, uint16_t > GetUserInfo(const XrdSecEntity *client)
void PrepLoadShed(const char *opaque, std::string &lsOpaque)
bool CloseFile(const std::string &entity)
bool OpenFile(const std::string &entity, std::string &open_error_message)
std::auto_ptr< XrdSfsFile > unique_sfs_ptr