]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_etag_verifier.h
import ceph pacific 16.2.5
[ceph.git] / ceph / src / rgw / rgw_etag_verifier.h
CommitLineData
adb31ebb
TL
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/*
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.
9 *
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
13 * on the MPU parts.
14 */
15#ifndef CEPH_RGW_ETAG_VERIFIER_H
16#define CEPH_RGW_ETAG_VERIFIER_H
17
18#include "rgw_putobj.h"
19#include "rgw_op.h"
20#include "common/static_ptr.h"
21
22namespace rgw::putobj {
23
24class ETagVerifier : public rgw::putobj::Pipe
25{
26protected:
27 CephContext* cct;
28 MD5 hash;
29 string calculated_etag;
30
31public:
32 ETagVerifier(CephContext* cct_, rgw::putobj::DataProcessor *next)
33 : Pipe(next), cct(cct_) {}
34
35 virtual void calculate_etag() = 0;
36 string get_calculated_etag() { return calculated_etag;}
37
38}; /* ETagVerifier */
39
40class ETagVerifier_Atomic : public ETagVerifier
41{
42public:
43 ETagVerifier_Atomic(CephContext* cct_, rgw::putobj::DataProcessor *next)
44 : ETagVerifier(cct_, next) {}
45
46 int process(bufferlist&& data, uint64_t logical_offset) override;
47 void calculate_etag() override;
48
49}; /* ETagVerifier_Atomic */
50
51class ETagVerifier_MPU : public ETagVerifier
52{
53 std::vector<uint64_t> part_ofs;
f67539c2 54 uint64_t cur_part_index{0}, next_part_index{1};
adb31ebb
TL
55 MD5 mpu_etag_hash;
56
57 void process_end_of_MPU_part();
58
59public:
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))
65 {}
66
67 int process(bufferlist&& data, uint64_t logical_offset) override;
68 void calculate_etag() override;
69
70}; /* ETagVerifier_MPU */
71
72constexpr auto max_etag_verifier_size = std::max(
73 sizeof(ETagVerifier_Atomic),
74 sizeof(ETagVerifier_MPU)
75 );
76using etag_verifier_ptr = ceph::static_ptr<ETagVerifier, max_etag_verifier_size>;
77
b3b6e05e
TL
78int create_etag_verifier(const DoutPrefixProvider *dpp,
79 CephContext* cct, DataProcessor* next,
adb31ebb
TL
80 const bufferlist& manifest_bl,
81 const std::optional<RGWCompressionInfo>& compression,
82 etag_verifier_ptr& verifier);
83
84} // namespace rgw::putobj
85
86#endif /* CEPH_RGW_ETAG_VERIFIER_H */