]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDPGQuery.h
bd6bf44150be2c2aaeb5fc4ebc114d3d0ae5a14c
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
16 #ifndef CEPH_MOSDPGQUERY_H
17 #define CEPH_MOSDPGQUERY_H
19 #include "common/hobject.h"
20 #include "msg/Message.h"
23 * PGQuery - query another OSD as to the contents of their PGs
26 class MOSDPGQuery
: public Message
{
27 static const int HEAD_VERSION
= 4;
28 static const int COMPAT_VERSION
= 3;
33 version_t
get_epoch() const { return epoch
; }
34 map
<spg_t
, pg_query_t
> pg_list
;
36 MOSDPGQuery() : Message(MSG_OSD_PG_QUERY
,
39 set_priority(CEPH_MSG_PRIO_HIGH
);
41 MOSDPGQuery(epoch_t e
, map
<spg_t
,pg_query_t
>& ls
) :
42 Message(MSG_OSD_PG_QUERY
,
47 set_priority(CEPH_MSG_PRIO_HIGH
);
50 ~MOSDPGQuery() override
{}
53 const char *get_type_name() const override
{ return "pg_query"; }
54 void print(ostream
& out
) const override
{
56 for (map
<spg_t
,pg_query_t
>::const_iterator p
= pg_list
.begin();
57 p
!= pg_list
.end(); ++p
) {
58 if (p
!= pg_list
.begin())
62 out
<< " epoch " << epoch
<< ")";
65 void encode_payload(uint64_t features
) override
{
66 if (HAVE_FEATURE(features
, SERVER_LUMINOUS
)) {
67 header
.version
= HEAD_VERSION
;
69 // for kraken/jewel only
71 ::encode(epoch
, payload
);
72 vector
<pair
<pg_t
, pg_query_t
> > _pg_list
;
73 _pg_list
.reserve(pg_list
.size());
74 vector
<shard_id_t
> _shard_list
;
75 _shard_list
.reserve(pg_list
.size());
76 for (map
<spg_t
, pg_query_t
>::iterator i
= pg_list
.begin();
79 _pg_list
.push_back(make_pair(i
->first
.pgid
, i
->second
));
80 _shard_list
.push_back(i
->first
.shard
);
82 ::encode(_pg_list
, payload
, features
);
83 ::encode(_shard_list
, payload
);
86 ::encode(epoch
, payload
);
87 ::encode(pg_list
, payload
, features
);
89 void decode_payload() override
{
90 bufferlist::iterator p
= payload
.begin();
91 if (header
.version
< 4) {
92 // for kraken/jewel only
94 vector
<pair
<pg_t
, pg_query_t
> > _pg_list
;
95 ::decode(_pg_list
, p
);
96 vector
<shard_id_t
> _shard_list(_pg_list
.size(), shard_id_t::NO_SHARD
);
98 ::decode(_shard_list
, p
);
99 assert(_pg_list
.size() == _shard_list
.size());
100 for (unsigned i
= 0; i
< _pg_list
.size(); ++i
) {
103 spg_t(_pg_list
[i
].first
, _shard_list
[i
]), _pg_list
[i
].second
));
108 ::decode(pg_list
, p
);