Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MOSDECSubOpWrite.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 MOSDECSUBOPWRITE_H
16 #define MOSDECSUBOPWRITE_H
17
18 #include "MOSDFastDispatchOp.h"
19 #include "osd/ECMsgTypes.h"
20
21 class MOSDECSubOpWrite : public MOSDFastDispatchOp {
22   static const int HEAD_VERSION = 2;
23   static const int COMPAT_VERSION = 1;
24
25 public:
26   spg_t pgid;
27   epoch_t map_epoch, min_epoch;
28   ECSubWrite 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   MOSDECSubOpWrite()
44     : MOSDFastDispatchOp(MSG_OSD_EC_WRITE, HEAD_VERSION, COMPAT_VERSION)
45     {}
46   MOSDECSubOpWrite(ECSubWrite &in_op)
47     : MOSDFastDispatchOp(MSG_OSD_EC_WRITE, HEAD_VERSION, COMPAT_VERSION) {
48     op.claim(in_op);
49   }
50
51   void decode_payload() override {
52     bufferlist::iterator p = payload.begin();
53     ::decode(pgid, p);
54     ::decode(map_epoch, p);
55     ::decode(op, p);
56     if (header.version >= 2) {
57       ::decode(min_epoch, p);
58       decode_trace(p);
59     } else {
60       min_epoch = map_epoch;
61     }
62   }
63
64   void encode_payload(uint64_t features) override {
65     ::encode(pgid, payload);
66     ::encode(map_epoch, payload);
67     ::encode(op, payload);
68     ::encode(min_epoch, payload);
69     encode_trace(payload, features);
70   }
71
72   const char *get_type_name() const override { return "MOSDECSubOpWrite"; }
73
74   void print(ostream& out) const override {
75     out << "MOSDECSubOpWrite(" << pgid
76         << " " << map_epoch << "/" << min_epoch
77         << " " << op;
78     out << ")";
79   }
80
81   void clear_buffers() override {
82     op.t = ObjectStore::Transaction();
83     op.log_entries.clear();
84   }
85 };
86
87 #endif