Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MOSDECSubOpRead.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) 2013 Inktank Storage, Inc.
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 #ifndef MOSDECSUBOPREAD_H
16 #define MOSDECSUBOPREAD_H
17
18 #include "MOSDFastDispatchOp.h"
19 #include "osd/ECMsgTypes.h"
20
21 class MOSDECSubOpRead : public MOSDFastDispatchOp {
22   static const int HEAD_VERSION = 3;
23   static const int COMPAT_VERSION = 1;
24
25 public:
26   spg_t pgid;
27   epoch_t map_epoch, min_epoch;
28   ECSubRead op;
29
30   int get_cost() const override {
31     return 0;
32   }
33   epoch_t get_map_epoch() const override {
34     return map_epoch;
35   }
36   epoch_t get_min_epoch() const override {
37     return min_epoch;
38   }
39   spg_t get_spg() const override {
40     return pgid;
41   }
42
43   MOSDECSubOpRead()
44     : MOSDFastDispatchOp(MSG_OSD_EC_READ, HEAD_VERSION, COMPAT_VERSION)
45     {}
46
47   void decode_payload() override {
48     bufferlist::iterator p = payload.begin();
49     ::decode(pgid, p);
50     ::decode(map_epoch, p);
51     ::decode(op, p);
52     if (header.version >= 3) {
53       ::decode(min_epoch, p);
54       decode_trace(p);
55     } else {
56       min_epoch = map_epoch;
57     }
58   }
59
60   void encode_payload(uint64_t features) override {
61     ::encode(pgid, payload);
62     ::encode(map_epoch, payload);
63     ::encode(op, payload, features);
64     ::encode(min_epoch, payload);
65     encode_trace(payload, features);
66   }
67
68   const char *get_type_name() const override { return "MOSDECSubOpRead"; }
69
70   void print(ostream& out) const override {
71     out << "MOSDECSubOpRead(" << pgid
72         << " " << map_epoch << "/" << min_epoch
73         << " " << op;
74     out << ")";
75   }
76 };
77
78 #endif