]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | |
2 | ||
3 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- | |
4 | // vim: ts=8 sw=2 smarttab ft=cpp | |
5 | ||
6 | /* | |
7 | * Ceph - scalable distributed file system | |
8 | * | |
9 | * Copyright (C) 2019 Red Hat, Inc. | |
10 | * | |
11 | * This is free software; you can redistribute it and/or | |
12 | * modify it under the terms of the GNU Lesser General Public | |
13 | * License version 2.1, as published by the Free Software | |
14 | * Foundation. See file COPYING. | |
15 | * | |
16 | */ | |
17 | ||
18 | ||
19 | #pragma once | |
20 | ||
1e59de90 | 21 | #include "rgw_service.h" |
9f95a23c TL |
22 | |
23 | #include "svc_meta_be.h" | |
24 | #include "svc_sys_obj.h" | |
25 | ||
26 | ||
27 | class RGWSI_MBSObj_Handler_Module : public RGWSI_MetaBackend::Module { | |
28 | protected: | |
20effc67 | 29 | std::string section; |
9f95a23c | 30 | public: |
20effc67 | 31 | RGWSI_MBSObj_Handler_Module(const std::string& _section) : section(_section) {} |
9f95a23c TL |
32 | virtual void get_pool_and_oid(const std::string& key, rgw_pool *pool, std::string *oid) = 0; |
33 | virtual const std::string& get_oid_prefix() = 0; | |
34 | virtual std::string key_to_oid(const std::string& key) = 0; | |
35 | virtual bool is_valid_oid(const std::string& oid) = 0; | |
36 | virtual std::string oid_to_key(const std::string& oid) = 0; | |
37 | ||
38 | const std::string& get_section() { | |
39 | return section; | |
40 | } | |
41 | ||
42 | /* key to use for hashing entries for log shard placement */ | |
43 | virtual std::string get_hash_key(const std::string& key) { | |
44 | return section + ":" + key; | |
45 | } | |
46 | }; | |
47 | ||
48 | struct RGWSI_MBSObj_GetParams : public RGWSI_MetaBackend::GetParams { | |
49 | bufferlist *pbl{nullptr}; | |
20effc67 | 50 | std::map<std::string, bufferlist> *pattrs{nullptr}; |
9f95a23c TL |
51 | rgw_cache_entry_info *cache_info{nullptr}; |
52 | boost::optional<obj_version> refresh_version; | |
53 | ||
54 | RGWSI_MBSObj_GetParams() {} | |
55 | RGWSI_MBSObj_GetParams(bufferlist *_pbl, | |
20effc67 | 56 | std::map<std::string, bufferlist> *_pattrs, |
9f95a23c TL |
57 | ceph::real_time *_pmtime) : RGWSI_MetaBackend::GetParams(_pmtime), |
58 | pbl(_pbl), | |
59 | pattrs(_pattrs) {} | |
60 | ||
61 | RGWSI_MBSObj_GetParams& set_cache_info(rgw_cache_entry_info *_cache_info) { | |
62 | cache_info = _cache_info; | |
63 | return *this; | |
64 | } | |
65 | RGWSI_MBSObj_GetParams& set_refresh_version(boost::optional<obj_version>& _refresh_version) { | |
66 | refresh_version = _refresh_version; | |
67 | return *this; | |
68 | } | |
69 | }; | |
70 | ||
71 | struct RGWSI_MBSObj_PutParams : public RGWSI_MetaBackend::PutParams { | |
72 | bufferlist bl; | |
20effc67 | 73 | std::map<std::string, bufferlist> *pattrs{nullptr}; |
9f95a23c TL |
74 | bool exclusive{false}; |
75 | ||
76 | RGWSI_MBSObj_PutParams() {} | |
20effc67 | 77 | RGWSI_MBSObj_PutParams(std::map<std::string, bufferlist> *_pattrs, |
9f95a23c TL |
78 | const ceph::real_time& _mtime) : RGWSI_MetaBackend::PutParams(_mtime), |
79 | pattrs(_pattrs) {} | |
80 | RGWSI_MBSObj_PutParams(bufferlist& _bl, | |
20effc67 | 81 | std::map<std::string, bufferlist> *_pattrs, |
9f95a23c TL |
82 | const ceph::real_time& _mtime, |
83 | bool _exclusive) : RGWSI_MetaBackend::PutParams(_mtime), | |
84 | bl(_bl), | |
85 | pattrs(_pattrs), | |
86 | exclusive(_exclusive) {} | |
87 | }; | |
88 | ||
89 | struct RGWSI_MBSObj_RemoveParams : public RGWSI_MetaBackend::RemoveParams { | |
90 | }; | |
91 | ||
92 | class RGWSI_MetaBackend_SObj : public RGWSI_MetaBackend | |
93 | { | |
94 | protected: | |
95 | RGWSI_SysObj *sysobj_svc{nullptr}; | |
96 | ||
97 | public: | |
98 | struct Context_SObj : public RGWSI_MetaBackend::Context { | |
9f95a23c | 99 | RGWSI_MBSObj_Handler_Module *module{nullptr}; |
9f95a23c TL |
100 | struct _list { |
101 | std::optional<RGWSI_SysObj::Pool> pool; | |
102 | std::optional<RGWSI_SysObj::Pool::Op> op; | |
103 | } list; | |
104 | ||
9f95a23c TL |
105 | void init(RGWSI_MetaBackend_Handler *h) override; |
106 | }; | |
107 | ||
108 | RGWSI_MetaBackend_SObj(CephContext *cct); | |
109 | virtual ~RGWSI_MetaBackend_SObj(); | |
110 | ||
111 | RGWSI_MetaBackend::Type get_type() { | |
112 | return MDBE_SOBJ; | |
113 | } | |
114 | ||
115 | void init(RGWSI_SysObj *_sysobj_svc, | |
116 | RGWSI_MDLog *_mdlog_svc) { | |
117 | base_init(_mdlog_svc); | |
118 | sysobj_svc = _sysobj_svc; | |
119 | } | |
120 | ||
121 | RGWSI_MetaBackend_Handler *alloc_be_handler() override; | |
122 | RGWSI_MetaBackend::Context *alloc_ctx() override; | |
123 | ||
124 | ||
125 | int call_with_get_params(ceph::real_time *pmtime, std::function<int(RGWSI_MetaBackend::GetParams&)> cb) override; | |
126 | ||
b3b6e05e TL |
127 | int pre_modify(const DoutPrefixProvider *dpp, |
128 | RGWSI_MetaBackend::Context *ctx, | |
20effc67 | 129 | const std::string& key, |
9f95a23c TL |
130 | RGWMetadataLogData& log_data, |
131 | RGWObjVersionTracker *objv_tracker, | |
132 | RGWMDLogStatus op_type, | |
133 | optional_yield y); | |
b3b6e05e TL |
134 | int post_modify(const DoutPrefixProvider *dpp, |
135 | RGWSI_MetaBackend::Context *ctx, | |
20effc67 | 136 | const std::string& key, |
9f95a23c TL |
137 | RGWMetadataLogData& log_data, |
138 | RGWObjVersionTracker *objv_tracker, int ret, | |
139 | optional_yield y); | |
140 | ||
141 | int get_entry(RGWSI_MetaBackend::Context *ctx, | |
20effc67 | 142 | const std::string& key, |
9f95a23c TL |
143 | RGWSI_MetaBackend::GetParams& params, |
144 | RGWObjVersionTracker *objv_tracker, | |
b3b6e05e | 145 | optional_yield y, |
39ae355f TL |
146 | const DoutPrefixProvider *dpp, |
147 | bool get_raw_attrs=false) override; | |
b3b6e05e TL |
148 | int put_entry(const DoutPrefixProvider *dpp, |
149 | RGWSI_MetaBackend::Context *ctx, | |
20effc67 | 150 | const std::string& key, |
9f95a23c TL |
151 | RGWSI_MetaBackend::PutParams& params, |
152 | RGWObjVersionTracker *objv_tracker, | |
153 | optional_yield y) override; | |
b3b6e05e TL |
154 | int remove_entry(const DoutPrefixProvider *dpp, |
155 | RGWSI_MetaBackend::Context *ctx, | |
20effc67 | 156 | const std::string& key, |
9f95a23c TL |
157 | RGWSI_MetaBackend::RemoveParams& params, |
158 | RGWObjVersionTracker *objv_tracker, | |
159 | optional_yield y) override; | |
160 | ||
20effc67 TL |
161 | int list_init(const DoutPrefixProvider *dpp, RGWSI_MetaBackend::Context *_ctx, const std::string& marker) override; |
162 | int list_next(const DoutPrefixProvider *dpp, | |
163 | RGWSI_MetaBackend::Context *_ctx, | |
164 | int max, std::list<std::string> *keys, | |
9f95a23c TL |
165 | bool *truncated) override; |
166 | int list_get_marker(RGWSI_MetaBackend::Context *ctx, | |
20effc67 | 167 | std::string *marker) override; |
9f95a23c TL |
168 | |
169 | int get_shard_id(RGWSI_MetaBackend::Context *ctx, | |
170 | const std::string& key, | |
171 | int *shard_id) override; | |
172 | ||
173 | int call(std::optional<RGWSI_MetaBackend_CtxParams> opt, | |
174 | std::function<int(RGWSI_MetaBackend::Context *)> f) override; | |
175 | }; | |
176 | ||
177 | ||
178 | class RGWSI_MetaBackend_Handler_SObj : public RGWSI_MetaBackend_Handler { | |
179 | friend class RGWSI_MetaBackend_SObj::Context_SObj; | |
180 | ||
181 | RGWSI_MBSObj_Handler_Module *module{nullptr}; | |
182 | ||
183 | public: | |
184 | RGWSI_MetaBackend_Handler_SObj(RGWSI_MetaBackend *be) : | |
185 | RGWSI_MetaBackend_Handler(be) {} | |
186 | ||
187 | void set_module(RGWSI_MBSObj_Handler_Module *_module) { | |
188 | module = _module; | |
189 | } | |
190 | ||
191 | RGWSI_MBSObj_Handler_Module *get_module() { | |
192 | return module; | |
193 | } | |
194 | }; |