Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MOSDPGScan.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 #ifndef CEPH_MOSDPGSCAN_H
16 #define CEPH_MOSDPGSCAN_H
17
18 #include "MOSDFastDispatchOp.h"
19
20 class MOSDPGScan : public MOSDFastDispatchOp {
21
22   static const int HEAD_VERSION = 2;
23   static const int COMPAT_VERSION = 2;
24
25 public:
26   enum {
27     OP_SCAN_GET_DIGEST = 1,      // just objects and versions
28     OP_SCAN_DIGEST = 2,          // result
29   };
30   const char *get_op_name(int o) const {
31     switch (o) {
32     case OP_SCAN_GET_DIGEST: return "get_digest";
33     case OP_SCAN_DIGEST: return "digest";
34     default: return "???";
35     }
36   }
37
38   __u32 op = 0;
39   epoch_t map_epoch = 0, query_epoch = 0;
40   pg_shard_t from;
41   spg_t pgid;
42   hobject_t begin, end;
43
44   epoch_t get_map_epoch() const override {
45     return map_epoch;
46   }
47   epoch_t get_min_epoch() const override {
48     return query_epoch;
49   }
50   spg_t get_spg() const override {
51     return pgid;
52   }
53
54   void decode_payload() override {
55     bufferlist::iterator p = payload.begin();
56     ::decode(op, p);
57     ::decode(map_epoch, p);
58     ::decode(query_epoch, p);
59     ::decode(pgid.pgid, p);
60     ::decode(begin, p);
61     ::decode(end, p);
62
63     // handle hobject_t format upgrade
64     if (!begin.is_max() && begin.pool == -1)
65       begin.pool = pgid.pool();
66     if (!end.is_max() && end.pool == -1)
67       end.pool = pgid.pool();
68
69     ::decode(from, p);
70     ::decode(pgid.shard, p);
71   }
72
73   void encode_payload(uint64_t features) override {
74     ::encode(op, payload);
75     ::encode(map_epoch, payload);
76     ::encode(query_epoch, payload);
77     ::encode(pgid.pgid, payload);
78     ::encode(begin, payload);
79     ::encode(end, payload);
80     ::encode(from, payload);
81     ::encode(pgid.shard, payload);
82   }
83
84   MOSDPGScan()
85     : MOSDFastDispatchOp(MSG_OSD_PG_SCAN, HEAD_VERSION, COMPAT_VERSION) {}
86   MOSDPGScan(__u32 o, pg_shard_t from,
87              epoch_t e, epoch_t qe, spg_t p, hobject_t be, hobject_t en)
88     : MOSDFastDispatchOp(MSG_OSD_PG_SCAN, HEAD_VERSION, COMPAT_VERSION),
89       op(o),
90       map_epoch(e), query_epoch(e),
91       from(from),
92       pgid(p),
93       begin(be), end(en) {
94   }
95 private:
96   ~MOSDPGScan() override {}
97
98 public:
99   const char *get_type_name() const override { return "pg_scan"; }
100   void print(ostream& out) const override {
101     out << "pg_scan(" << get_op_name(op)
102         << " " << pgid
103         << " " << begin << "-" << end
104         << " e " << map_epoch << "/" << query_epoch
105         << ")";
106   }
107 };
108
109 #endif