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