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