]>
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
8 #include "include/types.h"
9 #include "include/rados/librados.hpp"
11 #include "cls/lock/cls_lock_types.h"
17 extern void lock(librados::ObjectWriteOperation
*rados_op
,
18 const std::string
& name
, ClsLockType type
,
19 const std::string
& cookie
, const std::string
& tag
,
20 const std::string
& description
, const utime_t
& duration
,
23 extern int lock(librados::IoCtx
*ioctx
,
24 const std::string
& oid
,
25 const std::string
& name
, ClsLockType type
,
26 const std::string
& cookie
, const std::string
& tag
,
27 const std::string
& description
, const utime_t
& duration
,
30 extern void unlock(librados::ObjectWriteOperation
*rados_op
,
31 const std::string
& name
, const std::string
& cookie
);
33 extern int unlock(librados::IoCtx
*ioctx
, const std::string
& oid
,
34 const std::string
& name
, const std::string
& cookie
);
36 extern int aio_unlock(librados::IoCtx
*ioctx
, const std::string
& oid
,
37 const std::string
& name
, const std::string
& cookie
,
38 librados::AioCompletion
*completion
);
40 extern void break_lock(librados::ObjectWriteOperation
*op
,
41 const std::string
& name
, const std::string
& cookie
,
42 const entity_name_t
& locker
);
44 extern int break_lock(librados::IoCtx
*ioctx
, const std::string
& oid
,
45 const std::string
& name
, const std::string
& cookie
,
46 const entity_name_t
& locker
);
48 extern int list_locks(librados::IoCtx
*ioctx
, const std::string
& oid
,
49 list
<std::string
> *locks
);
50 extern void get_lock_info_start(librados::ObjectReadOperation
*rados_op
,
51 const std::string
& name
);
52 extern int get_lock_info_finish(ceph::bufferlist::iterator
*out
,
53 map
<locker_id_t
, locker_info_t
> *lockers
,
54 ClsLockType
*type
, std::string
*tag
);
56 extern int get_lock_info(librados::IoCtx
*ioctx
, const std::string
& oid
,
57 const std::string
& name
,
58 map
<locker_id_t
, locker_info_t
> *lockers
,
59 ClsLockType
*type
, std::string
*tag
);
61 extern void assert_locked(librados::ObjectOperation
*rados_op
,
62 const std::string
& name
, ClsLockType type
,
63 const std::string
& cookie
,
64 const std::string
& tag
);
66 extern void set_cookie(librados::ObjectWriteOperation
*rados_op
,
67 const std::string
& name
, ClsLockType type
,
68 const std::string
& cookie
, const std::string
& tag
,
69 const std::string
& new_cookie
);
75 std::string description
;
81 Lock(const std::string
& _n
) : name(_n
), flags(0) {}
83 void set_cookie(const std::string
& c
) { cookie
= c
; }
84 void set_tag(const std::string
& t
) { tag
= t
; }
85 void set_description(const std::string
& desc
) { description
= desc
; }
86 void set_duration(const utime_t
& e
) { duration
= e
; }
87 void set_renew(bool renew
) {
89 flags
|= LOCK_FLAG_RENEW
;
91 flags
&= ~LOCK_FLAG_RENEW
;
95 void assert_locked_exclusive(librados::ObjectOperation
*rados_op
);
96 void assert_locked_shared(librados::ObjectOperation
*rados_op
);
98 /* ObjectWriteOperation */
99 void lock_exclusive(librados::ObjectWriteOperation
*ioctx
);
100 void lock_shared(librados::ObjectWriteOperation
*ioctx
);
101 void unlock(librados::ObjectWriteOperation
*ioctx
);
102 void break_lock(librados::ObjectWriteOperation
*ioctx
, const entity_name_t
& locker
);
105 int lock_exclusive(librados::IoCtx
*ioctx
, const std::string
& oid
);
106 int lock_shared(librados::IoCtx
*ioctx
, const std::string
& oid
);
107 int unlock(librados::IoCtx
*ioctx
, const std::string
& oid
);
108 int break_lock(librados::IoCtx
*ioctx
, const std::string
& oid
,
109 const entity_name_t
& locker
);