]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #ifndef CEPH_OBJCLASS_H | |
5 | #define CEPH_OBJCLASS_H | |
6 | ||
7 | #ifdef __cplusplus | |
8 | ||
9 | #include "../include/types.h" | |
10 | #include "msg/msg_types.h" | |
11 | #include "common/hobject.h" | |
12 | #include "common/ceph_time.h" | |
9f95a23c | 13 | #include "common/ceph_releases.h" |
7c673cae FG |
14 | #include "include/rados/objclass.h" |
15 | ||
16 | struct obj_list_watch_response_t; | |
9f95a23c | 17 | class PGLSFilter; |
7c673cae | 18 | |
7c673cae FG |
19 | extern "C" { |
20 | #endif | |
21 | ||
22 | #define CLS_METHOD_PUBLIC 0x4 /// unused | |
23 | ||
24 | typedef void *cls_filter_handle_t; | |
25 | typedef int (*cls_method_call_t)(cls_method_context_t ctx, | |
26 | char *indata, int datalen, | |
27 | char **outdata, int *outdatalen); | |
28 | typedef struct { | |
29 | const char *name; | |
30 | const char *ver; | |
31 | } cls_deps_t; | |
32 | ||
33 | /* class utils */ | |
34 | extern void *cls_alloc(size_t size); | |
35 | extern void cls_free(void *p); | |
36 | ||
37 | extern int cls_read(cls_method_context_t hctx, int ofs, int len, | |
38 | char **outdata, int *outdatalen); | |
39 | extern int cls_call(cls_method_context_t hctx, const char *cls, const char *method, | |
40 | char *indata, int datalen, | |
41 | char **outdata, int *outdatalen); | |
42 | extern int cls_getxattr(cls_method_context_t hctx, const char *name, | |
43 | char **outdata, int *outdatalen); | |
44 | extern int cls_setxattr(cls_method_context_t hctx, const char *name, | |
45 | const char *value, int val_len); | |
46 | /** This will fill in the passed origin pointer with the origin of the | |
47 | * request which activated your class call. */ | |
48 | extern int cls_get_request_origin(cls_method_context_t hctx, | |
49 | entity_inst_t *origin); | |
50 | ||
51 | /* class registration api */ | |
52 | extern int cls_unregister(cls_handle_t); | |
53 | ||
54 | extern int cls_register_method(cls_handle_t hclass, const char *method, int flags, | |
55 | cls_method_call_t class_call, cls_method_handle_t *handle); | |
56 | extern int cls_unregister_method(cls_method_handle_t handle); | |
57 | extern void cls_unregister_filter(cls_filter_handle_t handle); | |
58 | ||
59 | ||
60 | ||
61 | /* triggers */ | |
62 | #define OBJ_READ 0x1 | |
63 | #define OBJ_WRITE 0x2 | |
64 | ||
65 | typedef int cls_trigger_t; | |
66 | ||
67 | extern int cls_link(cls_method_handle_t handle, int priority, cls_trigger_t trigger); | |
68 | extern int cls_unlink(cls_method_handle_t handle); | |
69 | ||
70 | ||
71 | /* should be defined by the class implementation | |
72 | defined here inorder to get it compiled without C++ mangling */ | |
73 | extern void class_init(void); | |
74 | extern void class_fini(void); | |
75 | ||
76 | #ifdef __cplusplus | |
77 | } | |
7c673cae FG |
78 | // Classes expose a filter constructor that returns a subclass of PGLSFilter |
79 | typedef PGLSFilter* (*cls_cxx_filter_factory_t)(); | |
80 | ||
81 | ||
82 | extern int cls_register_cxx_filter(cls_handle_t hclass, | |
83 | const std::string &filter_name, | |
84 | cls_cxx_filter_factory_t fn, | |
85 | cls_filter_handle_t *handle=NULL); | |
86 | ||
87 | extern int cls_cxx_stat2(cls_method_context_t hctx, uint64_t *size, ceph::real_time *mtime); | |
88 | extern int cls_cxx_read2(cls_method_context_t hctx, int ofs, int len, | |
9f95a23c | 89 | ceph::buffer::list *bl, uint32_t op_flags); |
7c673cae | 90 | extern int cls_cxx_write2(cls_method_context_t hctx, int ofs, int len, |
9f95a23c TL |
91 | ceph::buffer::list *bl, uint32_t op_flags); |
92 | extern int cls_cxx_write_full(cls_method_context_t hctx, ceph::buffer::list *bl); | |
93 | extern int cls_cxx_getxattrs(cls_method_context_t hctx, std::map<std::string, | |
94 | ceph::buffer::list> *attrset); | |
95 | extern int cls_cxx_replace(cls_method_context_t hctx, int ofs, int len, | |
96 | ceph::buffer::list *bl); | |
97 | extern int cls_cxx_truncate(cls_method_context_t hctx, int ofs); | |
98 | extern int cls_cxx_write_zero(cls_method_context_t hctx, int ofs, int len); | |
7c673cae FG |
99 | extern int cls_cxx_snap_revert(cls_method_context_t hctx, snapid_t snapid); |
100 | extern int cls_cxx_map_clear(cls_method_context_t hctx); | |
101 | extern int cls_cxx_map_get_all_vals(cls_method_context_t hctx, | |
9f95a23c | 102 | std::map<std::string, ceph::buffer::list> *vals, |
c07f9fc5 | 103 | bool *more); |
7c673cae | 104 | extern int cls_cxx_map_get_keys(cls_method_context_t hctx, |
9f95a23c | 105 | const std::string &start_after, |
7c673cae | 106 | uint64_t max_to_get, |
9f95a23c | 107 | std::set<std::string> *keys, |
c07f9fc5 | 108 | bool *more); |
7c673cae | 109 | extern int cls_cxx_map_get_vals(cls_method_context_t hctx, |
9f95a23c TL |
110 | const std::string& start_after, |
111 | const std::string& filter_prefix, | |
7c673cae | 112 | uint64_t max_to_get, |
9f95a23c | 113 | std::map<std::string, ceph::buffer::list> *vals, |
c07f9fc5 | 114 | bool *more); |
f67539c2 TL |
115 | extern int cls_cxx_map_get_val(cls_method_context_t hctx, const std::string &key, |
116 | bufferlist *outbl); | |
117 | extern int cls_cxx_map_get_vals_by_keys(cls_method_context_t hctx, | |
118 | const std::set<std::string> &keys, | |
119 | std::map<std::string, bufferlist> *map); | |
9f95a23c | 120 | extern int cls_cxx_map_read_header(cls_method_context_t hctx, ceph::buffer::list *outbl); |
7c673cae | 121 | extern int cls_cxx_map_set_vals(cls_method_context_t hctx, |
9f95a23c TL |
122 | const std::map<std::string, ceph::buffer::list> *map); |
123 | extern int cls_cxx_map_write_header(cls_method_context_t hctx, ceph::buffer::list *inbl); | |
124 | extern int cls_cxx_map_remove_key(cls_method_context_t hctx, const std::string &key); | |
125 | /* remove keys in the range [key_begin, key_end) */ | |
126 | extern int cls_cxx_map_remove_range(cls_method_context_t hctx, | |
127 | const std::string& key_begin, | |
128 | const std::string& key_end); | |
129 | extern int cls_cxx_map_update(cls_method_context_t hctx, ceph::buffer::list *inbl); | |
7c673cae FG |
130 | |
131 | extern int cls_cxx_list_watchers(cls_method_context_t hctx, | |
132 | obj_list_watch_response_t *watchers); | |
133 | ||
134 | /* utility functions */ | |
135 | extern int cls_gen_random_bytes(char *buf, int size); | |
136 | extern int cls_gen_rand_base64(char *dest, int size); /* size should be the required string size + 1 */ | |
137 | ||
138 | /* environment */ | |
139 | extern uint64_t cls_current_version(cls_method_context_t hctx); | |
140 | extern int cls_current_subop_num(cls_method_context_t hctx); | |
141 | extern uint64_t cls_get_features(cls_method_context_t hctx); | |
142 | extern uint64_t cls_get_client_features(cls_method_context_t hctx); | |
9f95a23c TL |
143 | extern ceph_release_t cls_get_required_osd_release(cls_method_context_t hctx); |
144 | extern ceph_release_t cls_get_min_compatible_client(cls_method_context_t hctx); | |
7c673cae FG |
145 | |
146 | /* helpers */ | |
9f95a23c | 147 | extern void cls_cxx_subop_version(cls_method_context_t hctx, std::string *s); |
7c673cae | 148 | |
11fdf7f2 TL |
149 | extern int cls_get_snapset_seq(cls_method_context_t hctx, uint64_t *snap_seq); |
150 | ||
20effc67 TL |
151 | /* gather */ |
152 | extern int cls_cxx_gather(cls_method_context_t hctx, const std::set<std::string> &src_objs, const std::string& pool, | |
153 | const char *cls, const char *method, bufferlist& inbl); | |
154 | ||
155 | extern int cls_cxx_get_gathered_data(cls_method_context_t hctx, std::map<std::string, bufferlist> *results); | |
156 | ||
7c673cae FG |
157 | /* These are also defined in rados.h and librados.h. Keep them in sync! */ |
158 | #define CEPH_OSD_TMAP_HDR 'h' | |
159 | #define CEPH_OSD_TMAP_SET 's' | |
160 | #define CEPH_OSD_TMAP_CREATE 'c' | |
161 | #define CEPH_OSD_TMAP_RM 'r' | |
162 | ||
11fdf7f2 | 163 | int cls_cxx_chunk_write_and_set(cls_method_context_t hctx, int ofs, int len, |
9f95a23c | 164 | ceph::buffer::list *write_inbl, uint32_t op_flags, ceph::buffer::list *set_inbl, |
11fdf7f2 | 165 | int set_len); |
f67539c2 | 166 | int cls_get_manifest_ref_count(cls_method_context_t hctx, std::string fp_oid); |
9f95a23c TL |
167 | |
168 | extern uint64_t cls_get_osd_min_alloc_size(cls_method_context_t hctx); | |
f67539c2 | 169 | extern uint64_t cls_get_pool_stripe_width(cls_method_context_t hctx); |
7c673cae FG |
170 | |
171 | #endif | |
172 | ||
173 | #endif |