]> git.proxmox.com Git - ceph.git/blob - ceph/src/client/Delegation.h
update sources to 12.2.8
[ceph.git] / ceph / src / client / Delegation.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #ifndef _CEPH_CLIENT_DELEGATION_H
4 #define _CEPH_CLIENT_DELEGATION_H
5
6 #include "common/Clock.h"
7 #include "common/Timer.h"
8
9 class Fh;
10
11 /* Commands for manipulating delegation state */
12 #ifndef CEPH_DELEGATION_NONE
13 # define CEPH_DELEGATION_NONE 0
14 # define CEPH_DELEGATION_RD 1
15 # define CEPH_DELEGATION_WR 2
16 #endif
17
18 /* Callback for delegation recalls */
19 typedef void (*ceph_deleg_cb_t)(Fh *fh, void *priv);
20
21 /* Converts CEPH_DELEGATION_* to cap mask */
22 int ceph_deleg_caps_for_type(unsigned type);
23
24 /*
25 * A delegation is a container for holding caps on behalf of a client that
26 * wants to be able to rely on them until recalled.
27 */
28 class Delegation {
29 public:
30 Delegation(Fh *_fh, unsigned _type, ceph_deleg_cb_t _cb, void *_priv);
31 ~Delegation();
32 Fh *get_fh() { return fh; }
33 unsigned get_type() { return type; }
34 bool is_recalled() { return !recall_time.is_zero(); }
35
36 void reinit(unsigned _type, ceph_deleg_cb_t _recall_cb, void *_priv);
37 void recall(bool skip_read);
38 private:
39 // Filehandle against which it was acquired
40 Fh *fh;
41
42 // opaque token that will be passed to the callback
43 void *priv;
44
45 // CEPH_DELEGATION_* type
46 unsigned type;
47
48 // callback into application to recall delegation
49 ceph_deleg_cb_t recall_cb;
50
51 // time of first recall
52 utime_t recall_time;
53
54 // timer for unreturned delegations
55 Context *timeout_event;
56
57 void arm_timeout();
58 void disarm_timeout();
59 };
60
61 #endif /* _CEPH_CLIENT_DELEGATION_H */