]>
git.proxmox.com Git - ceph.git/blob - ceph/src/cls/lock/cls_lock_client.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_CLS_LOCK_CLIENT_H
5 #define CEPH_CLS_LOCK_CLIENT_H
7 #include "cls/lock/cls_lock_types.h"
11 class ObjectWriteOperation
;
13 class ObjectReadOperation
;
14 class ObjectOperation
;
20 extern void lock(librados::ObjectWriteOperation
*rados_op
,
21 const std::string
& name
, ClsLockType type
,
22 const std::string
& cookie
, const std::string
& tag
,
23 const std::string
& description
, const utime_t
& duration
,
26 extern int lock(librados::IoCtx
*ioctx
,
27 const std::string
& oid
,
28 const std::string
& name
, ClsLockType type
,
29 const std::string
& cookie
, const std::string
& tag
,
30 const std::string
& description
, const utime_t
& duration
,
33 extern void unlock(librados::ObjectWriteOperation
*rados_op
,
34 const std::string
& name
, const std::string
& cookie
);
36 extern int unlock(librados::IoCtx
*ioctx
, const std::string
& oid
,
37 const std::string
& name
, const std::string
& cookie
);
39 extern int aio_unlock(librados::IoCtx
*ioctx
, const std::string
& oid
,
40 const std::string
& name
, const std::string
& cookie
,
41 librados::AioCompletion
*completion
);
43 extern void break_lock(librados::ObjectWriteOperation
*op
,
44 const std::string
& name
, const std::string
& cookie
,
45 const entity_name_t
& locker
);
47 extern int break_lock(librados::IoCtx
*ioctx
, const std::string
& oid
,
48 const std::string
& name
, const std::string
& cookie
,
49 const entity_name_t
& locker
);
51 extern int list_locks(librados::IoCtx
*ioctx
, const std::string
& oid
,
52 list
<std::string
> *locks
);
53 extern void get_lock_info_start(librados::ObjectReadOperation
*rados_op
,
54 const std::string
& name
);
55 extern int get_lock_info_finish(ceph::bufferlist::iterator
*out
,
56 map
<locker_id_t
, locker_info_t
> *lockers
,
57 ClsLockType
*type
, std::string
*tag
);
59 extern int get_lock_info(librados::IoCtx
*ioctx
, const std::string
& oid
,
60 const std::string
& name
,
61 map
<locker_id_t
, locker_info_t
> *lockers
,
62 ClsLockType
*type
, std::string
*tag
);
64 extern void assert_locked(librados::ObjectOperation
*rados_op
,
65 const std::string
& name
, ClsLockType type
,
66 const std::string
& cookie
,
67 const std::string
& tag
);
69 extern void set_cookie(librados::ObjectWriteOperation
*rados_op
,
70 const std::string
& name
, ClsLockType type
,
71 const std::string
& cookie
, const std::string
& tag
,
72 const std::string
& new_cookie
);
78 std::string description
;
84 Lock(const std::string
& _n
) : name(_n
), flags(0) {}
86 void set_cookie(const std::string
& c
) { cookie
= c
; }
87 void set_tag(const std::string
& t
) { tag
= t
; }
88 void set_description(const std::string
& desc
) { description
= desc
; }
89 void set_duration(const utime_t
& e
) { duration
= e
; }
90 void set_renew(bool renew
) {
92 flags
|= LOCK_FLAG_RENEW
;
94 flags
&= ~LOCK_FLAG_RENEW
;
98 void assert_locked_exclusive(librados::ObjectOperation
*rados_op
);
99 void assert_locked_shared(librados::ObjectOperation
*rados_op
);
101 /* ObjectWriteOperation */
102 void lock_exclusive(librados::ObjectWriteOperation
*ioctx
);
103 void lock_shared(librados::ObjectWriteOperation
*ioctx
);
104 void unlock(librados::ObjectWriteOperation
*ioctx
);
105 void break_lock(librados::ObjectWriteOperation
*ioctx
, const entity_name_t
& locker
);
108 int lock_exclusive(librados::IoCtx
*ioctx
, const std::string
& oid
);
109 int lock_shared(librados::IoCtx
*ioctx
, const std::string
& oid
);
110 int unlock(librados::IoCtx
*ioctx
, const std::string
& oid
);
111 int break_lock(librados::IoCtx
*ioctx
, const std::string
& oid
,
112 const entity_name_t
& locker
);