]> git.proxmox.com Git - ceph.git/blob - ceph/src/client/Delegation.h
import 15.2.4
[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 #include "include/cephfs/ceph_ll_client.h"
9
10 /* Commands for manipulating delegation state */
11 #ifndef CEPH_DELEGATION_NONE
12 # define CEPH_DELEGATION_NONE 0
13 # define CEPH_DELEGATION_RD 1
14 # define CEPH_DELEGATION_WR 2
15 #endif
16
17 /* Converts CEPH_DELEGATION_* to cap mask */
18 int ceph_deleg_caps_for_type(unsigned type);
19
20 /*
21 * A delegation is a container for holding caps on behalf of a client that
22 * wants to be able to rely on them until recalled.
23 */
24 class Delegation {
25 public:
26 Delegation(Fh *_fh, unsigned _type, ceph_deleg_cb_t _cb, void *_priv);
27 ~Delegation();
28 Fh *get_fh() { return fh; }
29 unsigned get_type() { return type; }
30 bool is_recalled() { return !recall_time.is_zero(); }
31
32 void reinit(unsigned _type, ceph_deleg_cb_t _recall_cb, void *_priv);
33 void recall(bool skip_read);
34 private:
35 // Filehandle against which it was acquired
36 Fh *fh;
37
38 // opaque token that will be passed to the callback
39 void *priv;
40
41 // CEPH_DELEGATION_* type
42 unsigned type;
43
44 // callback into application to recall delegation
45 ceph_deleg_cb_t recall_cb;
46
47 // time of first recall
48 utime_t recall_time;
49
50 // timer for unreturned delegations
51 Context *timeout_event;
52
53 void arm_timeout();
54 void disarm_timeout();
55 };
56
57 #endif /* _CEPH_CLIENT_DELEGATION_H */