]>
git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MMDSResolve.h
d636bdcd559edf14246944418d7c7c9f6c2c948a
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.
15 #ifndef CEPH_MMDSRESOLVE_H
16 #define CEPH_MMDSRESOLVE_H
18 #include "include/types.h"
19 #include "mds/Capability.h"
20 #include "messages/MMDSOp.h"
22 class MMDSResolve final
: public MMDSOp
{
23 static constexpr int HEAD_VERSION
= 1;
24 static constexpr int COMPAT_VERSION
= 1;
27 std::map
<dirfrag_t
, std::vector
<dirfrag_t
>> subtrees
;
28 std::map
<dirfrag_t
, std::vector
<dirfrag_t
>> ambiguous_imports
;
30 class peer_inode_cap
{
33 std::map
<client_t
,Capability::Export
> cap_exports
;
35 peer_inode_cap(inodeno_t a
, map
<client_t
, Capability::Export
> b
) : ino(a
), cap_exports(b
) {}
36 void encode(ceph::buffer::list
&bl
) const
38 ENCODE_START(1, 1, bl
);
40 encode(cap_exports
, bl
);
43 void decode(ceph::buffer::list::const_iterator
&blp
)
47 decode(cap_exports
, blp
);
51 WRITE_CLASS_ENCODER(peer_inode_cap
)
54 ceph::buffer::list inode_caps
;
56 peer_request() : committing(false) {}
57 void encode(ceph::buffer::list
&bl
) const {
58 ENCODE_START(1, 1, bl
);
59 encode(inode_caps
, bl
);
60 encode(committing
, bl
);
63 void decode(ceph::buffer::list::const_iterator
&blp
) {
65 decode(inode_caps
, blp
);
66 decode(committing
, blp
);
71 std::map
<metareqid_t
, peer_request
> peer_requests
;
73 // table client information
76 std::set
<version_t
> pending_commits
;
78 table_client() : type(0) {}
79 table_client(int _type
, const std::set
<version_t
>& commits
)
80 : type(_type
), pending_commits(commits
) {}
82 void encode(ceph::buffer::list
& bl
) const {
85 encode(pending_commits
, bl
);
87 void decode(ceph::buffer::list::const_iterator
& bl
) {
90 decode(pending_commits
, bl
);
94 std::list
<table_client
> table_clients
;
97 MMDSResolve() : MMDSOp
{MSG_MDS_RESOLVE
, HEAD_VERSION
, COMPAT_VERSION
}
99 ~MMDSResolve() final
{}
102 std::string_view
get_type_name() const override
{ return "mds_resolve"; }
104 void print(std::ostream
& out
) const override
{
105 out
<< "mds_resolve(" << subtrees
.size()
106 << "+" << ambiguous_imports
.size()
107 << " subtrees +" << peer_requests
.size() << " peer requests)";
110 void add_subtree(dirfrag_t im
) {
111 subtrees
[im
].clear();
113 void add_subtree_bound(dirfrag_t im
, dirfrag_t ex
) {
114 subtrees
[im
].push_back(ex
);
117 void add_ambiguous_import(dirfrag_t im
, const std::vector
<dirfrag_t
>& m
) {
118 ambiguous_imports
[im
] = m
;
121 void add_peer_request(metareqid_t reqid
, bool committing
) {
122 peer_requests
[reqid
].committing
= committing
;
125 void add_peer_request(metareqid_t reqid
, ceph::buffer::list
& bl
) {
126 peer_requests
[reqid
].inode_caps
= std::move(bl
);
129 void add_table_commits(int table
, const std::set
<version_t
>& pending_commits
) {
130 table_clients
.push_back(table_client(table
, pending_commits
));
133 void encode_payload(uint64_t features
) override
{
135 encode(subtrees
, payload
);
136 encode(ambiguous_imports
, payload
);
137 encode(peer_requests
, payload
);
138 encode(table_clients
, payload
);
140 void decode_payload() override
{
142 auto p
= payload
.cbegin();
144 decode(ambiguous_imports
, p
);
145 decode(peer_requests
, p
);
146 decode(table_clients
, p
);
149 template<class T
, typename
... Args
>
150 friend boost::intrusive_ptr
<T
> ceph::make_message(Args
&&... args
);
153 inline std::ostream
& operator<<(std::ostream
& out
, const MMDSResolve::peer_request
&) {
157 WRITE_CLASS_ENCODER(MMDSResolve::peer_request
)
158 WRITE_CLASS_ENCODER(MMDSResolve::table_client
)
159 WRITE_CLASS_ENCODER(MMDSResolve::peer_inode_cap
)