3 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
4 // vim: ts=8 sw=2 smarttab ft=cpp
7 * Ceph - scalable distributed file system
9 * Copyright (C) 2019 Red Hat, Inc.
11 * This is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License version 2.1, as published by the Free Software
14 * Foundation. See file COPYING.
21 #include "rgw/rgw_service.h"
23 #include "svc_meta_be.h"
24 #include "svc_sys_obj.h"
27 class RGWSI_MBSObj_Handler_Module
: public RGWSI_MetaBackend::Module
{
31 RGWSI_MBSObj_Handler_Module(const string
& _section
) : section(_section
) {}
32 virtual void get_pool_and_oid(const std::string
& key
, rgw_pool
*pool
, std::string
*oid
) = 0;
33 virtual const std::string
& get_oid_prefix() = 0;
34 virtual std::string
key_to_oid(const std::string
& key
) = 0;
35 virtual bool is_valid_oid(const std::string
& oid
) = 0;
36 virtual std::string
oid_to_key(const std::string
& oid
) = 0;
38 const std::string
& get_section() {
42 /* key to use for hashing entries for log shard placement */
43 virtual std::string
get_hash_key(const std::string
& key
) {
44 return section
+ ":" + key
;
48 struct RGWSI_MBSObj_GetParams
: public RGWSI_MetaBackend::GetParams
{
49 bufferlist
*pbl
{nullptr};
50 map
<string
, bufferlist
> *pattrs
{nullptr};
51 rgw_cache_entry_info
*cache_info
{nullptr};
52 boost::optional
<obj_version
> refresh_version
;
54 RGWSI_MBSObj_GetParams() {}
55 RGWSI_MBSObj_GetParams(bufferlist
*_pbl
,
56 std::map
<string
, bufferlist
> *_pattrs
,
57 ceph::real_time
*_pmtime
) : RGWSI_MetaBackend::GetParams(_pmtime
),
61 RGWSI_MBSObj_GetParams
& set_cache_info(rgw_cache_entry_info
*_cache_info
) {
62 cache_info
= _cache_info
;
65 RGWSI_MBSObj_GetParams
& set_refresh_version(boost::optional
<obj_version
>& _refresh_version
) {
66 refresh_version
= _refresh_version
;
71 struct RGWSI_MBSObj_PutParams
: public RGWSI_MetaBackend::PutParams
{
73 map
<string
, bufferlist
> *pattrs
{nullptr};
74 bool exclusive
{false};
76 RGWSI_MBSObj_PutParams() {}
77 RGWSI_MBSObj_PutParams(std::map
<string
, bufferlist
> *_pattrs
,
78 const ceph::real_time
& _mtime
) : RGWSI_MetaBackend::PutParams(_mtime
),
80 RGWSI_MBSObj_PutParams(bufferlist
& _bl
,
81 std::map
<string
, bufferlist
> *_pattrs
,
82 const ceph::real_time
& _mtime
,
83 bool _exclusive
) : RGWSI_MetaBackend::PutParams(_mtime
),
86 exclusive(_exclusive
) {}
89 struct RGWSI_MBSObj_RemoveParams
: public RGWSI_MetaBackend::RemoveParams
{
92 class RGWSI_MetaBackend_SObj
: public RGWSI_MetaBackend
95 RGWSI_SysObj
*sysobj_svc
{nullptr};
98 struct Context_SObj
: public RGWSI_MetaBackend::Context
{
99 RGWSI_SysObj
*sysobj_svc
{nullptr};
101 RGWSI_MBSObj_Handler_Module
*module
{nullptr};
102 std::optional
<RGWSysObjectCtx
> _obj_ctx
;
103 RGWSysObjectCtx
*obj_ctx
{nullptr};
105 std::optional
<RGWSI_SysObj::Pool
> pool
;
106 std::optional
<RGWSI_SysObj::Pool::Op
> op
;
109 Context_SObj(RGWSI_SysObj
*_sysobj_svc
,
110 RGWSysObjectCtx
*_oc
= nullptr) : sysobj_svc(_sysobj_svc
),
113 void init(RGWSI_MetaBackend_Handler
*h
) override
;
116 RGWSI_MetaBackend_SObj(CephContext
*cct
);
117 virtual ~RGWSI_MetaBackend_SObj();
119 RGWSI_MetaBackend::Type
get_type() {
123 void init(RGWSI_SysObj
*_sysobj_svc
,
124 RGWSI_MDLog
*_mdlog_svc
) {
125 base_init(_mdlog_svc
);
126 sysobj_svc
= _sysobj_svc
;
129 RGWSI_MetaBackend_Handler
*alloc_be_handler() override
;
130 RGWSI_MetaBackend::Context
*alloc_ctx() override
;
133 int call_with_get_params(ceph::real_time
*pmtime
, std::function
<int(RGWSI_MetaBackend::GetParams
&)> cb
) override
;
135 int pre_modify(RGWSI_MetaBackend::Context
*ctx
,
137 RGWMetadataLogData
& log_data
,
138 RGWObjVersionTracker
*objv_tracker
,
139 RGWMDLogStatus op_type
,
141 int post_modify(RGWSI_MetaBackend::Context
*ctx
,
143 RGWMetadataLogData
& log_data
,
144 RGWObjVersionTracker
*objv_tracker
, int ret
,
147 int get_entry(RGWSI_MetaBackend::Context
*ctx
,
149 RGWSI_MetaBackend::GetParams
& params
,
150 RGWObjVersionTracker
*objv_tracker
,
151 optional_yield y
) override
;
152 int put_entry(RGWSI_MetaBackend::Context
*ctx
,
154 RGWSI_MetaBackend::PutParams
& params
,
155 RGWObjVersionTracker
*objv_tracker
,
156 optional_yield y
) override
;
157 int remove_entry(RGWSI_MetaBackend::Context
*ctx
,
159 RGWSI_MetaBackend::RemoveParams
& params
,
160 RGWObjVersionTracker
*objv_tracker
,
161 optional_yield y
) override
;
163 int list_init(RGWSI_MetaBackend::Context
*_ctx
, const string
& marker
) override
;
164 int list_next(RGWSI_MetaBackend::Context
*_ctx
,
165 int max
, list
<string
> *keys
,
166 bool *truncated
) override
;
167 int list_get_marker(RGWSI_MetaBackend::Context
*ctx
,
168 string
*marker
) override
;
170 int get_shard_id(RGWSI_MetaBackend::Context
*ctx
,
171 const std::string
& key
,
172 int *shard_id
) override
;
174 int call(std::optional
<RGWSI_MetaBackend_CtxParams
> opt
,
175 std::function
<int(RGWSI_MetaBackend::Context
*)> f
) override
;
179 class RGWSI_MetaBackend_Handler_SObj
: public RGWSI_MetaBackend_Handler
{
180 friend class RGWSI_MetaBackend_SObj::Context_SObj
;
182 RGWSI_MBSObj_Handler_Module
*module
{nullptr};
185 RGWSI_MetaBackend_Handler_SObj(RGWSI_MetaBackend
*be
) :
186 RGWSI_MetaBackend_Handler(be
) {}
188 void set_module(RGWSI_MBSObj_Handler_Module
*_module
) {
192 RGWSI_MBSObj_Handler_Module
*get_module() {