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