]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_multi.h
import ceph pacific 16.2.5
[ceph.git] / ceph / src / rgw / rgw_multi.h
CommitLineData
7c673cae 1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
9f95a23c 2// vim: ts=8 sw=2 smarttab ft=cpp
7c673cae
FG
3
4#ifndef CEPH_RGW_MULTI_H
5#define CEPH_RGW_MULTI_H
6
7#include <map>
8#include "rgw_xml.h"
9f95a23c
TL
9#include "rgw_obj_manifest.h"
10#include "rgw_compression_types.h"
b3b6e05e 11#include "common/dout.h"
9f95a23c
TL
12
13namespace rgw { namespace sal {
14 class RGWRadosStore;
15} }
7c673cae 16
7c673cae
FG
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
9f95a23c
TL
20class RGWMPObj;
21
22struct 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};
63WRITE_CLASS_ENCODER(RGWUploadPartInfo)
64
7c673cae
FG
65class RGWMultiCompleteUpload : public XMLObj
66{
67public:
68 RGWMultiCompleteUpload() {}
69 ~RGWMultiCompleteUpload() override {}
70 bool xml_end(const char *el) override;
71
72 std::map<int, string> parts;
73};
74
75class RGWMultiPart : public XMLObj
76{
77 string etag;
78 int num;
79public:
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
88class RGWMultiPartNumber : public XMLObj
89{
90public:
91 RGWMultiPartNumber() {}
92 ~RGWMultiPartNumber() override {}
93};
94
95class RGWMultiETag : public XMLObj
96{
97public:
98 RGWMultiETag() {}
99 ~RGWMultiETag() override {}
100};
101
102class RGWMultiXMLParser : public RGWXMLParser
103{
104 XMLObj *alloc_obj(const char *el) override;
105public:
106 RGWMultiXMLParser() {}
107 ~RGWMultiXMLParser() override {}
108};
109
7c673cae
FG
110extern bool is_v2_upload_id(const string& upload_id);
111
b3b6e05e
TL
112extern int list_multipart_parts(const DoutPrefixProvider *dpp,
113 rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info,
11fdf7f2 114 CephContext *cct,
7c673cae 115 const string& upload_id,
11fdf7f2 116 const string& meta_oid, int num_parts,
7c673cae
FG
117 int marker, map<uint32_t, RGWUploadPartInfo>& parts,
118 int *next_marker, bool *truncated,
119 bool assume_unsorted = false);
120
b3b6e05e
TL
121extern int list_multipart_parts(const DoutPrefixProvider *dpp,
122 rgw::sal::RGWRadosStore *store, struct req_state *s,
7c673cae 123 const string& upload_id,
11fdf7f2 124 const string& meta_oid, int num_parts,
7c673cae
FG
125 int marker, map<uint32_t, RGWUploadPartInfo>& parts,
126 int *next_marker, bool *truncated,
127 bool assume_unsorted = false);
128
b3b6e05e 129extern int abort_multipart_upload(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, CephContext *cct, RGWObjectCtx *obj_ctx,
7c673cae
FG
130 RGWBucketInfo& bucket_info, RGWMPObj& mp_obj);
131
b3b6e05e
TL
132extern int list_bucket_multiparts(const DoutPrefixProvider *dpp,
133 rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info,
494da23a
TL
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);
224ce89b 140
b3b6e05e 141extern int abort_bucket_multiparts(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, CephContext *cct, RGWBucketInfo& bucket_info,
224ce89b 142 string& prefix, string& delim);
7c673cae 143#endif