]>
git.proxmox.com Git - ceph.git/blob - ceph/src/cls/lock/cls_lock_types.h
03e6e11f69c1b3fdb1a9b1fd51d0deb05bceff5b
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
)
102 WRITE_CLASS_ENCODER_FEATURES(rados::cls::lock::locker_info_t
)
103 WRITE_CLASS_ENCODER(rados::cls::lock::locker_id_t
)