]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/services/svc_tier_rados.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2019 Red Hat, Inc.
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
21 #include "rgw/rgw_service.h"
23 #include "svc_rados.h"
25 extern const std::string MP_META_SUFFIX
;
34 RGWMPObj(const string
& _oid
, const string
& _upload_id
) {
35 init(_oid
, _upload_id
, _upload_id
);
37 void init(const string
& _oid
, const string
& _upload_id
) {
38 init(_oid
, _upload_id
, _upload_id
);
40 void init(const string
& _oid
, const string
& _upload_id
, const string
& part_unique_str
) {
46 upload_id
= _upload_id
;
48 meta
= prefix
+ upload_id
+ MP_META_SUFFIX
;
49 prefix
.append(part_unique_str
);
51 const string
& get_meta() const { return meta
; }
52 string
get_part(int num
) const {
54 snprintf(buf
, 16, ".%d", num
);
59 string
get_part(const string
& part
) const {
65 const string
& get_upload_id() const {
68 const string
& get_key() const {
71 bool from_meta(const string
& meta
) {
72 int end_pos
= meta
.rfind('.'); // search for ".meta"
75 int mid_pos
= meta
.rfind('.', end_pos
- 1); // <key>.<upload_id>
78 oid
= meta
.substr(0, mid_pos
);
79 upload_id
= meta
.substr(mid_pos
+ 1, end_pos
- mid_pos
- 1);
80 init(oid
, upload_id
, upload_id
);
89 friend std::ostream
& operator<<(std::ostream
& out
, const RGWMPObj
& obj
) {
90 return out
<< "RGWMPObj:{ prefix=" << std::quoted(obj
.prefix
) <<
91 ", meta=" << std::quoted(obj
.meta
) << " }";
96 * A filter to a) test whether an object name is a multipart meta
97 * object, and b) filter out just the key used to determine the bucket
100 * Objects for multipart meta have names adorned with an upload id and
101 * other elements -- specifically a ".", MULTIPART_UPLOAD_ID_PREFIX,
102 * unique id, and MP_META_SUFFIX. This filter will return true when
103 * the name provided is such. It will also extract the key used for
104 * bucket index shard calculation from the adorned name.
106 class MultipartMetaFilter
: public RGWAccessListFilter
{
108 MultipartMetaFilter() {}
111 * @param name [in] The object name as it appears in the bucket index.
112 * @param key [out] An output parameter that will contain the bucket
113 * index key if this entry is in the form of a multipart meta object.
114 * @return true if the name provided is in the form of a multipart meta
115 * object, false otherwise
117 bool filter(const string
& name
, string
& key
) override
;
120 class RGWSI_Tier_RADOS
: public RGWServiceInstance
122 RGWSI_Zone
*zone_svc
{nullptr};
125 RGWSI_Tier_RADOS(CephContext
*cct
): RGWServiceInstance(cct
) {}
127 void init(RGWSI_Zone
*_zone_svc
) {
128 zone_svc
= _zone_svc
;
131 static inline bool raw_obj_to_obj(const rgw_bucket
& bucket
, const rgw_raw_obj
& raw_obj
, rgw_obj
*obj
) {
132 ssize_t pos
= raw_obj
.oid
.find('_');
137 if (!rgw_obj_key::parse_raw_oid(raw_obj
.oid
.substr(pos
+ 1), &obj
->key
)) {
140 obj
->bucket
= bucket
;