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
6 #include "common/Clock.h"
7 #include "common/Timer.h"
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
18 /* Callback for delegation recalls */
19 typedef void (*ceph_deleg_cb_t
)(Fh
*fh
, void *priv
);
21 /* Converts CEPH_DELEGATION_* to cap mask */
22 int ceph_deleg_caps_for_type(unsigned type
);
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.
30 Delegation(Fh
*_fh
, unsigned _type
, ceph_deleg_cb_t _cb
, void *_priv
);
32 Fh
*get_fh() { return fh
; }
33 unsigned get_type() { return type
; }
34 bool is_recalled() { return !recall_time
.is_zero(); }
36 void reinit(unsigned _type
, ceph_deleg_cb_t _recall_cb
, void *_priv
);
37 void recall(bool skip_read
);
39 // Filehandle against which it was acquired
42 // opaque token that will be passed to the callback
45 // CEPH_DELEGATION_* type
48 // callback into application to recall delegation
49 ceph_deleg_cb_t recall_cb
;
51 // time of first recall
54 // timer for unreturned delegations
55 Context
*timeout_event
;
58 void disarm_timeout();
61 #endif /* _CEPH_CLIENT_DELEGATION_H */