]>
git.proxmox.com Git - ceph.git/blob - ceph/src/cls/lock/cls_lock_types.h
1 #ifndef CEPH_CLS_LOCK_TYPES_H
2 #define CEPH_CLS_LOCK_TYPES_H
4 #include "include/encoding.h"
5 #include "include/types.h"
6 #include "include/utime.h"
7 #include "msg/msg_types.h"
10 #define LOCK_FLAG_RENEW 0x1 /* idempotent lock acquire */
18 static inline const char *cls_lock_type_str(ClsLockType type
)
37 * locker_id_t: the locker id, needs to be unique in a single lock
40 entity_name_t locker
; // locker's client name
41 string cookie
; // locker's cookie.
44 locker_id_t(entity_name_t
& _n
, const string
& _c
) : locker(_n
), cookie(_c
) {}
46 void encode(bufferlist
&bl
) const {
47 ENCODE_START(1, 1, bl
);
52 void decode(bufferlist::iterator
&bl
) {
53 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl
);
59 bool operator<(const locker_id_t
& rhs
) const {
60 if (locker
== rhs
.locker
)
61 return cookie
.compare(rhs
.cookie
) < 0;
62 if (locker
< rhs
.locker
)
66 void dump(Formatter
*f
) const;
67 static void generate_test_instances(list
<locker_id_t
*>& o
);
69 WRITE_CLASS_ENCODER(rados::cls::lock::locker_id_t
)
73 utime_t expiration
; // expiration: non-zero means epoch of locker expiration
74 entity_addr_t addr
; // addr: locker address
75 string description
; // description: locker description, may be empty
78 locker_info_t(const utime_t
& _e
, const entity_addr_t
& _a
,
79 const string
& _d
) : expiration(_e
), addr(_a
), description(_d
) {}
81 void encode(bufferlist
&bl
, uint64_t features
) const {
82 ENCODE_START(1, 1, bl
);
83 ::encode(expiration
, bl
);
84 ::encode(addr
, bl
, features
);
85 ::encode(description
, bl
);
88 void decode(bufferlist::iterator
&bl
) {
89 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl
);
90 ::decode(expiration
, bl
);
92 ::decode(description
, bl
);
95 void dump(Formatter
*f
) const;
96 static void generate_test_instances(list
<locker_info_t
*>& o
);
98 WRITE_CLASS_ENCODER_FEATURES(rados::cls::lock::locker_info_t
)
101 map
<locker_id_t
, locker_info_t
> lockers
; // map of lockers
102 ClsLockType lock_type
; // lock type (exclusive / shared)
103 string tag
; // tag: operations on lock can only succeed with this tag
104 // as long as set of non expired lockers
107 void encode(bufferlist
&bl
, uint64_t features
) const {
108 ENCODE_START(1, 1, bl
);
109 ::encode(lockers
, bl
, features
);
110 uint8_t t
= (uint8_t)lock_type
;
115 void decode(bufferlist::iterator
&bl
) {
116 DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl
);
117 ::decode(lockers
, bl
);
120 lock_type
= (ClsLockType
)t
;
124 lock_info_t() : lock_type(LOCK_NONE
) {}
125 void dump(Formatter
*f
) const;
126 static void generate_test_instances(list
<lock_info_t
*>& o
);
128 WRITE_CLASS_ENCODER_FEATURES(rados::cls::lock::lock_info_t
)
132 WRITE_CLASS_ENCODER_FEATURES(rados::cls::lock::locker_info_t
)
133 WRITE_CLASS_ENCODER(rados::cls::lock::locker_id_t
)
134 WRITE_CLASS_ENCODER_FEATURES(rados::cls::lock::lock_info_t
)