Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MOSDPGUpdateLogMissing.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) 2004-2006 Sage Weil <sage@newdream.net>
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_MOSDPGUPDATELOGMISSING_H
17 #define CEPH_MOSDPGUPDATELOGMISSING_H
18
19 #include "MOSDFastDispatchOp.h"
20
21 class MOSDPGUpdateLogMissing : public MOSDFastDispatchOp {
22
23   static const int HEAD_VERSION = 2;
24   static const int COMPAT_VERSION = 1;
25
26
27 public:
28   epoch_t map_epoch, min_epoch;
29   spg_t pgid;
30   shard_id_t from;
31   ceph_tid_t rep_tid;
32   mempool::osd_pglog::list<pg_log_entry_t> entries;
33
34   epoch_t get_epoch() const { return map_epoch; }
35   spg_t get_pgid() const { return pgid; }
36   epoch_t get_query_epoch() const { return map_epoch; }
37   ceph_tid_t get_tid() const { return rep_tid; }
38
39   epoch_t get_map_epoch() const override {
40     return map_epoch;
41   }
42   epoch_t get_min_epoch() const override {
43     return min_epoch;
44   }
45   spg_t get_spg() const override {
46     return pgid;
47   }
48
49   MOSDPGUpdateLogMissing()
50     : MOSDFastDispatchOp(MSG_OSD_PG_UPDATE_LOG_MISSING, HEAD_VERSION,
51                          COMPAT_VERSION) { }
52   MOSDPGUpdateLogMissing(
53     const mempool::osd_pglog::list<pg_log_entry_t> &entries,
54     spg_t pgid,
55     shard_id_t from,
56     epoch_t epoch,
57     epoch_t min_epoch,
58     ceph_tid_t rep_tid)
59     : MOSDFastDispatchOp(MSG_OSD_PG_UPDATE_LOG_MISSING, HEAD_VERSION,
60                          COMPAT_VERSION),
61       map_epoch(epoch),
62       min_epoch(min_epoch),
63       pgid(pgid),
64       from(from),
65       rep_tid(rep_tid),
66       entries(entries) {}
67
68 private:
69   ~MOSDPGUpdateLogMissing() override {}
70
71 public:
72   const char *get_type_name() const override { return "PGUpdateLogMissing"; }
73   void print(ostream& out) const override {
74     out << "pg_update_log_missing(" << pgid << " epoch " << map_epoch
75         << "/" << min_epoch
76         << " rep_tid " << rep_tid
77         << " entries " << entries << ")";
78   }
79
80   void encode_payload(uint64_t features) override {
81     ::encode(map_epoch, payload);
82     ::encode(pgid, payload);
83     ::encode(from, payload);
84     ::encode(rep_tid, payload);
85     ::encode(entries, payload);
86     ::encode(min_epoch, payload);
87   }
88   void decode_payload() override {
89     bufferlist::iterator p = payload.begin();
90     ::decode(map_epoch, p);
91     ::decode(pgid, p);
92     ::decode(from, p);
93     ::decode(rep_tid, p);
94     ::decode(entries, p);
95     if (header.version >= 2) {
96       ::decode(min_epoch, p);
97     } else {
98       min_epoch = map_epoch;
99     }
100   }
101 };
102
103 #endif