vfs_ceph_new: common prefix to debug-log messages
[Samba.git] / source3 / include / g_lock.h
blobd6c1521a52c415548616d9800406f8437f63836c
1 /*
2 Unix SMB/CIFS implementation.
3 global locks based on dbwrap and messaging
4 Copyright (C) 2009 by Volker Lendecke
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _G_LOCK_H_
21 #define _G_LOCK_H_
23 #include "replace.h"
24 #include "librpc/gen_ndr/server_id.h"
25 #include "dbwrap/dbwrap.h"
27 struct g_lock_ctx;
28 struct g_lock_lock_cb_state;
29 struct messaging_context;
31 enum g_lock_type {
32 G_LOCK_READ,
33 G_LOCK_WRITE,
34 G_LOCK_UPGRADE,
35 G_LOCK_DOWNGRADE,
38 struct g_lock_ctx *g_lock_ctx_init_backend(
39 TALLOC_CTX *mem_ctx,
40 struct messaging_context *msg,
41 struct db_context **backend);
42 void g_lock_set_lock_order(struct g_lock_ctx *ctx,
43 enum dbwrap_lock_order lock_order);
44 struct g_lock_ctx *g_lock_ctx_init(TALLOC_CTX *mem_ctx,
45 struct messaging_context *msg);
47 typedef void (*g_lock_lock_cb_fn_t)(struct g_lock_lock_cb_state *glck,
48 void *cb_private);
50 NTSTATUS g_lock_lock_cb_dump(struct g_lock_lock_cb_state *glck,
51 void (*fn)(struct server_id exclusive,
52 size_t num_shared,
53 const struct server_id *shared,
54 const uint8_t *data,
55 size_t datalen,
56 void *private_data),
57 void *private_data);
58 NTSTATUS g_lock_lock_cb_writev(struct g_lock_lock_cb_state *glck,
59 const TDB_DATA *dbufs,
60 size_t num_dbufs);
61 void g_lock_lock_cb_unlock(struct g_lock_lock_cb_state *glck);
62 struct tevent_req *g_lock_lock_cb_watch_data_send(
63 TALLOC_CTX *mem_ctx,
64 struct tevent_context *ev,
65 struct g_lock_lock_cb_state *cb_state,
66 struct server_id blocker);
67 NTSTATUS g_lock_lock_cb_watch_data_recv(
68 struct tevent_req *req,
69 bool *blockerdead,
70 struct server_id *blocker);
71 void g_lock_lock_cb_wake_watchers(struct g_lock_lock_cb_state *cb_state);
73 struct tevent_req *g_lock_lock_send(TALLOC_CTX *mem_ctx,
74 struct tevent_context *ev,
75 struct g_lock_ctx *ctx,
76 TDB_DATA key,
77 enum g_lock_type type,
78 g_lock_lock_cb_fn_t cb_fn,
79 void *cb_private);
80 NTSTATUS g_lock_lock_recv(struct tevent_req *req);
81 NTSTATUS g_lock_lock(struct g_lock_ctx *ctx, TDB_DATA key,
82 enum g_lock_type lock_type, struct timeval timeout,
83 g_lock_lock_cb_fn_t cb_fn,
84 void *cb_private);
85 NTSTATUS g_lock_unlock(struct g_lock_ctx *ctx, TDB_DATA key);
87 NTSTATUS g_lock_writev_data(
88 struct g_lock_ctx *ctx,
89 TDB_DATA key,
90 const TDB_DATA *dbufs,
91 size_t num_dbufs);
92 NTSTATUS g_lock_write_data(struct g_lock_ctx *ctx, TDB_DATA key,
93 const uint8_t *buf, size_t buflen);
95 int g_lock_locks(struct g_lock_ctx *ctx,
96 int (*fn)(TDB_DATA key, void *private_data),
97 void *private_data);
98 struct tevent_req *g_lock_dump_send(
99 TALLOC_CTX *mem_ctx,
100 struct tevent_context *ev,
101 struct g_lock_ctx *ctx,
102 TDB_DATA key,
103 void (*fn)(struct server_id exclusive,
104 size_t num_shared,
105 const struct server_id *shared,
106 const uint8_t *data,
107 size_t datalen,
108 void *private_data),
109 void *private_data);
110 NTSTATUS g_lock_dump_recv(struct tevent_req *req);
111 NTSTATUS g_lock_dump(struct g_lock_ctx *ctx,
112 TDB_DATA key,
113 void (*fn)(struct server_id exclusive,
114 size_t num_shared,
115 const struct server_id *shared,
116 const uint8_t *data,
117 size_t datalen,
118 void *private_data),
119 void *private_data);
120 int g_lock_seqnum(struct g_lock_ctx *ctx);
122 struct tevent_req *g_lock_watch_data_send(
123 TALLOC_CTX *mem_ctx,
124 struct tevent_context *ev,
125 struct g_lock_ctx *ctx,
126 TDB_DATA key,
127 struct server_id blocker);
128 NTSTATUS g_lock_watch_data_recv(
129 struct tevent_req *req,
130 bool *blockerdead,
131 struct server_id *blocker);
132 void g_lock_wake_watchers(struct g_lock_ctx *ctx, TDB_DATA key);
134 #endif