]> git.proxmox.com Git - ceph.git/blob - ceph/src/osd/osd_op_util.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / osd / osd_op_util.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #pragma once
5
6 #include <vector>
7 #include <string>
8
9 #include "osd/OSDMap.h"
10
11 #include "messages/MOSDOp.h"
12
13 class OpInfo {
14 public:
15 struct ClassInfo {
16 ClassInfo(std::string&& class_name, std::string&& method_name,
17 bool read, bool write, bool allowed) :
18 class_name(std::move(class_name)), method_name(std::move(method_name)),
19 read(read), write(write), allowed(allowed)
20 {}
21 const std::string class_name;
22 const std::string method_name;
23 const bool read, write, allowed;
24 };
25
26 private:
27 uint64_t rmw_flags = 0;
28 std::vector<ClassInfo> classes;
29
30 void set_rmw_flags(int flags);
31
32 void add_class(std::string&& class_name, std::string&& method_name,
33 bool read, bool write, bool allowed) {
34 classes.emplace_back(std::move(class_name), std::move(method_name),
35 read, write, allowed);
36 }
37
38 public:
39
40 void clear() {
41 rmw_flags = 0;
42 }
43
44 uint64_t get_flags() const {
45 return rmw_flags;
46 }
47
48 bool check_rmw(int flag) const ;
49 bool may_read() const;
50 bool may_write() const;
51 bool may_cache() const;
52 bool rwordered_forced() const;
53 bool rwordered() const;
54 bool includes_pg_op() const;
55 bool need_read_cap() const;
56 bool need_write_cap() const;
57 bool need_promote() const;
58 bool need_skip_handle_cache() const;
59 bool need_skip_promote() const;
60 bool allows_returnvec() const;
61
62 void set_read();
63 void set_write();
64 void set_cache();
65 void set_class_read();
66 void set_class_write();
67 void set_pg_op();
68 void set_promote();
69 void set_skip_handle_cache();
70 void set_skip_promote();
71 void set_force_rwordered();
72 void set_returnvec();
73
74 int set_from_op(
75 const MOSDOp *m,
76 const OSDMap &osdmap);
77 int set_from_op(
78 const std::vector<OSDOp> &ops,
79 const pg_t &pg,
80 const OSDMap &osdmap);
81
82 std::vector<ClassInfo> get_classes() const {
83 return classes;
84 }
85 };
86
87 std::ostream& operator<<(std::ostream& out, const OpInfo::ClassInfo& i);