1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
6 #include "common/static_ptr.h"
8 #include "rgw_service.h"
10 #include "svc_rados.h"
11 #include "svc_sys_obj_types.h"
12 #include "svc_sys_obj_core_types.h"
18 struct rgw_cache_entry_info
;
20 class RGWSI_SysObj
: public RGWServiceInstance
22 friend struct RGWServices_Def
;
28 RGWSI_SysObj_Core
*core_svc
;
32 Obj(RGWSI_SysObj_Core
*_core_svc
, const rgw_raw_obj
& _obj
)
33 : core_svc(_core_svc
), obj(_obj
) {}
35 rgw_raw_obj
& get_obj() {
42 ceph::static_ptr
<RGWSI_SysObj_Obj_GetObjState
, sizeof(RGWSI_SysObj_Core_GetObjState
)> state
;
44 RGWObjVersionTracker
*objv_tracker
{nullptr};
45 std::map
<std::string
, bufferlist
> *attrs
{nullptr};
46 bool raw_attrs
{false};
47 boost::optional
<obj_version
> refresh_version
{boost::none
};
48 ceph::real_time
*lastmod
{nullptr};
49 uint64_t *obj_size
{nullptr};
50 rgw_cache_entry_info
*cache_info
{nullptr};
52 ROp
& set_objv_tracker(RGWObjVersionTracker
*_objv_tracker
) {
53 objv_tracker
= _objv_tracker
;
57 ROp
& set_last_mod(ceph::real_time
*_lastmod
) {
62 ROp
& set_obj_size(uint64_t *_obj_size
) {
67 ROp
& set_attrs(std::map
<std::string
, bufferlist
> *_attrs
) {
72 ROp
& set_raw_attrs(bool ra
) {
77 ROp
& set_refresh_version(boost::optional
<obj_version
>& rf
) {
82 ROp
& set_cache_info(rgw_cache_entry_info
*ci
) {
89 int stat(optional_yield y
, const DoutPrefixProvider
*dpp
);
90 int read(const DoutPrefixProvider
*dpp
, int64_t ofs
, int64_t end
, bufferlist
*pbl
, optional_yield y
);
91 int read(const DoutPrefixProvider
*dpp
, bufferlist
*pbl
, optional_yield y
) {
92 return read(dpp
, 0, -1, pbl
, y
);
94 int get_attr(const DoutPrefixProvider
*dpp
, const char *name
, bufferlist
*dest
, optional_yield y
);
100 RGWObjVersionTracker
*objv_tracker
{nullptr};
101 std::map
<std::string
, bufferlist
> attrs
;
102 ceph::real_time mtime
;
103 ceph::real_time
*pmtime
{nullptr};
104 bool exclusive
{false};
106 WOp
& set_objv_tracker(RGWObjVersionTracker
*_objv_tracker
) {
107 objv_tracker
= _objv_tracker
;
111 WOp
& set_attrs(std::map
<std::string
, bufferlist
>& _attrs
) {
116 WOp
& set_attrs(std::map
<std::string
, bufferlist
>&& _attrs
) {
121 WOp
& set_mtime(const ceph::real_time
& _mtime
) {
126 WOp
& set_pmtime(ceph::real_time
*_pmtime
) {
131 WOp
& set_exclusive(bool _exclusive
= true) {
132 exclusive
= _exclusive
;
136 WOp(Obj
& _source
) : source(_source
) {}
138 int remove(const DoutPrefixProvider
*dpp
, optional_yield y
);
139 int write(const DoutPrefixProvider
*dpp
, bufferlist
& bl
, optional_yield y
);
141 int write_data(const DoutPrefixProvider
*dpp
, bufferlist
& bl
, optional_yield y
); /* write data only */
142 int write_attrs(const DoutPrefixProvider
*dpp
, optional_yield y
); /* write attrs only */
143 int write_attr(const DoutPrefixProvider
*dpp
, const char *name
, bufferlist
& bl
,
144 optional_yield y
); /* write attrs only */
150 bool must_exist
{false};
152 OmapOp
& set_must_exist(bool _must_exist
= true) {
153 must_exist
= _must_exist
;
157 OmapOp(Obj
& _source
) : source(_source
) {}
159 int get_all(const DoutPrefixProvider
*dpp
, std::map
<std::string
, bufferlist
> *m
, optional_yield y
);
160 int get_vals(const DoutPrefixProvider
*dpp
, const std::string
& marker
, uint64_t count
,
161 std::map
<std::string
, bufferlist
> *m
,
162 bool *pmore
, optional_yield y
);
163 int set(const DoutPrefixProvider
*dpp
, const std::string
& key
, bufferlist
& bl
, optional_yield y
);
164 int set(const DoutPrefixProvider
*dpp
, const std::map
<std::string
, bufferlist
>& m
, optional_yield y
);
165 int del(const DoutPrefixProvider
*dpp
, const std::string
& key
, optional_yield y
);
171 WNOp(Obj
& _source
) : source(_source
) {}
173 int notify(const DoutPrefixProvider
*dpp
, bufferlist
& bl
, uint64_t timeout_ms
, bufferlist
*pbl
,
185 return OmapOp(*this);
195 friend class RGWSI_SysObj_Core
;
197 RGWSI_SysObj_Core
*core_svc
;
201 using ListImplInfo
= RGWSI_SysObj_Pool_ListInfo
;
204 ceph::static_ptr
<ListImplInfo
, sizeof(RGWSI_SysObj_Core_PoolListImplInfo
)> impl
; /* update this if creating new backend types */
208 Pool(RGWSI_SysObj_Core
*_core_svc
,
209 const rgw_pool
& _pool
) : core_svc(_core_svc
),
212 rgw_pool
& get_pool() {
220 Op(Pool
& _source
) : source(_source
) {}
222 int init(const DoutPrefixProvider
*dpp
, const std::string
& marker
, const std::string
& prefix
);
223 int get_next(const DoutPrefixProvider
*dpp
, int max
, std::vector
<std::string
> *oids
, bool *is_truncated
);
224 int get_marker(std::string
*marker
);
227 int list_prefixed_objs(const DoutPrefixProvider
*dpp
, const std::string
& prefix
, std::function
<void(const std::string
&)> cb
);
229 template <typename Container
>
230 int list_prefixed_objs(const DoutPrefixProvider
*dpp
, const std::string
& prefix
,
232 return list_prefixed_objs(dpp
, prefix
, [&](const std::string
& val
) {
233 result
->push_back(val
);
243 friend class Obj::ROp
;
244 friend class Obj::WOp
;
246 friend class Pool::Op
;
249 RGWSI_RADOS
*rados_svc
{nullptr};
250 RGWSI_SysObj_Core
*core_svc
{nullptr};
252 void init(RGWSI_RADOS
*_rados_svc
,
253 RGWSI_SysObj_Core
*_core_svc
) {
254 rados_svc
= _rados_svc
;
255 core_svc
= _core_svc
;
259 RGWSI_SysObj(CephContext
*cct
): RGWServiceInstance(cct
) {}
261 Obj
get_obj(const rgw_raw_obj
& obj
);
263 Pool
get_pool(const rgw_pool
& pool
) {
264 return Pool(core_svc
, pool
);
267 RGWSI_Zone
*get_zone_svc();
270 using RGWSysObj
= RGWSI_SysObj::Obj
;