Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MOSDBackoff.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2017 Red Hat
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software
11  * Foundation.  See file COPYING.
12  *
13  */
14
15
16 #ifndef CEPH_MOSDBACKOFF_H
17 #define CEPH_MOSDBACKOFF_H
18
19 #include "MOSDFastDispatchOp.h"
20 #include "osd/osd_types.h"
21
22 class MOSDBackoff : public MOSDFastDispatchOp {
23 public:
24   static constexpr int HEAD_VERSION = 1;
25   static constexpr int COMPAT_VERSION = 1;
26
27   spg_t pgid;
28   epoch_t map_epoch = 0;
29   uint8_t op = 0;           ///< CEPH_OSD_BACKOFF_OP_*
30   uint64_t id = 0;          ///< unique id within this session
31   hobject_t begin, end;     ///< [) range to block, unless ==, block single obj
32
33   spg_t get_spg() const override {
34     return pgid;
35   }
36   epoch_t get_map_epoch() const override {
37     return map_epoch;
38   }
39
40   MOSDBackoff()
41     : MOSDFastDispatchOp(CEPH_MSG_OSD_BACKOFF, HEAD_VERSION, COMPAT_VERSION) {}
42   MOSDBackoff(spg_t pgid_, epoch_t ep, uint8_t op_, uint64_t id_,
43               hobject_t begin_, hobject_t end_)
44     : MOSDFastDispatchOp(CEPH_MSG_OSD_BACKOFF, HEAD_VERSION, COMPAT_VERSION),
45       pgid(pgid_),
46       map_epoch(ep),
47       op(op_),
48       id(id_),
49       begin(begin_),
50       end(end_) { }
51
52   void encode_payload(uint64_t features) override {
53     ::encode(pgid, payload);
54     ::encode(map_epoch, payload);
55     ::encode(op, payload);
56     ::encode(id, payload);
57     ::encode(begin, payload);
58     ::encode(end, payload);
59   }
60
61   void decode_payload() override {
62     auto p = payload.begin();
63     ::decode(pgid, p);
64     ::decode(map_epoch, p);
65     ::decode(op, p);
66     ::decode(id, p);
67     ::decode(begin, p);
68     ::decode(end, p);
69   }
70
71   const char *get_type_name() const override { return "osd_backoff"; }
72
73   void print(ostream& out) const override {
74     out << "osd_backoff(" << pgid << " " << ceph_osd_backoff_op_name(op)
75         << " id " << id
76         << " [" << begin << "," << end << ")"
77         << " e" << map_epoch << ")";
78   }
79 };
80
81 #endif