summaryrefslogtreecommitdiffstats
path: root/src/cls/cas/cls_cas_ops.h
blob: a79013f0ea12cfcf0b75699e34b8a74e46db878a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#ifndef CEPH_CLS_CAS_OPS_H
#define CEPH_CLS_CAS_OPS_H

#include "include/types.h"
#include "common/hobject.h"
#include "common/Formatter.h"

struct cls_cas_chunk_create_or_get_ref_op {
  enum {
    FLAG_VERIFY = 1,  // verify content bit-for-bit if chunk already exists
  };

  hobject_t source;
  uint64_t flags = 0;
  bufferlist data;

  cls_cas_chunk_create_or_get_ref_op() {}

  void encode(ceph::buffer::list& bl) const {
    ENCODE_START(1, 1, bl);
    encode(source, bl);
    encode(flags, bl);
    encode(data, bl);
    ENCODE_FINISH(bl);
  }

  void decode(ceph::buffer::list::const_iterator& bl) {
    DECODE_START(1, bl);
    decode(source, bl);
    decode(flags, bl);
    decode(data, bl);
    DECODE_FINISH(bl);
  }
  void dump(ceph::Formatter *f) const {
    f->dump_object("source", source);
    f->dump_unsigned("flags", flags);
    f->dump_unsigned("data_len", data.length());
  }
  static void generate_test_instances(std::list<cls_cas_chunk_create_or_get_ref_op*>& ls) {
    ls.push_back(new cls_cas_chunk_create_or_get_ref_op());
  }
};
WRITE_CLASS_ENCODER(cls_cas_chunk_create_or_get_ref_op)


struct cls_cas_chunk_get_ref_op {
  hobject_t source;

  cls_cas_chunk_get_ref_op() {}

  void encode(ceph::buffer::list& bl) const {
    ENCODE_START(1, 1, bl);
    encode(source, bl);
    ENCODE_FINISH(bl);
  }

  void decode(ceph::buffer::list::const_iterator& bl) {
    DECODE_START(1, bl);
    decode(source, bl);
    DECODE_FINISH(bl);
  }
  void dump(ceph::Formatter *f) const {
    f->dump_object("source", source);
  }
  static void generate_test_instances(std::list<cls_cas_chunk_get_ref_op*>& ls) {
    ls.push_back(new cls_cas_chunk_get_ref_op());
  }
};
WRITE_CLASS_ENCODER(cls_cas_chunk_get_ref_op)


struct cls_cas_chunk_put_ref_op {
  hobject_t source;

  cls_cas_chunk_put_ref_op() {}

  void encode(ceph::buffer::list& bl) const {
    ENCODE_START(1, 1, bl);
    encode(source, bl);
    ENCODE_FINISH(bl);
  }

  void decode(ceph::buffer::list::const_iterator& bl) {
    DECODE_START(1, bl);
    decode(source, bl);
    DECODE_FINISH(bl);
  }

  void dump(ceph::Formatter *f) const {
    f->dump_object("source", source);
  }
  static void generate_test_instances(std::list<cls_cas_chunk_put_ref_op*>& ls) {
    ls.push_back(new cls_cas_chunk_put_ref_op());
  }
};
WRITE_CLASS_ENCODER(cls_cas_chunk_put_ref_op)

#endif