]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/services/svc_sys_obj.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / rgw / services / svc_sys_obj.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 #include "svc_sys_obj.h"
5 #include "svc_sys_obj_core.h"
6 #include "svc_rados.h"
7 #include "svc_zone.h"
8
9 #include "rgw/rgw_zone.h"
10
11 #define dout_subsys ceph_subsys_rgw
12
13 using namespace std;
14
15 RGWSysObjectCtx RGWSI_SysObj::init_obj_ctx()
16 {
17 return RGWSysObjectCtx(this);
18 }
19
20 RGWSI_SysObj::Obj RGWSI_SysObj::get_obj(RGWSysObjectCtx& obj_ctx, const rgw_raw_obj& obj)
21 {
22 return Obj(core_svc, obj_ctx, obj);
23 }
24
25 void RGWSI_SysObj::Obj::invalidate()
26 {
27 ctx.invalidate(obj);
28 }
29
30 RGWSI_SysObj::Obj::ROp::ROp(Obj& _source) : source(_source) {
31 state.emplace<RGWSI_SysObj_Core::GetObjState>();
32 }
33
34 int RGWSI_SysObj::Obj::ROp::stat(optional_yield y, const DoutPrefixProvider *dpp)
35 {
36 RGWSI_SysObj_Core *svc = source.core_svc;
37 rgw_raw_obj& obj = source.obj;
38
39 return svc->stat(source.get_ctx(), *state, obj,
40 attrs, raw_attrs,
41 lastmod, obj_size,
42 objv_tracker, y, dpp);
43 }
44
45 int RGWSI_SysObj::Obj::ROp::read(const DoutPrefixProvider *dpp,
46 int64_t ofs, int64_t end, bufferlist *bl,
47 optional_yield y)
48 {
49 RGWSI_SysObj_Core *svc = source.core_svc;
50 rgw_raw_obj& obj = source.get_obj();
51
52 return svc->read(dpp, source.get_ctx(), *state,
53 objv_tracker,
54 obj, bl, ofs, end,
55 attrs,
56 raw_attrs,
57 cache_info,
58 refresh_version, y);
59 }
60
61 int RGWSI_SysObj::Obj::ROp::get_attr(const DoutPrefixProvider *dpp,
62 const char *name, bufferlist *dest,
63 optional_yield y)
64 {
65 RGWSI_SysObj_Core *svc = source.core_svc;
66 rgw_raw_obj& obj = source.get_obj();
67
68 return svc->get_attr(dpp, obj, name, dest, y);
69 }
70
71 int RGWSI_SysObj::Obj::WOp::remove(const DoutPrefixProvider *dpp, optional_yield y)
72 {
73 RGWSI_SysObj_Core *svc = source.core_svc;
74 rgw_raw_obj& obj = source.get_obj();
75
76 return svc->remove(dpp, source.get_ctx(),
77 objv_tracker,
78 obj, y);
79 }
80
81 int RGWSI_SysObj::Obj::WOp::write(const DoutPrefixProvider *dpp, bufferlist& bl, optional_yield y)
82 {
83 RGWSI_SysObj_Core *svc = source.core_svc;
84 rgw_raw_obj& obj = source.get_obj();
85
86 return svc->write(dpp, obj, pmtime, attrs, exclusive,
87 bl, objv_tracker, mtime, y);
88 }
89
90 int RGWSI_SysObj::Obj::WOp::write_data(const DoutPrefixProvider *dpp, bufferlist& bl, optional_yield y)
91 {
92 RGWSI_SysObj_Core *svc = source.core_svc;
93 rgw_raw_obj& obj = source.get_obj();
94
95 return svc->write_data(dpp, obj, bl, exclusive, objv_tracker, y);
96 }
97
98 int RGWSI_SysObj::Obj::WOp::write_attrs(const DoutPrefixProvider *dpp, optional_yield y)
99 {
100 RGWSI_SysObj_Core *svc = source.core_svc;
101 rgw_raw_obj& obj = source.get_obj();
102
103 return svc->set_attrs(dpp, obj, attrs, nullptr, objv_tracker, y);
104 }
105
106 int RGWSI_SysObj::Obj::WOp::write_attr(const DoutPrefixProvider *dpp, const char *name, bufferlist& bl,
107 optional_yield y)
108 {
109 RGWSI_SysObj_Core *svc = source.core_svc;
110 rgw_raw_obj& obj = source.get_obj();
111
112 map<string, bufferlist> m;
113 m[name] = bl;
114
115 return svc->set_attrs(dpp, obj, m, nullptr, objv_tracker, y);
116 }
117
118 int RGWSI_SysObj::Pool::list_prefixed_objs(const DoutPrefixProvider *dpp, const string& prefix, std::function<void(const string&)> cb)
119 {
120 return core_svc->pool_list_prefixed_objs(dpp, pool, prefix, cb);
121 }
122
123 int RGWSI_SysObj::Pool::Op::init(const DoutPrefixProvider *dpp, const string& marker, const string& prefix)
124 {
125 return source.core_svc->pool_list_objects_init(dpp, source.pool, marker, prefix, &ctx);
126 }
127
128 int RGWSI_SysObj::Pool::Op::get_next(const DoutPrefixProvider *dpp, int max, vector<string> *oids, bool *is_truncated)
129 {
130 return source.core_svc->pool_list_objects_next(dpp, ctx, max, oids, is_truncated);
131 }
132
133 int RGWSI_SysObj::Pool::Op::get_marker(string *marker)
134 {
135 return source.core_svc->pool_list_objects_get_marker(ctx, marker);
136 }
137
138 int RGWSI_SysObj::Obj::OmapOp::get_all(const DoutPrefixProvider *dpp, std::map<string, bufferlist> *m,
139 optional_yield y)
140 {
141 RGWSI_SysObj_Core *svc = source.core_svc;
142 rgw_raw_obj& obj = source.obj;
143
144 return svc->omap_get_all(dpp, obj, m, y);
145 }
146
147 int RGWSI_SysObj::Obj::OmapOp::get_vals(const DoutPrefixProvider *dpp,
148 const string& marker, uint64_t count,
149 std::map<string, bufferlist> *m,
150 bool *pmore, optional_yield y)
151 {
152 RGWSI_SysObj_Core *svc = source.core_svc;
153 rgw_raw_obj& obj = source.obj;
154
155 return svc->omap_get_vals(dpp, obj, marker, count, m, pmore, y);
156 }
157
158 int RGWSI_SysObj::Obj::OmapOp::set(const DoutPrefixProvider *dpp, const std::string& key, bufferlist& bl,
159 optional_yield y)
160 {
161 RGWSI_SysObj_Core *svc = source.core_svc;
162 rgw_raw_obj& obj = source.obj;
163
164 return svc->omap_set(dpp, obj, key, bl, must_exist, y);
165 }
166
167 int RGWSI_SysObj::Obj::OmapOp::set(const DoutPrefixProvider *dpp, const map<std::string, bufferlist>& m,
168 optional_yield y)
169 {
170 RGWSI_SysObj_Core *svc = source.core_svc;
171 rgw_raw_obj& obj = source.obj;
172
173 return svc->omap_set(dpp, obj, m, must_exist, y);
174 }
175
176 int RGWSI_SysObj::Obj::OmapOp::del(const DoutPrefixProvider *dpp, const std::string& key, optional_yield y)
177 {
178 RGWSI_SysObj_Core *svc = source.core_svc;
179 rgw_raw_obj& obj = source.obj;
180
181 return svc->omap_del(dpp, obj, key, y);
182 }
183
184 int RGWSI_SysObj::Obj::WNOp::notify(const DoutPrefixProvider *dpp, bufferlist& bl, uint64_t timeout_ms,
185 bufferlist *pbl, optional_yield y)
186 {
187 RGWSI_SysObj_Core *svc = source.core_svc;
188 rgw_raw_obj& obj = source.obj;
189
190 return svc->notify(dpp, obj, bl, timeout_ms, pbl, y);
191 }
192
193 RGWSI_Zone *RGWSI_SysObj::get_zone_svc()
194 {
195 return core_svc->get_zone_svc();
196 }