From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/client/Delegation.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/client/Delegation.h (limited to 'src/client/Delegation.h') diff --git a/src/client/Delegation.h b/src/client/Delegation.h new file mode 100644 index 000000000..d24a02487 --- /dev/null +++ b/src/client/Delegation.h @@ -0,0 +1,57 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +#ifndef _CEPH_CLIENT_DELEGATION_H +#define _CEPH_CLIENT_DELEGATION_H + +#include "common/Clock.h" +#include "common/Timer.h" +#include "include/cephfs/ceph_ll_client.h" + +/* Commands for manipulating delegation state */ +#ifndef CEPH_DELEGATION_NONE +# define CEPH_DELEGATION_NONE 0 +# define CEPH_DELEGATION_RD 1 +# define CEPH_DELEGATION_WR 2 +#endif + +/* Converts CEPH_DELEGATION_* to cap mask */ +int ceph_deleg_caps_for_type(unsigned type); + +/* + * A delegation is a container for holding caps on behalf of a client that + * wants to be able to rely on them until recalled. + */ +class Delegation { +public: + Delegation(Fh *_fh, unsigned _type, ceph_deleg_cb_t _cb, void *_priv); + ~Delegation(); + Fh *get_fh() { return fh; } + unsigned get_type() { return type; } + bool is_recalled() { return !recall_time.is_zero(); } + + void reinit(unsigned _type, ceph_deleg_cb_t _recall_cb, void *_priv); + void recall(bool skip_read); +private: + // Filehandle against which it was acquired + Fh *fh; + + // opaque token that will be passed to the callback + void *priv; + + // CEPH_DELEGATION_* type + unsigned type; + + // callback into application to recall delegation + ceph_deleg_cb_t recall_cb; + + // time of first recall + utime_t recall_time; + + // timer for unreturned delegations + Context *timeout_event; + + void arm_timeout(); + void disarm_timeout(); +}; + +#endif /* _CEPH_CLIENT_DELEGATION_H */ -- cgit v1.2.3