]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_multi.h
import ceph pacific 16.2.5
[ceph.git] / ceph / src / rgw / rgw_multi.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 #ifndef CEPH_RGW_MULTI_H
5 #define CEPH_RGW_MULTI_H
6
7 #include <map>
8 #include "rgw_xml.h"
9 #include "rgw_obj_manifest.h"
10 #include "rgw_compression_types.h"
11 #include "common/dout.h"
12
13 namespace rgw { namespace sal {
14 class RGWRadosStore;
15 } }
16
17 #define MULTIPART_UPLOAD_ID_PREFIX_LEGACY "2/"
18 #define MULTIPART_UPLOAD_ID_PREFIX "2~" // must contain a unique char that may not come up in gen_rand_alpha()
19
20 class RGWMPObj;
21
22 struct RGWUploadPartInfo {
23 uint32_t num;
24 uint64_t size;
25 uint64_t accounted_size{0};
26 string etag;
27 ceph::real_time modified;
28 RGWObjManifest manifest;
29 RGWCompressionInfo cs_info;
30
31 RGWUploadPartInfo() : num(0), size(0) {}
32
33 void encode(bufferlist& bl) const {
34 ENCODE_START(4, 2, bl);
35 encode(num, bl);
36 encode(size, bl);
37 encode(etag, bl);
38 encode(modified, bl);
39 encode(manifest, bl);
40 encode(cs_info, bl);
41 encode(accounted_size, bl);
42 ENCODE_FINISH(bl);
43 }
44 void decode(bufferlist::const_iterator& bl) {
45 DECODE_START_LEGACY_COMPAT_LEN(4, 2, 2, bl);
46 decode(num, bl);
47 decode(size, bl);
48 decode(etag, bl);
49 decode(modified, bl);
50 if (struct_v >= 3)
51 decode(manifest, bl);
52 if (struct_v >= 4) {
53 decode(cs_info, bl);
54 decode(accounted_size, bl);
55 } else {
56 accounted_size = size;
57 }
58 DECODE_FINISH(bl);
59 }
60 void dump(Formatter *f) const;
61 static void generate_test_instances(list<RGWUploadPartInfo*>& o);
62 };
63 WRITE_CLASS_ENCODER(RGWUploadPartInfo)
64
65 class RGWMultiCompleteUpload : public XMLObj
66 {
67 public:
68 RGWMultiCompleteUpload() {}
69 ~RGWMultiCompleteUpload() override {}
70 bool xml_end(const char *el) override;
71
72 std::map<int, string> parts;
73 };
74
75 class RGWMultiPart : public XMLObj
76 {
77 string etag;
78 int num;
79 public:
80 RGWMultiPart() : num(0) {}
81 ~RGWMultiPart() override {}
82 bool xml_end(const char *el) override;
83
84 string& get_etag() { return etag; }
85 int get_num() { return num; }
86 };
87
88 class RGWMultiPartNumber : public XMLObj
89 {
90 public:
91 RGWMultiPartNumber() {}
92 ~RGWMultiPartNumber() override {}
93 };
94
95 class RGWMultiETag : public XMLObj
96 {
97 public:
98 RGWMultiETag() {}
99 ~RGWMultiETag() override {}
100 };
101
102 class RGWMultiXMLParser : public RGWXMLParser
103 {
104 XMLObj *alloc_obj(const char *el) override;
105 public:
106 RGWMultiXMLParser() {}
107 ~RGWMultiXMLParser() override {}
108 };
109
110 extern bool is_v2_upload_id(const string& upload_id);
111
112 extern int list_multipart_parts(const DoutPrefixProvider *dpp,
113 rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info,
114 CephContext *cct,
115 const string& upload_id,
116 const string& meta_oid, int num_parts,
117 int marker, map<uint32_t, RGWUploadPartInfo>& parts,
118 int *next_marker, bool *truncated,
119 bool assume_unsorted = false);
120
121 extern int list_multipart_parts(const DoutPrefixProvider *dpp,
122 rgw::sal::RGWRadosStore *store, struct req_state *s,
123 const string& upload_id,
124 const string& meta_oid, int num_parts,
125 int marker, map<uint32_t, RGWUploadPartInfo>& parts,
126 int *next_marker, bool *truncated,
127 bool assume_unsorted = false);
128
129 extern int abort_multipart_upload(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, CephContext *cct, RGWObjectCtx *obj_ctx,
130 RGWBucketInfo& bucket_info, RGWMPObj& mp_obj);
131
132 extern int list_bucket_multiparts(const DoutPrefixProvider *dpp,
133 rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info,
134 const string& prefix,
135 const string& marker,
136 const string& delim,
137 const int& max_uploads,
138 vector<rgw_bucket_dir_entry> *objs,
139 map<string, bool> *common_prefixes, bool *is_truncated);
140
141 extern int abort_bucket_multiparts(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, CephContext *cct, RGWBucketInfo& bucket_info,
142 string& prefix, string& delim);
143 #endif