]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_etag_verifier.h
dac6ddab5f800a12a88d3f7354b2b3be1938be22
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * RGW Etag Verifier is an RGW filter which enables the objects copied using
6 * multisite sync to be verified using their ETag from source i.e. the MD5
7 * checksum of the object is computed at the destination and is verified to be
8 * identical to the ETag stored in the object HEAD at source cluster.
10 * For MPU objects, a different filter named RGWMultipartEtagFilter is applied
11 * which re-computes ETag using RGWObjManifest. This computes the ETag using the
12 * same algorithm used at the source cluster i.e. MD5 sum of the individual ETag
15 #ifndef CEPH_RGW_ETAG_VERIFIER_H
16 #define CEPH_RGW_ETAG_VERIFIER_H
18 #include "rgw_putobj.h"
20 #include "common/static_ptr.h"
22 namespace rgw::putobj
{
24 class ETagVerifier
: public rgw::putobj::Pipe
29 string calculated_etag
;
32 ETagVerifier(CephContext
* cct_
, rgw::putobj::DataProcessor
*next
)
33 : Pipe(next
), cct(cct_
) {}
35 virtual void calculate_etag() = 0;
36 string
get_calculated_etag() { return calculated_etag
;}
40 class ETagVerifier_Atomic
: public ETagVerifier
43 ETagVerifier_Atomic(CephContext
* cct_
, rgw::putobj::DataProcessor
*next
)
44 : ETagVerifier(cct_
, next
) {}
46 int process(bufferlist
&& data
, uint64_t logical_offset
) override
;
47 void calculate_etag() override
;
49 }; /* ETagVerifier_Atomic */
51 class ETagVerifier_MPU
: public ETagVerifier
53 std::vector
<uint64_t> part_ofs
;
54 uint64_t cur_part_index
{0}, next_part_index
{1};
57 void process_end_of_MPU_part();
60 ETagVerifier_MPU(CephContext
* cct
,
61 std::vector
<uint64_t> part_ofs
,
62 rgw::putobj::DataProcessor
*next
)
63 : ETagVerifier(cct
, next
),
64 part_ofs(std::move(part_ofs
))
67 int process(bufferlist
&& data
, uint64_t logical_offset
) override
;
68 void calculate_etag() override
;
70 }; /* ETagVerifier_MPU */
72 constexpr auto max_etag_verifier_size
= std::max(
73 sizeof(ETagVerifier_Atomic
),
74 sizeof(ETagVerifier_MPU
)
76 using etag_verifier_ptr
= ceph::static_ptr
<ETagVerifier
, max_etag_verifier_size
>;
78 int create_etag_verifier(CephContext
* cct
, DataProcessor
* next
,
79 const bufferlist
& manifest_bl
,
80 const std::optional
<RGWCompressionInfo
>& compression
,
81 etag_verifier_ptr
& verifier
);
83 } // namespace rgw::putobj
85 #endif /* CEPH_RGW_ETAG_VERIFIER_H */