1 #include "svc_sys_obj.h"
2 #include "svc_sys_obj_core.h"
6 #include "rgw/rgw_zone.h"
8 #define dout_subsys ceph_subsys_rgw
10 RGWSysObjectCtx
RGWSI_SysObj::init_obj_ctx()
12 return RGWSysObjectCtx(this);
15 RGWSI_SysObj::Obj
RGWSI_SysObj::get_obj(RGWSysObjectCtx
& obj_ctx
, const rgw_raw_obj
& obj
)
17 return Obj(core_svc
, obj_ctx
, obj
);
20 void RGWSI_SysObj::Obj::invalidate()
25 int RGWSI_SysObj::Obj::ROp::stat()
27 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
28 rgw_raw_obj
& obj
= source
.obj
;
30 return svc
->stat(source
.get_ctx(), state
, obj
,
36 int RGWSI_SysObj::Obj::ROp::read(int64_t ofs
, int64_t end
, bufferlist
*bl
)
38 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
39 rgw_raw_obj
& obj
= source
.get_obj();
41 return svc
->read(source
.get_ctx(), state
,
50 int RGWSI_SysObj::Obj::ROp::get_attr(const char *name
, bufferlist
*dest
)
52 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
53 rgw_raw_obj
& obj
= source
.get_obj();
55 return svc
->get_attr(obj
, name
, dest
);
58 int RGWSI_SysObj::Obj::WOp::remove()
60 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
61 rgw_raw_obj
& obj
= source
.get_obj();
63 return svc
->remove(source
.get_ctx(),
68 int RGWSI_SysObj::Obj::WOp::write(bufferlist
& bl
)
70 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
71 rgw_raw_obj
& obj
= source
.get_obj();
73 return svc
->write(obj
, pmtime
, attrs
, exclusive
,
74 bl
, objv_tracker
, mtime
);
77 int RGWSI_SysObj::Obj::WOp::write_data(bufferlist
& bl
)
79 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
80 rgw_raw_obj
& obj
= source
.get_obj();
82 return svc
->write_data(obj
, bl
, exclusive
, objv_tracker
);
85 int RGWSI_SysObj::Obj::WOp::write_attrs()
87 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
88 rgw_raw_obj
& obj
= source
.get_obj();
90 return svc
->set_attrs(obj
, attrs
, nullptr, objv_tracker
);
93 int RGWSI_SysObj::Obj::WOp::write_attr(const char *name
, bufferlist
& bl
)
95 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
96 rgw_raw_obj
& obj
= source
.get_obj();
98 map
<string
, bufferlist
> m
;
101 return svc
->set_attrs(obj
, m
, nullptr, objv_tracker
);
104 int RGWSI_SysObj::Pool::Op::list_prefixed_objs(const string
& prefix
, list
<string
> *result
)
108 auto rados_pool
= source
.rados_svc
->pool(source
.pool
);
110 auto op
= rados_pool
.op();
112 RGWAccessListFilterPrefix
filter(prefix
);
114 int r
= op
.init(string(), &filter
);
121 #define MAX_OBJS_DEFAULT 1000
122 int r
= op
.get_next(MAX_OBJS_DEFAULT
, &oids
, &is_truncated
);
126 for (auto& val
: oids
) {
127 if (val
.size() > prefix
.size()) {
128 result
->push_back(val
.substr(prefix
.size()));
131 } while (is_truncated
);
136 int RGWSI_SysObj::Obj::OmapOp::get_all(std::map
<string
, bufferlist
> *m
)
138 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
139 rgw_raw_obj
& obj
= source
.obj
;
141 return svc
->omap_get_all(obj
, m
);
144 int RGWSI_SysObj::Obj::OmapOp::get_vals(const string
& marker
,
146 std::map
<string
, bufferlist
> *m
,
149 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
150 rgw_raw_obj
& obj
= source
.obj
;
152 return svc
->omap_get_vals(obj
, marker
, count
, m
, pmore
);
155 int RGWSI_SysObj::Obj::OmapOp::set(const std::string
& key
, bufferlist
& bl
)
157 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
158 rgw_raw_obj
& obj
= source
.obj
;
160 return svc
->omap_set(obj
, key
, bl
, must_exist
);
163 int RGWSI_SysObj::Obj::OmapOp::set(const map
<std::string
, bufferlist
>& m
)
165 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
166 rgw_raw_obj
& obj
= source
.obj
;
168 return svc
->omap_set(obj
, m
, must_exist
);
171 int RGWSI_SysObj::Obj::OmapOp::del(const std::string
& key
)
173 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
174 rgw_raw_obj
& obj
= source
.obj
;
176 return svc
->omap_del(obj
, key
);
179 int RGWSI_SysObj::Obj::WNOp::notify(bufferlist
& bl
,
183 RGWSI_SysObj_Core
*svc
= source
.core_svc
;
184 rgw_raw_obj
& obj
= source
.obj
;
186 return svc
->notify(obj
, bl
, timeout_ms
, pbl
);
189 RGWSI_Zone
*RGWSI_SysObj::get_zone_svc()
191 return core_svc
->get_zone_svc();