]> git.proxmox.com Git - ceph.git/blame - ceph/src/osd/osd_op_util.h
buildsys: switch source download to quincy
[ceph.git] / ceph / src / osd / osd_op_util.h
CommitLineData
9f95a23c
TL
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
f67539c2
TL
11#include "messages/MOSDOp.h"
12
9f95a23c
TL
13class OpInfo {
14public:
15 struct ClassInfo {
16 ClassInfo(std::string&& class_name, std::string&& method_name,
f67539c2 17 bool read, bool write, bool allowed) :
9f95a23c 18 class_name(std::move(class_name)), method_name(std::move(method_name)),
f67539c2 19 read(read), write(write), allowed(allowed)
9f95a23c
TL
20 {}
21 const std::string class_name;
22 const std::string method_name;
f67539c2 23 const bool read, write, allowed;
9f95a23c
TL
24 };
25
26private:
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,
f67539c2 33 bool read, bool write, bool allowed) {
9f95a23c 34 classes.emplace_back(std::move(class_name), std::move(method_name),
f67539c2 35 read, write, allowed);
9f95a23c
TL
36 }
37
38public:
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
78 std::vector<ClassInfo> get_classes() const {
79 return classes;
80 }
81};
82
83std::ostream& operator<<(std::ostream& out, const OpInfo::ClassInfo& i);