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